Sunan Ibn Majah, Book 18, Hadith 2599 (In-Book)

It was narrated that Mundhir bin Jarir said: “I was with my father in Bawazij and the cows came back in the evening. He saw a cow did not recognize it. He said: 'What is this?' He said: 'A cow that joined the herd.' And he issued orders that it be driven away until it disappeared from view. Then he said: 'I heard the Messenger of Allah say: “No one gives refuge to a stray animal but one who is also astray.”

حَدَّثَنَا مُحَمَّدُ بْنُ بَشَّارٍ، حَدَّثَنَا يَحْيَى بْنُ سَعِيدٍ، حَدَّثَنَا أَبُو حَيَّانَ التَّيْمِيُّ، حَدَّثَنَا الضَّحَّاكُ، خَالُ الْمُنْذِرِ بْنِ جَرِيرٍ عَنِ الْمُنْذِرِ بْنِ جَرِيرٍ، قَالَ كُنْتُ مَعَ أَبِي بِالْبَوَازِيجِ فَرَاحَتِ الْبَقَرُ فَرَأَى بَقَرَةً أَنْكَرَهَا فَقَالَ مَا هَذِهِ قَالُوا بَقَرَةٌ لَحِقَتْ بِالْبَقَرِ ‏.‏ قَالَ فَأَمَرَ بِهَا فَطُرِدَتْ حَتَّى تَوَارَتْ ثُمَّ قَالَ سَمِعْتُ رَسُولَ اللَّهِ صلى الله عليه وسلم يَقُولُ ‏ "‏ لاَ يُئْوِي الضَّالَّةَ إِلاَّ ضَالٌّ ‏" ‏ ‏.‏

sunnah.com