Sefer Chofetz Chaim chapter 8 halacha 7

If a person Is known to be a “bad guy” then you are allowed to speak lashon hara against him in order keep others away from him and not learn from his ways and hopefully he might repent as well if he sees so many people speaking out against him. Just be sure to say this lashon hara only for the sake of spreading the truth not to benefit, be it fame or fortune, when spreading this lashon hara, neither out if hatred for the guy.

What is considered a rasha status, a “bad guy” status? It is a person that habitually or many times committed a sin that everyone knows is wrong, like murder, adultery, or robbery, and even if it’s a minor sin, like a rabbinic prohibition, for example the gemara in Shabbos 40a discusses a case where the rabbis enacted that people cannot go into a sauna on Shabbos because people used to take hot baths on Shabbos from water heated up from before Shabbos and then it was discovered that bath house attendants use that the water on Shabbos so the rabbis forbade it then people use to make believe they went to saunas on Shabbos really going to the bathhouse so that became forbidden too. Rava said that whoever disobeys this enactment is a rasha and people could spread lashon hara about him. Because everyone knew about this enactment and people still disobeyed then lashon hara can be said against them to be sure no one else follows suit but a person who is in a habit of committing non-famous sins then know can say lashon hara about him because maybe he just doesn’t know any better. This person must be known throughout the city as a “bad guy” not just rumors and you can’t exaggerate more then what you know he does. Bottom line honesty and for the sake of truth is the key.

The Chofetz Chaim concludes that even though this halacha might create an excuse for those who constantly speak lashon hara to brand others wicked and have an excuse to spread more lashon hara but he still felt he must write down this halacha for the sake of the truth and he quoted a verse in Hoshea14:10 “For the ways of Hashem are straight and the righteous walk within them and the sinners stumble within them.”