It is narrated from Sayyiduna Ali (may Allah be pleased with him) that he ruled concerning a foundling that he is free, and he recited this verse: "And they sold him for a paltry price, a few counted dirhams, and they had no interest in him (Yusuf)" [Surah Yusuf: 20].
Hadith Referenceالسنن الكبرى للبيهقي / كتاب اللقطة / 12135
Juhayr bin Yazid al-Abdi said: I heard al-Hasan (may Allah have mercy on him) when he was asked about a foundling: may he be sold? He said: "Allah has refused that. Have you not read Surah Yusuf?"
Hadith Referenceالسنن الكبرى للبيهقي / كتاب اللقطة / 12136