The Messenger of Allah ﷺ was asked about fruit still hanging on the tree. He said, "Whoever, being in need, eats some without carrying any away in his garment bears no liability. But whoever takes any of it away must pay double its value as a fine and also receive a punishment. Whoever steals any of it after it has been gathered into the drying-place, and the value reaches that of a shield, his hand is to be cut off. Whoever steals less than that must pay double its value as a fine and also receive a punishment."
أخبرنا قتيبة قال حدثنا الليث عن ابن عجلان عن عمرو بن شعيب عن أبيه
عن رسول الله ﷺ أنه سئل عن الثمر المعلق فقال ما أصاب من ذي حاجة غير متخذ خبنة فلا شيء عليه ومن خرج بشيء منه فعليه غرامة مثليه والعقوبة ومن سرق شيئا منه بعد أن يؤويه الجرين فبلغ ثمن المجن فعليه القطع ومن سرق دون ذلك فعليه غرامة مثليه والعقوبة
[Its isnad is hasan]. Abu Dawud narrated it in Kitab al-Luqata, chapter on identifying a lost item, Hadith: 1710, 4390, and Tirmidhi in Kitab al-Buyu, chapter on the concession permitting a passerby to eat fruit, Hadith: 1289, from Qutayba, with this wording. Tirmidhi said, hasan, and Ibn Jarud graded it sahih. See the following hadith, and its opening portion has already been given, Hadith: 2496.