Ali said, "The Messenger of Allah ﷺ taught me words to say in the witr prayer, 'O Allah, guide me among those You have guided, grant me well-being among those You have granted well-being, take me as an ally among those You have taken as allies, bless me in what You have given, and protect me from the evil of what You have decreed. Indeed, You decree and none can decree against You. The one You support is never humiliated, and the one You oppose is never honored. Blessed are You, our Lord, and Exalted.'"
علمني رسول الله ﷺ كلمات أقولهن في الوتر: اللهم اهدني فيمن هديت، وعافني فيمن عافيت، وتولني فيمن توليت، وبارك لي فيما أعطيت، وقني شر ما قضيت، إنك تقضي ولا يقضى عليك، وإنه لا يذل من واليت، ولا يعز من عاديت، تباركت ربنا وتعاليت.
Abu Dawud (1425), Tirmidhi (464), Nasai (1745), and Ibn Majah (1178) narrated it, and Ibn Khuzayma (1095) graded it sahih, all of them through the route of Abu Ishaq, from Burayd bin Abu Maryam Saluli, from Abu Hawra, from Hasan bin Ali, who mentioned it. Its chain is sahih, and the discussion of it is set out at length in the Book of Prayer.As for what Nasai (1746) narrated of an addition at the end of the supplication, "And Allah's blessings be upon the Prophet Muhammad," through the route of Ibn Wahb, from Yahya bin Abdullah bin Salim, from Musa bin Uqba, from Abdullah bin Ali, from Hasan bin Ali, who said, "The Messenger of Allah ﷺ taught me these words..." then he mentioned the supplication and added at the end the invoking of blessings on the Prophet ﷺ, this contains a break in the chain, for Abdullah bin Ali, who is the son of Husayn bin Ali, never met Hasan bin Ali bin Abu Talib.As for invoking blessings on the Prophet ﷺ at the end of the qunut supplications in general, this has indeed been established in the leading of prayer by Ubayy bin Kaab, who used to lead the people in prayer during the time of Umar bin Khattab. After he would pray against the disbelievers and curse them, he would then invoke blessings on the Prophet ﷺ and pray for the Muslims with whatever good he could. Ibn Khuzayma (1100) narrated it.