كتاب الجنائز
11  
The Book of Prayer - Funerals
(33)
Chapter: Prohibition against sitting and praying on graves
(33)
باب النَّهْىِ عَنِ الْجُلُوسِ، عَلَى الْقَبْرِ وَالصَّلاَةِ عَلَيْهِ ‏‏
Sahih Muslim 971 a

Abu Huraira reported Allah's Messenger (ﷺ) as saying:

It is better that one of you should sit on live coals which would burn his clothing and come in contact with his skin than that he should sit on a grave.
وَحَدَّثَنِي زُهَيْرُ بْنُ حَرْبٍ، حَدَّثَنَا جَرِيرٌ، عَنْ سُهَيْلٍ، عَنْ أَبِيهِ، عَنْ أَبِي هُرَيْرَةَ، قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏ "‏ لأَنْ يَجْلِسَ أَحَدُكُمْ عَلَى جَمْرَةٍ فَتُحْرِقَ ثِيَابَهُ فَتَخْلُصَ إِلَى جِلْدِهِ خَيْرٌ لَهُ مِنْ أَنْ يَجْلِسَ عَلَى قَبْرٍ ‏"‏ ‏.‏
Reference : Sahih Muslim 971a
In-book reference : Book 11, Hadith 124
USC-MSA web (English) reference : Book 4, Hadith 2119
  (deprecated numbering scheme)