كتاب الصلاة
4  
The Book of Prayers
(48)
Chapter: Preventing One Who Wants To Pass In Front Of A Praying Person
(48)
باب مَنْعِ الْمَارِّ بَيْنَ يَدَىِ الْمُصَلِّي ‏
Sahih Muslim 507 a

Busr b Sa'id reported that Zaid b Khalid al-Juhani sent him to Abu Juhaim in order to ask him what he had heard from the Messenger of Allah (ﷺ) with regard to the passer in front of the worshipper. Abu Juhaim reported that the Messenger of Allah (ﷺ) said:

If anyone who passes in front of a man who is praying knew the responsibility he incurs, he would stand still forty (years) rather than to pass in front of him Abu Nadr said: I do not know whether he said forty days or months or years.
حَدَّثَنَا يَحْيَى بْنُ يَحْيَى، قَالَ قَرَأْتُ عَلَى مَالِكٍ عَنْ أَبِي النَّضْرِ، عَنْ بُسْرِ بْنِ سَعِيدٍ، أَنَّ زَيْدَ بْنَ خَالِدٍ الْجُهَنِيَّ، أَرْسَلَهُ إِلَى أَبِي جُهَيْمٍ يَسْأَلُهُ مَاذَا سَمِعَ مِنْ، رَسُولِ اللَّهِ صلى الله عليه وسلم فِي الْمَارِّ بَيْنَ يَدَىِ الْمُصَلِّي قَالَ أَبُو جُهَيْمٍ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏ "‏ لَوْ يَعْلَمُ الْمَارُّ بَيْنَ يَدَىِ الْمُصَلِّي مَاذَا عَلَيْهِ لَكَانَ أَنْ يَقِفَ أَرْبَعِينَ خَيْرًا لَهُ مِنْ أَنْ يَمُرَّ بَيْنَ يَدَيْهِ ‏"‏ ‏.‏ قَالَ أَبُو النَّضْرِ لاَ أَدْرِي قَالَ أَرْبَعِينَ يَوْمًا أَوْ شَهْرًا أَوْ سَنَةً
Reference : Sahih Muslim 507a
In-book reference : Book 4, Hadith 294
USC-MSA web (English) reference : Book 4, Hadith 1027
  (deprecated numbering scheme)