It is narrated from Abu Hurayrah (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "When the imam says 'Sami'allahu liman hamidah' (Allah has heard the one who praised Him), then say: 'Allahumma rabbana lakal-hamd' (O Allah, our Lord, to You belongs all praise); for whoever's words coincide with the words of the angels, all his past sins will be forgiven."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 2617