No one is immune.
● Even the greatest Gedolim have struggled with such thoughts and temptations. Kiddushin 81a-81b regarding R’ Amram Chasida, R’ Meir, and R’ Chiya bar Ashi. Rashi Sanhedrin 31b about Mar Ukvah. Bava Metzia 85a regarding the son of R’ Elazar ben R’ Shimon.
● Rabbi Yaakov Emden related in Megilas Sefer how he was personally tempted, and barely withstood the test.
● Maamorei Shlomo Ch. 16: The Taz wrote that a person does not have free will with regard to thoughts that enter his mind. Therefore, Chazal teach us that immoral thoughts are one of three things, that, on a regular basis, a person is not saved from.
● Chiddushei Halev Naso 5:18. A person can feel opposite feelings at the same time: both a feeling of repulsion, and also a feeling of strong attraction. That is because a human is comprised of both an earthly body and and G-dly soul. Therefore, he should not feel distraught if improper thoughts suddenly come to his mind, as such may happen even to a tzaddik and chassid.