The Prophet ﷺ said, "Do not sit on graves, and do not pray facing them."
حدثنا هناد حدثنا عبد الله بن المبارك عن عبد الرحمن بن يزيد بن جابر عن بسر بن عبيد الله عن أبي إدريس الخولاني عن واثلة بن الأسقع
قال النبي ﷺ لا تجلسوا على القبور ولا تصلوا إليها
SourcesMuslim also narrated it in the Book of Funerals, in the chapter on the prohibition of sitting on a grave and praying over it, hadith no. 972/98, through the hadith of Ibn Mubarak, with the same wording.There are also hadiths on this topic from Abu Hurairah [Muslim, no. 971], Amr bin [Ahmad, as cited in Jami al-Masanid wal-Sunan by Ibn Kathir, 9/558-559, no. 7274], and Bashir bin Khasasiyah [Abu Dawud, no. 3230, and Ibn Majah, no. 1568].