Hadithcore
Mishkat al-Masabih, 3628

Khuzaima b. Thabit reported God's Messenger as saying, “If anyone commits a sin and has inflicted on him the prescribed punishment for that sin, it is an atonement for him.” It is transmitted in <i>Sharh as-sunna</i>.

وَعَنْ خُزَيْمَةَ بْنِ ثَابِتٍ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «مَنْ أَصَابَ ذَنْبًا أُقِيمَ عَلَيْهِ حَدُّ ذَلِكَ الذَّنْبِ فَهُوَ كفارتُه» رَوَاهُ فِي شرح السّنة

References1 variant
In-Book Reference
Book 17, Hadith 65