Abdullah ibn Umar reported: The Messenger of Allah, peace and blessings be upon him, raised his head from the last bowing in dawn prayer, saying, “O Allah, curse this person, and this person, and this person,” after he had said, “Allah listens to those who praise him. Our Lord, for you is the praise.” Then, Allah revealed the verse, “You do not have any decision in the matter, whether He will forgive them or punish them. Verily, they are wrongdoers.” (3:128)
Source: Ṣaḥīḥ al-Bukhārī 4559
Grade: Sahih (authentic) according to Al-Bukhari
Al-Nawawi said, “Know that cursing a protected Muslim is forbidden by consensus of the Muslims. It is permissible to curse people with blameworthy characteristics (without naming them), such as saying: The curse of Allah is upon the wrongdoers… For to curse is to distance someone from the mercy of Allah Almighty, and we do not know what was the fate of this sinner, or this unbeliever.”
Source: al-Adhkār lil-Nawawī 1/560
عَنْ ابْنِ عُمَرَ قَالَ قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ إِذَا رَفَعَ رَأْسَهُ مِنْ الرُّكُوعِ فِي الرَّكْعَةِ الْآخِرَةِ مِنْ الْفَجْرِ اللَّهُمَّ الْعَنْ فُلَانًا وَفُلَانًا وَفُلَانًا بَعْدَ مَا قَالَ سَمِعَ اللَّهُ لِمَنْ حَمِدَهُ رَبَّنَا وَلَكَ الْحَمْدُ فَأَنْزَلَ اللَّهُ لَيْسَ لَكَ مِنْ الْأَمْرِ شَيْءٌ إِلَى قَوْلِهِ فَإِنَّهُمْ ظَالِمُونَ
4559 صحيح البخاري كتاب تفسير القرآن سورة آل عمران باب ليس لك من الأمر شيء
قال النووي اعلم أن لعن المسلم المصونِ حرامٌ بإجماع المسلمين ويجوزُ لعنُ أصحابِ الأوصافِ المذمومةِ كقولك لعن الله الظالمين … لأن اللعن هو الإبعادُ عن رحمةِ الله تعالى وما ندري ما يختم به لهذا الفاسقِ أو الكافر
1/560 الأذكار للنووي