Praise be to Allah.
Seeking protection by means of the ruqyahs, du‘aa’s and adhkaar that are prescribed in Islam is the teaching and practice of the Prophet (blessings and peace of Allah be upon him). He (blessings and peace of Allah be upon him) often sought refuge with Allah “from vitiligo, insanity, leprosy and bad diseases.” Narrated by Abu Dawood (no. 1554)’ classed as saheeh by an-Nawawi in al-Adhkaar (483) and by al-Albaani in Saheeh Abi Dawood.
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) said:
“Bad diseases” includes that which is now known as cancer – we ask Allah to keep us safe and sound – for it is one of the worst diseases. The individual should be keen to learn such hadiths and to follow the example of the Prophet (blessings and peace of Allah be upon him) as described in these reports. End quote.
Sharh Riyaadh as-Saaliheen (6/40).
The Prophet (blessings and peace of Allah be upon him) used to offer du‘aa’ praying that epidemics be taken away from Madinah. That is quoted as evidence by scholar for the permissibility of praying that epidemics be taken away or warded off.
Al-Haafiz Ibn Hajar (may Allah have mercy on him) said:
Some people could not understand the du‘aa’ asking that epidemics be taken away, because they thought that this du‘aa’ implies taking away death, and as death is something that is decreed and inevitable, this du‘aa’ [in their view] is meaningless.
My response to that is that this does not contradict the concept of worshipping Allah through du‘aa’ [supplication], because it may be among the causes of one’s lifespan being extended or sickness being relieved. There are mutawaatir hadiths which speak of seeking refuge with Allah from insanity, leprosy, bad diseases, evil behaviour, whims and desires, and sickness. The one who objects to treating sickness by means of du‘aa’ must also object to treating sickness by means of medicines, but no one says that except some outliers who went against the majority, and the saheeh hadiths refute their view.
Turning to du‘aa’ brings another benefit that is not found in any other means of treating sickness, because it involves humbling oneself before the Lord, may He be glorified. In fact, not offering du‘aa’ is akin to refraining from doing righteous deeds and relying on what is decreed, which would imply that one should give up striving completely! Warding off calamity by means of du‘aa’ is like warding off arrows by means of a shield, and it is not one of the conditions of belief in the divine decree that one should not shield oneself from arrows.
End quote from Fath al-Baari (10/133).
With regard to the du‘aa’ mentioned in the question, we have not come across it in any of the books of Sunnah and reports. Rather something similar to it was narrated by some of the Maaliki fuqaha’ from Shaykh Ahmad Zarrooq, as mentioned in al-Fawaakih ad-Dawaani ‘ala Risaalat Ibn Abi Zayd al-Qayrawaani (2/266).
But as the words of this du‘aa’ are acceptable from an Islamic point of view, and there is nothing in it that is contrary to Islamic teachings – rather they are good words that reflect respect and veneration of Allah, may He be glorified and exalted – it is permissible to call upon Allah with these words, and to seek His protection by reciting these words, on condition that one does not believe that there is any special virtue and reward in these particular words, and on condition that one does not recite it regularly in such a way that it becomes like an act of worship that is regarded as equal to those specifically enjoined in the religious texts. If the one who wants to call upon Allah focuses on what is narrated in the Sunnah concerning such matters, and he memorizes those du‘aa’s and understands them, and turns to Allah is supplication using those du‘aa’s, that will be better for him and will bring him more barakah (blessing).
And Allah knows best.