The Messenger of Allah ﷺ said, "Whoever fasts Ramadan out of faith and seeking reward will have his past sins forgiven."
أخبرنا علي بن المنذر قال حدثنا ابن فضيل قال حدثنا يحيى بن سعيد عن أبي سلمة
رسول الله ﷺ من صام رمضان إيمانا واحتسابا غفر له ما تقدم من ذنبه
Bukhari narrated it in the Book of Faith, chapter on fasting Ramadan out of sincere faith, hadith no. 38, from the hadith of Muhammad bin Fudayl bin Ghazwan through the same chain, and it is also found in Kubra, hadith no. 2515.