Muwatta Malik, Book 3, Hadith 50 (USC-MSA)

Yahya related to me from Malik from Sumayy, the mawla of Abu Bakr, from Abu Salih as-Samman from Abu Hurayra that the Messenger of Allah, may Allah bless him and grant him peace, said, "When the imam says, 'Allah hears whoever praises Him,' say 'O Allah! Our Lord, praise be toYou, 'for the previous wrong actions done by the one whose utterance coincides with that of the angels are forgiven."

وَحَدَّثَنِي عَنْ مَالِكٍ، عَنْ سُمَىٍّ، مَوْلَى أَبِي بَكْرٍ عَنْ أَبِي صَالِحٍ السَّمَّانِ، عَنْ أَبِي هُرَيْرَةَ، أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم قَالَ ‏ "‏ إِذَا قَالَ الإِمَامُ سَمِعَ اللَّهُ لِمَنْ حَمِدَهُ فَقُولُوا اللَّهُمَّ رَبَّنَا لَكَ الْحَمْدُ فَإِنَّهُ مَنْ وَافَقَ قَوْلُهُ قَوْلَ الْمَلاَئِكَةِ غُفِرَ لَهُ مَا تَقَدَّمَ مِنْ ذَنْبِهِ ‏" ‏ ‏.‏

sunnah.com

also referenced under: Book 3, Hadith 197 (In-Book)