It is narrated from Zaid bin Wahb that Sayyiduna Ali (may Allah be pleased with him) said regarding a child born of adultery to the guardians of his mother: "Take him, you will be his heirs, and you will be responsible for his blood money, and he will not be your heir."
Hadith Referenceسنن دارمي / من كتاب الفرائض / 3149
Hadith Takhrijاس اثر کی سند صحیح ہے۔ دیکھے: [ابن أبى شيبه 11403]
Brief Explanation
(Explanation of Ahadith 3145 to 3149) From all these traditions, it is established that a child born out of fornication (haram zada, i.e., a child born as a result of zina) will not inherit from his fornicator father, nor will his father inherit from him. However, he will inherit from his mother, and the mother will inherit from him. The Messenger of Allah sallallahu alayhi wa sallam said: «اَلْوَلَدُلِلْفِرَاشِوَلِلْعَاهِرِالْحَجَرُ» (agreed upon), meaning the child belongs to the owner of the bed (the husband or the master), and for the fornicator there are stones, i.e., he will be stoned (rajm). This hadith has already passed in «كتاب النكاح ، باب (41) ، الولد للفراش».