According to what is in Imam an-Nawwawi’s ‘al-Adhkaar,’
this dua is related in a sahih hadith.
ابن السني عن عليّ رضي الله عنه
أن النبيّ صلى الله عليه و سلّم كان إذا نظر في المرآة قال: الحمدُ لله اللّهمّ كما حسّنْتَ خّلْفي فحسّنْ When the Prophet (Allah bless him and grant him peace) looked in the mirror, he said, “Praise be to Allah. Oh Allah, as you have beautified me, beautify my character.”
AlhamduLlilahi Allahumma kama hasanta khalqi fahassin khuluqi