The Messenger of Allah ﷺ said, "The child born of adultery is the worst of the three."Abu Hurairah said, "For me to lend out a whip for use in the cause of Allah is more beloved to me than freeing a child born of adultery."
حدثنا إبراهيم بن موسى أخبرنا جرير عن سهيل بن أبي صالح عن أبيه
قال رسول الله ﷺ ولد الزنا شر الثلاثة و قال أبو هريرة لأن أمتع بسوط في سبيل الله عز وجل أحب إلي من أن أعتق ولد زنية
[Its chain is sahih] Nasai reported it in al-Kubra, no. 4930, from the hadith of Jareer, and Ahmad, 2/311, from the hadith of Suhayl bin Abu Salih, through the same route. Hakim graded it sahih according to the criterion of Muslim, 2/214, and Dhahabi agreed with him. Some narrators added, "when he acts according to the deeds of his parents."