The Messenger of Allah ﷺ said, "Any man who commits adultery with a free woman or a slave woman, the child is a child of fornication. He neither inherits nor is inherited from."
حدثنا قتيبة حدثنا ابن لهيعة
أن رسول الله ﷺ قال أيما رجل عاهر بحرة أو أمة فالولد ولد زنا لا يرث ولا يورث
[Hasan]. Ibn Majah also narrated it in "Faraid," chapter: On claiming a child, hadith no. 2745, from the hadith of Amr bin Shuayb, through him. This hadith has corroborating narrations in Ibn Hibban, hadith no. 1699, and elsewhere, and with these it is hasan.