The Messenger of Allah ﷺ said, "Any man who claims descent from someone other than his real father, or attaches himself as a freed slave to people other than those who actually freed him, brings upon himself the curse of Allah, the angels, and all of humanity until the Day of Resurrection. No obligatory deed nor voluntary deed will be accepted from him."
حدثنا أبو النضر حدثنا عبد الحميد حدثنا شهر قال
قال رسول الله ﷺ أيما رجل ادعى إلى غير والديه أو تولى غير مواليه الذين أعتقوه فإن عليه لعنة الله والملائكة والناس أجمعين إلى يوم القيامة لا يقبل منه صرف ولا عدل
Its isnad is sahih. It is found in Majma al-Zawaid 3:301, where he said, Ahmad narrated it, and its isnad is hasan. The word "yuwi" appears in manuscript H as "yawi," and we have adopted the reading found in manuscript K. See also 1297.