Abu Uthman reported,

I heard Saad, who was the first to shoot an arrow in the path of Allah, and Abu Bakrah, who scaled the fortress of Taif along with a group of men and came over to the Prophet ﷺ. They both said, "We heard the Prophet ﷺ say, 'Whoever claims descent from someone other than his real father, knowing the truth, Paradise is forbidden to him.'"

Azami 9235

Sahih

عن أبي عثمان النهدي قال

سمعت سعدا- وهو أول من رمى بسهم في سبيل الله- وأبا بكرة، وكان تسور حصن الطائف في أناس، فجاء إلى النبي ﷺ قالا: سمعنا النبي ﷺ يقول: من ادعى إلى غير أبيه وهو يعلم فالجنة عليه حرام.

الأعظمي 9235صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Biography of the Prophet ﷺ
Chapter
Expedition of Hunayn and Taif
Section
Abu Bakra came with people to the Prophet ﷺ and they became Muslim while they were slaves
Numbering
Jami al-Kamil 9235 (2nd edition)
Azami 9235