Then you'd have to find somewhere to live, and undertake the time/expense of suing. The best protection is probably a bit of a mutually assured destruction angle if the landlord is breaking the law through the irregular rental in the first place (in Santa Cruz many of the rentals are off the books because they aren't even legal rental units--DIY converted garages and attics and such).
Not sure how big that "informal rental" section of the economy is, though, so maybe this isn't a common situation. I'd guess it's highest in NYC.
One flat I shared the rental agency tried to withhold £150 for the changing of 1 (entirely ordinary) lightbulb, and cleaning a single drawer of a chest of drawers (a tiny amount of dirt under the drawer lining paper, and not apparent).
It's such a persistent theme that I tend to write off the deposit as part of the costs of moving, and consider it a good deal if I see 50% of it again.
I have never ever experienced a landlord trying to raise my rent mere days after I moved in, like they seem to do in this game.