Ubayy heard the Prophet ﷺ say, "Any man who knowingly claims someone other than his real father as his father has committed disbelief, and whoever claims to belong to a people to whom he has no lineage, let him take his seat in the Fire."
أنه سمع النبي ﷺ يقول: ليس من رجل ادعى لغير أبيه- وهو يعلمه- إلا كفر، ومن ادعى قوما ليس له فيهم فليتبوأ مقعده من النار.
Bukhari narrated it in the Book of Virtues (3508), and Muslim in the Book of Faith (61), both from the hadith of Abdul-Warith, from Husayn the teacher, from Abdullah bin Burayda, who said, Yahya bin Yamar narrated to me, that Abu Aswad Dili narrated to him from Abu Dharr, and he mentioned the hadith, their wording being the same. Muslim added, "Whoever calls a man a disbeliever, or says, 'enemy of Allah,' when he is not so, it will turn back upon him." His saying, "it will turn back upon him" means it reverts and comes back to him.