The Messenger of Allah ﷺ said, "When the reciter says, 'Allah has heard the one who praises Him,' and those behind him say, 'O Allah, our Lord, to You belongs all praise,' and their words coincide with the words of the inhabitants of heaven, 'O Allah, our Lord, to You belongs all praise,' his past sins are forgiven."
وقال ﷺ إذا قال القارئ سمع الله لمن حمده فقال من خلفه اللهم ربنا ولك الحمد فوافق قوله ذلك قول أهل السماء اللهم ربنا لك الحمد غفر له ما تقدم من ذنبه
Its isnad is sahih, it passed at 7164, and it is found in Bukhari 1/201, Muslim 1/306 no. 409, Abu Dawud 848, Tirmidhi 247, Nasai 2/194, Ibn Majah 876, Ibn Abu Shayba 1/252, and Abdul-Razzaq 2909.