The Messenger of Allah ﷺ said, "When one of you passes by an orchard, he may eat from it, but he must not carry any away in his garment."
حدثنا هدية بن عبد الوهاب وأيوب بن حسان الواسطي وعلي بن سلمة قالوا حدثنا يحيى بن سليم الطائفي عن عبيد الله بن عمر عن نافع
قال رسول الله ﷺ إذا مر أحدكم بحائط فليأكل ولا يتخذ خبنة
Its isnad is daif. Tirmidhi narrated it in the Book of Business Transactions, chapter on the permission granted to a passerby to eat fruit he passes by, hadith 1287, from the hadith of Yahya Taifi with a similar meaning, and he said it is gharib. Yahya bin Main and others criticized him, and Bukhari said, "Yahya bin Salim narrates hadiths from Ubaydullah in which he errs" (Bayhaqi 9, "he errs" 359). Nasai said, "There is no harm in him, but he is munkar al-hadith when narrating from Ubaydullah bin Umar."I say, his hadith is daif when narrating from Ubaydullah, hasan when narrating from someone other than Ubaydullah, and sahih in the narration of Humaydi from him when narrating from someone other than Ubaydullah, and this is the most balanced of the opinions concerning him.Bayhaqi narrated with a strong isnad from Umar that he said, "Whoever among you passes by an orchard wall, let him eat from it as much as fills his stomach, but let him not take away a bundle in his garment." He said, "It is sahih by both of its isnads." Refer also to Fath al-Bari, 5/90.