كتاب البر والصلة والآداب
45
The Book of Virtue, Enjoining Good Manners, and Joining of the Ties of Kinship
(14)
Chapter: The Reward Of The Believer For Whatever Befalls Him Of Sickness, Grief And The Like, Even A Thorn That Pricks Him
(14)
باب ثَوَابِ الْمُؤْمِنِ فِيمَا يُصِيبُهُ مِنْ مَرَضٍ أَوْ حُزْنٍ أَوْ نَحْوِ ذَلِكَ حَتَّى الشَّوْكَةِ يُش

'A'isha reported:

I heard Allah's Messenger (ﷺ) as saying: There is nothing (in the form of trouble) that comes to a believer even if it is the pricking of a thorn that there is decreed for him by Allah good or his sins are obliterated.
حَدَّثَنِي حَرْمَلَةُ بْنُ يَحْيَى، أَخْبَرَنَا عَبْدُ اللَّهِ بْنُ وَهْبٍ، أَخْبَرَنَا حَيْوَةُ، حَدَّثَنَا ابْنُ الْهَادِ، عَنْ أَبِي بَكْرِ بْنِ حَزْمٍ، عَنْ عَمْرَةَ، عَنْ عَائِشَةَ، قَالَتْ سَمِعْتُ رَسُولَ اللَّهِ صلى الله عليه وسلم يَقُولُ ‏ "‏ مَا مِنْ شَىْءٍ يُصِيبُ الْمُؤْمِنَ حَتَّى الشَّوْكَةِ تُصِيبُهُ إِلاَّ كَتَبَ اللَّهُ لَهُ بِهَا حَسَنَةً أَوْ حُطَّتْ عَنْهُ بِهَا خَطِيئَةٌ ‏"‏ ‏.‏
Reference : Sahih Muslim 2572 g
In-book reference : Book 45, Hadith 65
USC-MSA web (English) reference : Book 32, Hadith 6241
  (deprecated numbering scheme)