Muhammad ﷺ said, "Does the one who raises his head before the imam not fear that Allah will turn his head into the head of a donkey?"
أخبرنا قتيبة قال حدثنا حماد عن محمد بن زياد
قال محمد ﷺ ألا يخشى الذي يرفع رأسه قبل الإمام أن يحول الله رأسه رأس حمار
Muslim narrated it in the Book of Prayer, chapter on the prohibition of preceding the imam in bowing, prostrating, or similar actions, hadith 427, from Qutayba, with this wording. It is also found in Al-Kubra, hadith 902. Bukhari narrated it, hadith 691, from the hadith of Muhammad bin Ziyad.