The Messenger of Allah ﷺ said, "Injuries caused by livestock are not compensable, falling into a well carries no liability, accidents in mines carry no liability, and on buried treasure a fifth is due."Qutayba narrated to us, Layth narrated to us, from Ibn Shihab, from Saeed bin Musayab and Abu Salama, from Abu Hurairah, from the Prophet ﷺ, something similar.
حدثنا أحمد بن منيع حدثنا سفيان عن الزهري عن سعيد بن المسيب
قال رسول الله ﷺ العجماء جرحها جبار والبئر جبار والمعدن جبار وفي الركاز الخمس حدثنا قتيبة حدثنا الليث عن ابن شهاب عن سعيد بن المسيب وأبي سلمة عن أبي هريرة عن النبي ﷺ نحوه
Reference, [sahih]. Abu Dawud also narrated it in "Kharaj," chapter on reviving barren land, no. 3073, from the hadith of Abdul-Wahhab through the same route, and its isnad is hasan. Hafiz strengthened it in Fath al-Bari.On this topic there is also a narration from Jabir [to come, 1379], from Amr bin Awf Muzani [Ibn Adi in Kamil, 2079/6], and from Samura [Abu Dawud, no. 3077, and Ahmad, 21, 12].