The Messenger of Allah ﷺ said, "Whoever strokes the head of an orphan, doing so solely for the sake of Allah, will receive good deeds for every hair his hand passes over. And whoever treats an orphan girl or boy in their care with kindness, he and I will be together in Paradise like these two," and he held apart his index and middle fingers.
حدثنا أبو إسحاق الطالقاني حدثنا عبد الله بن المبارك عن يحيى بن أيوب عن عبيد الله بن زحر عن علي بن يزيد عن القاسم
أن رسول الله ﷺ قال من مسح رأس يتيم لم يمسحه إلا لله كان له بكل شعرة مرت عليها يده حسنات ومن أحسن إلى يتيمة أو يتيم عنده كنت أنا وهو في الجنة كهاتين وفرق بين أصبعيه السبابة والوسطى
Its isnad is hasan, because of Ubaydullah bin Zahr and Qasim bin Abdul-Rahman, the freedman of Banu Umaya, all of whom have much said about their memory. Ali bin Yazid Alhani is likewise similar to them. The hadith of these narrators is only graded hasan in matters of exhortation and encouragement to good deeds. It is corroborated by the hadith "I and the guardian of the orphan," which will come at 22718.