We were with the Prophet ﷺ in a gathering when he said, "Pledge allegiance to me that you will not associate anything with Allah, that you will not steal, and that you will not commit fornication." He recited the verse to them."Whoever among you fulfills this pledge, his reward is with Allah. Whoever commits any of these offenses and is punished for it, that punishment is an expiation for him. And whoever commits any of these offenses but Allah conceals it for him, his affair rests with Allah. If He wills, He will punish him, and if He wills, He will forgive him."
حدثنا قتيبة حدثنا سفيان بن عيينة عن الزهري عن أبي إدريس الخولاني
كنا عند النبي ﷺ في مجلس فقال تبايعوني على أن لا تشركوا بالله شيئا ولا تسرقوا ولا تزنوا قرأ عليهم الآية فمن وفى منكم فأجره على الله ومن أصاب من ذلك شيئا فعوقب عليه فهو كفارة له ومن أصاب من ذلك شيئا فستره الله عليه فهو إلى الله إن شاء عذبه وإن شاء غفر له
Agreed upon [by Bukhari and Muslim]. Bukhari narrated it in the Tafsir, chapter "When believing women come to you pledging allegiance," no. 4894, and Muslim, no. 1709, from the hadith of Sufyan bin Uyayna with this same wording.There is also a narration on this topic from Ali [to come: 2626], Jareer bin Abdullah [I did not find it], and Khuzayma bin Thabit [Ahmad: 5/214, 215].