If a deputy sells something (in an illegal manner)
باب إِذَا بَاعَ الْوَكِيلُ شَيْئًا فَاسِدًا فَبَيْعُهُ مَرْدُودٌ
Sahih al-Bukhari, Book of Representation, Authorization, Business by Proxy(view book)
Sahih al-Bukhari 2312
Narrated Abu Said al-Khudri:
Once Bilal brought Barni (i.e. a kind of dates) to the Prophet and the Prophet asked him, "From where have you brought these?" Bilal replied, "I had some inferior type of dates and exchanged two Sas of it for one Sa of Barni dates in order to give it to the Prophet;
to eat." Thereupon the Prophet ﷺ said, "Beware! Beware! This is definitely Riba (usury)! This is definitely Riba (Usury)! Don't do so, but if you want to buy (a superior kind of dates) sell the inferior dates for money and then buy the superior kind of dates with that money."
حَدَّثَنَا إِسْحَاقُ، حَدَّثَنَا يَحْيَى بْنُ صَالِحٍ، حَدَّثَنَا مُعَاوِيَةُ ـ هُوَ ابْنُ سَلاَّمٍ ـ عَنْ يَحْيَى، قَالَ سَمِعْتُ عُقْبَةَ بْنَ عَبْدِ الْغَافِرِ، أَنَّهُ سَمِعَ أَبَا سَعِيدٍ الْخُدْرِيَّ ـ رضى الله عنه ـ قَالَ جَاءَ بِلاَلٌ إِلَى النَّبِيِّ ﷺ بِتَمْرٍ بَرْنِيٍّ فَقَالَ لَهُ النَّبِيُّ ﷺ " مِنْ أَيْنَ هَذَا ". قَالَ بِلاَلٌ كَانَ عِنْدَنَا تَمْرٌ رَدِيٌّ، فَبِعْتُ مِنْهُ صَاعَيْنِ بِصَاعٍ، لِنُطْعِمَ النَّبِيَّ ﷺ فَقَالَ النَّبِيُّ ﷺ عِنْدَ ذَلِكَ " أَوَّهْ أَوَّهْ عَيْنُ الرِّبَا عَيْنُ الرِّبَا، لاَ تَفْعَلْ، وَلَكِنْ إِذَا أَرَدْتَ أَنْ تَشْتَرِيَ فَبِعِ التَّمْرَ بِبَيْعٍ آخَرَ ثُمَّ اشْتَرِهِ ".