The Prophet (ﷺ) decided regarding one who was treated as a member of a family after the death of his father, to whom he was attributed when the heirs said he was one of them, that if he was the child of a slave-woman whom the father owned when he had intercourse with her, he was included among those who sought his inclusion, but received none of the inheritance which was previously divided; he, however, received his portion of the inheritance which had not already been divided; but if the father to whom he was attributed had disowned him, he was not joined to the heirs.
If he was a child of a slave-woman whom the father did not possess or of a free woman with whom he had illicit intercourse, he was not joined to the heirs and did not inherit even if the one to whom he was attributed is the one who claimed paternity, since he was a child of fornication whether his mother was free or a slave.
Sunan Abi Dawud Book 13, Hadith 91
Sa`d bin Abi Waqqas and 'Abu bin Zam`a had a dispute over a boy. Sa`d said, "O Allah's Messenger (ﷺ)!
This (boy) is the son of my brother, `Utba bin Abi Waqqas who told me to be his custodian as he was
his son. Please notice to whom he bears affinity." And 'Abu bin Zam`a said, "This is my brother, O
Allah's Messenger (ﷺ)! He was born on my father's bed by his slave girl." Then the Prophet (ﷺ) looked at the boy
and noticed evident resemblance between him and `Utba, so he said, "He (the toy) is for you, O 'Abu
bin Zam`a, for the boy is for the owner of the bed, and the stone is for the adulterer. Screen yourself
before the boy, O Sauda bint Zam`a." `Aisha added: Since then he had never seen Sauda.
Sahih al-Bukhari Book 85, Hadith 42