This is the received wisdom, but not sure it happens. It might be something that happens at high levels, but it's uncommon for most people to even get a rejection letter or email in the first place, this notion of companies badmouthing you then them telling you that's why you were not hired is just... weird.
Someone would have to call/email your former company, they'd have to put something in writing (or recording) that specifically was negative about you, the company you are applying to would then need to keep a record of that, and then tell you why you weren't hired was because of that negative information.
Has that ever happened to anyone?
It feels to me like the 'lawsuits!' excuse is mostly a smokescreen to cover people being lazy, rude or incompetent at their job of actually managing a hiring process.
You're applying at a bunch of places, some of them being internal referrals from friends of yours. After a while you notice that all of your job applications are fizzling out, so, frustrated, you start asking for feedback (especially since a friend of yours kept getting rejected for talking about SOA instead of RESTful APIs).
The answers you get aren't helpful, like "we just felt that you weren't a good fit", and in a couple of cases somewhat antagonistic.
Eventually, you hear through the grapevine that you might want to check the references you're using.
So, you get your Significant Other to pose as an employer checking your employment history and references, while they record the calls with an app.
Guess what? One of your references is actually trashing you, saying you were unreliable and a troublemaker. It also turns out that another reference just blows everyone off and never returns calls.
Ta-da! You have a recorded evidence. BIG PROBLEM for the reference that bad-mouthed you.
Confronting them on the phone is probably a worse idea, though.
Realistically, though, if you're job hunting, filing lawsuits might not be the best use of time.
Most professionals I know are happy to "bend" policy to give a respected colleague or personal friend a good reference, especially if that person is on the street.
If the company clams up and limits its response to name, rank and serial number, that's a huge red flag.
It's really frustrating to try to look for a job when your potential employer really has a limited way of checking your references.
You are correct. It's not just "if they're smart" it's "if they're complying with the law." Former employers are only legally allowed to confirm employment, salary (yes, really), and whether or not you're eligible for rehire.
Do you mean they're opening themselves up to a lawsuit by saying anything else? If so, that's different than being illegal.