Sunan Ibn Majah
It was narrated from Anas bin Malik that the Messenger of Allah (ﷺ) said: “When the Imam says: ‘Sami’ Allahu liman hamidah (Allah hears those who praise Him),’ say: ‘Rabbana wa lakal-hamd (O our Lord, to You is the praise).’”
حَدَّثَنَا هِشَامُ بْنُ عَمَّارٍ، حَدَّثَنَا سُفْيَانُ، عَنِ الزُّهْرِيِّ، عَنْ أَنَسِ بْنِ مَالِكٍ، . أَنَّ رَسُولَ اللَّهِ ـ صلى الله عليه وسلم ـ قَالَ " إِذَا قَالَ الإِمَامُ سَمِعَ اللَّهُ لِمَنْ حَمِدَهُ . فَقُولُوا رَبَّنَا وَلَكَ الْحَمْدُ " .
Grade: Sahih (Darussalam)
Reference