The Messenger of Allah ﷺ said, "An injury caused by an animal is not compensated, mines are not liable for compensation, wells are not liable for compensation, and on buried treasure a fifth is due."
حدثنا قتيبة حدثنا الليث بن سعد عن ابن شهاب عن سعيد بن المسيب وأبي سلمة
عن رسول الله ﷺ قال العجماء جرحها جبار والمعدن جبار والبئر جبار وفي الركاز الخمس
Agreed upon [by Bukhari and Muslim]. Muslim also reported it in the Book of Legal Punishments, chapter on the injury caused by an animal, a mine, or a well being without liability, hadith no. 1710, from Qutayba, and Bukhari, hadith no. 6912, through the hadith of Layth bin Saad, with the same wording.On this topic there are also narrations from Anas bin Malik [Ahmad 3/128], Abdullah bin Amr [Bayhaqi 4/155], Ubada bin Samit [Ibn Majah, hadith no. 2675], Amr bin Awf Muzani [Ibn Majah, hadith no. 2674], and Jabir [Ahmad 3/335, 353].