The dam of pent-up sexual harassment claims has burst.  But what kept those claims pent up in the first place?

There were lots of reasons. The abusers were powerful figures who could make or break a victim's career. The victims were embarrassed and mistakenly blamed themselves. Victims feared that going public would trigger a public relations battle that the wealthy, influential abusers were certain to win.

But in many instances, the abusers also purchased their victims' silence. In exchange for a financial settlement, the victims agreed not to disclose what happened. That was the modus operandi of Harvey Weinstein, Bill Cosby, and Bill O'Reilly.

These abusers are not alone in using contractual nondisclosure agreements to hide malfeasance. Manufacturers sued for selling dangerously defective products similarly insist upon secret settlements, as General Motors did with its faulty ignition switches. Many employers also include nondisclosure provisions in their employment contracts as well as nondisparagement clauses, which prohibit employees from disparaging the employers both during and after the term of employment.

To get a sense of how expansive these promises of silence can be, consider a contract signed by a Trump campaign adviser that was obtained by BuzzFeed. The nondisclosure provision covers all information "of a private, proprietary, or confidential nature or that Mr. Trump insists remain private or confidential." The nondisparagement provision forbids the employee to "demean or disparage publicly" Trump, any Trump company, or "any member of Mr. Trump's family." Both provisions apply during the employee's service and "at all times thereafter."

Had Trump been challenged about these provisions, he probably would have said that he was merely doing what the law allowed. But should the law allow these provisions to be enforced?

Certainly, nondisclosure agreements are often legitimate. Companies need to ensure that employees do not disclose trade secrets. Insurers and banks don't want employees revealing customers' private medical or financial information. And publicly traded companies must keep inside information from being leaked to stock traders.

But neither companies nor individuals have a legitimate interest in keeping their malfeasance secret, whether it's about dangerously defective products, predatory sexual behavior, or anything else. Hiding malfeasance only paves the way for more wrongdoing to more unsuspecting victims. Just ask Weinstein's victims.

Is the law capable of separating the wheat of legitimate nondisclosure provisions from the chaff of illegitimate ones? Absolutely.

From time immemorial, judges have refused to enforce contracts that violate public policy. Contracts are unenforceable whenever the public policy against enforcement clearly outweighs the public policy favoring enforcement. And the relevant policy can be anything that advances the public welfare.

Judges have long used this doctrine to invalidate contract provisions that interfere with economic markets. For example, judges routinely examine employment contracts to ensure that they do not unfairly restrain an employee's ability to compete with a former employer.  Reasonable restraints — such as those preventing the use of a former employer's trade secret — are enforceable.  Unreasonable restraints — such as those preventing employees from using general knowledge or skill to work for a competitor — are not.

If judges can police contracts to ensure robust economic markets, they can also police contracts to ensure a robust marketplace of ideas. The most obvious candidates for unenforceability are promises to conceal criminal or tortious behavior. But even promises to conceal merely embarrassing information might be unenforceable if there is a legitimate public interest in disclosure. For example, a former employee of a candidate for public office should be able to disclose that the candidate exaggerated his academic credentials.

Would an abuser like Weinstein continue to offer compensation to his victims if they would not promise to keep his actions secret? Most likely. He still needs the victims to release him from any liability for physically assaulting them.

But suppose the women wanted the information concealed for their own privacy? Then they shouldn't disclose it. Weinstein is certainly not going to publicize it.

The public policy exception empowers judges not to enforce illegitimate nondisclosure or nondisparagement clauses. But there is enough uncertainty about these clauses' enforceability to make people justifiably afraid to breach them. No one wants to risk potential liability or the exorbitant cost of defending a lawsuit.

Legislators should reduce this murkiness by enacting laws with explicit provisions about which types of clauses are unenforceable and providing sanctions for including obviously illegitimate clauses in contracts. Judges should simultaneously develop robust common law rules for policing contracts of silence, just as they have for contracts restraining trade.

Justice Louis Brandeis famously proclaimed that sunlight is the best disinfectant. Let us end the practice of using contracts to block the light.

Alan Garfield is a professor at Widener University Delaware Law School and the author of "Promises of Silence: Contract Law and Freedom of Speech" in the Cornell Law Review.