A secretive super-court system called ISDS is threatening to blow up President Barack Obama’s highest foreign policy priority.

Investor-state dispute settlement — an integral part of the Trans-Pacific Partnership trade deal — allows companies to sue entire countries for costing them money when laws or regulations change. Cases are decided by extrajudicial tribunals composed of three corporate lawyers. Buzzfeed, in a multi-part investigation launched Sunday, called it “the court that rules the world.”

Although the ISDS process has existed for years, TPP would drastically expand it. The most common criticisms of the system are that it’s secret, that it’s dominated by unaccountable big-firm lawyers, and that global corporations use it to change sovereign laws and undermine regulations. That’s all true.

But here’s what most of the coverage and the critics are missing.

The ISDS system ― which is now written into over 3,000 international trade treaties, including NAFTA ― was designed to solve a specific problem. When corporations invest abroad, they fear that their factories might be nationalized or their products expropriated by governments that also control the local courts. ISDS is meant to give companies confidence that if a country seizes their accounts or factories, they’ll have a fair, neutral place to appeal.

But instead of helping companies resolve legitimate disputes over seized assets, ISDS has increasingly become a way for rich investors to make money by speculating on lawsuits, winning huge awards and forcing taxpayers to foot the bill.

Here’s how it works: Wealthy financiers with idle cash have purchased companies that are well placed to bring an ISDS claim, seemingly for the sole purpose of using that claim to make a buck. Sometimes, they set up shell corporations to create the plaintiffs to bring ISDS cases. And some hedge funds and private equity firms bankroll ISDS cases as third parties — just like billionaire Peter Thiel bankrolled Hulk Hogan in his lawsuit against Gawker Media.

It’s the same playbook that hedge funds were following when they bought up Argentine, Puerto Rican and other U.S. housing debt for pennies on the dollar. As The Huffington Post reported in May, the financiers were betting they could use lawsuits and lobbying to influence the political system in favor of the creditors like them and reap huge rewards.

Indeed, the damage of ISDS goes far beyond the money that investors manage to extract from public coffers and extends to the corruption of a political system by investors who buy off scholars, economists and politicians in pursuit of whatever policy outcome leads to a payoff. And there’s nothing stopping plutocrats with agendas that go beyond profit-making from getting involved ― again the way Thiel did with Gawker. That alone changes the power dynamic: If you’re the government of Thailand, the billionaire you’re negotiating with has one extra threat at his disposal.

If these investors are able to cement ISDS as part of the Trans-Pacific Partnership, the opportunities for hedge funds to do what they’ve already done to Argentina will be endless ― possibly even in cities and states under financial pressure in the U.S., like Detroit and Illinois.

So-called third-party funding of “international arbitration against foreign sovereigns” has been expanding quickly, according to Selvyn Seidel, a pioneer in the litigation finance industry and now CEO of the advisory firm Fulbrook Capital Management.

“You can get an award for billions of dollars when that award would never come out in domestic law,” said Gus van Harten, a professor at Osgoode Hall Law School at York University in Toronto. “It’s just a jackpot for speculators.”

Andrea Comas/Reuters Protesters march against government austerity measures in Madrid last year.

Here’s an example. In 2008, the Spanish government, under pressure from the eurozone to cut its budget during the financial crisis, began to reverse generous subsidies for solar energy. Spain reduced support for solar in stages. It changed the definition of its main solar incentive program in 2008, reduced the subsidies through two measures in 2010, placed a moratorium on subsidies for new solar plants in 2011, and added further restrictions in 2013.

Renewable energy activists could only shout into the air. But a group of investors hatched a plan.

Between November 2011 and December 2013, 22 different companies sued Spain in seven different cases over the subsidy changes – not in Spanish courts, but using ISDS.

RREEF, an investment fund subsidiary of Germany’s Deutsche Bank, and Antin, a private equity firm owned by French bank BNP Paribas, purchased their Spanish solar-thermal power plants in 2011, three years after the country began to roll back subsidies. But when they went to ISDS, they claimed they had expected subsidies to continue — not to continue declining.

“It feels like they acquired [the solar plants] in order to sue,” said Lora Verheecke, a campaigner for Corporate Europe Observatory, a Brussels-based research organization. Those two cases are still pending; a tribunal order allowed the RREEF case to advance in June.

The facts suggest that these investment funds made their purchases based not on the potential success or failure of the business they bought, not out of a concern for climate change and its consequences, but with the expectation that the Spanish government would continue its subsidy rollback, allowing the funds to sue in a special court unavailable to Spanish citizens. (To be fair, HuffPost can’t prove this to a certainty.) ISDS represented the purpose of the investment ― or, to phrase another way, the use of ISDS was an asset-building strategy. Spain’s renewable energy subsidies have not been restored. Instead, a cash-strapped government is being forced to spend scarce resources defending a decision that was forced upon it.

Spain isn’t the only government defending these sorts of ISDS claims. Poštová Banka of the Czech Republic bought sovereign debt from Greece in early 2010, well after rating agencies had downgraded the nation’s bonds. Two years later, after European leaders forced a restructuring of all Greek government bonds, Poštová and its shareholder, Istrokapital of Cyprus, filed an ISDS claim, contending that the restructuring cost them millions.

Maybe Poštová bought the distressed bonds knowing that it could use arbitration as a fallback. Or maybe it bought the bonds with the intent to sue and gain a favorable return on its money through ISDS.

In several other cases, investors appeared to opportunistically purchase a company that had the ability to file an ISDS claim at exactly the right time.

In 2004, through one of its investment funds, the French bank Société Générale purchased a 50 percent stake in a public-private partnership to distribute electricity in the Dominican Republic. The purchase included intermediary companies from California, Delaware, Nevada and the Cayman Islands, and the corporate structure is nearly impossible to ascertain. Because of the complex structure, the listed purchase price was only $2 U.S. (SocGen explained to arbitrators that it also arranged a “deferred purchase fee”). And the heart of the dispute ― the Dominican Republic’s alleged failure to pay negotiated compensation ― occurred years before SocGen made its purchase, according to the country, which argued SocGen was merely “buying a claim.”

Nonetheless, an ISDS tribunal ruled that “the principal objective of the transaction was the potential profitability of the investment.” It found that the Dominican Republic’s violations were ongoing and, through a settlement, awarded SocGen $26.5 million.

You can actually ask for enormous amounts of money without anybody criticizing you. Lora Verheecke of Corporate Europe Observatory

Since Greek and Roman times, the wealthy have placed bets on the outcomes of court cases. Under English common law, financing someone else’s lawsuit, known as champerty, was illegal. But the modern version of that, litigation finance ― which began in Australia in the 1960s ― has spread widely over the past two decades. Investors seeking higher returns on their savings have looked to courtrooms instead of stocks or bonds, agreeing to bankroll cases and taking a portion of the cash awards if they win.

Third-party funding shields corporations from the upfront costs of litigation, making it easier to sue. Since companies generally don’t have to disclose that they’ve received third-party funding for an ISDS case, and since international arbitration usually proceeds in comparative secrecy, pursuing a claim through ISDS can shield companies from the public criticism that accompanies challenging a law in regular courts. “You can actually ask for enormous amounts of money without anybody criticizing you,” said Verheecke of Corporate Europe Observatory.

With ISDS permitted under some 3,000 treaties, there are a huge number of opportunities to sue. And “unlike some other legal systems, the default remedy is a cash payment,” said Todd Tucker, a fellow at the Roosevelt Institute with a decade of experience researching trade and investment policy. The awards are also uncapped, meaning they can be enormous. If a corporation sought damages on future profits in perpetuity and the arbitrators agreed, the sovereign would have no recourse. Dozens of cases have resulted in awards of over $100 million, according to a 2016 report from van Harten, the law professor.

Those possibilities have the ISDS claim-financing industry booming. Hedge funds, private equity firms and institutional investors are flocking to fund lawsuits as they would any other speculative asset, according to experts in the field. And the lack of transparency means that lawyers acting as arbitrators or advocates in one case could be unnamed investors in other cases, and nobody would ever know.

Defenders of ISDS argue that the outcome of any case is uncertain and that companies win only about one-quarter of the time. But that’s only the cases that have been publicly identified and it doesn’t include settlements, where the corporation can also extract a monetary award. If funding ISDS suits was really such a bad bet, the industry probably wouldn’t be expanding so quickly.

Fulbrook Capital Management’s primer on the litigation finance industry, updated this year, includes a section entitled “International, the name of the game.” It lists numerous big-city hubs for arbitration: London, New York, Paris, Toronto. About ISDS in particular, the primer reads, “Investment claims against Sovereigns are often subject to Treaty and, within the Treaty, subject to arbitration. This promotes investments. … While investors are known to shy away from financing claims in ‘third world’ courts, particularly claims against the host court’s sovereign, they view international arbitration in a far more favorable light.”

Between 2009 and 2015, rulings in 16 ISDS cases have noted the existence of third-party funding, according to a report from Jean-Christophe Honlet, a partner at the global law firm Dentons. But the scale of third-party funding for ISDS cases is probably significantly larger than that number suggests. The International Council for Commercial Arbitration suggests that at least 60 percent of ISDS cases “enquired about (but not necessarily sought or obtained) third-party funding before their cases were lodged.” Just this month, Canadian gold mining company Rusoro won a $1.2 billion claim against Venezuela that was “third-party funded,” according to Global Arbitration Review.

Burford Capital, Bentham IMF and Gerchen Keller are among the biggest litigation finance firms, working closely with these investors and specialized law firms to pursue commercial claims. Burford has publicly stated that it has tested ISDS cases. While its chief marketing officer, Liz Bigham, would not reveal statistics on how many cases have been funded, she said via email, “Burford is a pioneer in the provision of arbitration finance and has been active in the field for well over a decade.” She added that “commercial claimants involved in international disputes — as well as the law firms that serve them — see the tremendous benefits of shifting the significant cost and risk of pursuing claims off their own balance sheets.”

British law firm Freshfields is an adviser to Burford, and they have worked together on arbitration claims. Vannin Capital, another litigation funder, recently hired two Freshfields lawyers. The powerhouse law firm is one of the top three for ISDS cases, according to Corporate Europe Observatory.

The financing firms provide clients with a full litigation package at the outset, complete with what treaties to exploit and which law firms to hire. They even recommend arbitrators.

“Loads of law firms actually send alerts to clients,” said Verheecke. The alerts say “this country has just done this. It’s a good opportunity to sue.”

Marcos Brindicci/Reuters Demonstrators huddle against the cold during a protest over electricity and gas prices in Buenos Aires this year.

Often, the best country for international investors to sue is one that’s already in trouble. When a country uses emergency economic measures to protect its citizens, investors can argue that those measures conflict with an existing trade treaty. The subsequent flood of lawsuits can further hurt the country’s credit ratings and raise the cost of capital, while undermining its ability to attract future investment.

No country has been sued more in ISDS tribunals than Argentina. Of the 696 ISDS cases in the United Nations Conference on Trade and Development (UNCTAD) database, at least 59 were brought against that one country. Since late 2001 and early 2002, when it defaulted on international debt and unpegged its currency from the U.S. dollar, Argentina has been forced to pay out $980 million in ISDS awards, in addition to the millions it spent to defend itself in arbitration.

Currently, some 60,000 bondholders are using ISDS to seek higher payouts on the value of Argentine debt. They claim they’re due $1 billion in lost profits because of the damaging effect of Argentine government policies.

Although bondholders are not traditional investors ― in the sense that they don’t actually build factories or sell services in a host country, they too have repeatedly used arbitration to get the highest returns on their debt purchases. UNCTAD has warned that if those holding bonds that have lost value can access the ISDS back door to sue countries for monetary damages, then no country could ever escape its debt.

You’re usually talking about very rich investors. ... There’s no reason why it should be the taxpayer [who] pays. Lora Verheecke

Once a venue of last resort for corporations wronged in a foreign jurisdiction, ISDS is now a playground where investors with no connection to the initial investment can get rich. Even the arbitrators seem to be growing queasy at the prospect of investors using ISDS like a casino parlor. In a 2015 case against Turkmenistan, arbitrators ordered Muhammet Cap to disclose whether it had received third-party funding to bring the case and what the terms of any such funding were.

Giving financiers the ability to extract taxpayer dollars from around the globe transfers wealth upwards. It’s another way the rich get richer by accessing tools unavailable to most citizens. That has massive follow-on effects for economic and political power worldwide, including right here in the U.S.

Now, upcoming trade agreements would dramatically expand this system. Public Citizen estimates that 9,000 new companies would gain ISDS rights to sue the United States under TPP alone. That’s 9,000 new opportunities for financiers to reach down into state and local coffers, in addition to the federal government, to grab cash. TPP would also expand the “minimum standard of treatment” clause, which sets up the most flexible type of ISDS claim, to cover financial services companies, meaning almost any change in the expected future profits of a bank could be challenged. “TPP was a win for the banks on ISDS,” said van Harten, the law professor.

It doesn’t have to be this way. Investors could be forced to prove discrimination in national courts first before proceeding to arbitration. Or national courts could exercise judicial review over ISDS awards. The largest ISDS award in history, $50 billion to a web of companies all owned by Russian oil magnate Mikhail Khodorovsky, was actually set aside by a Dutch court in April, the first time that has happened in a treaty-based ISDS case. Arbitrators — who generally come from a very small group of international corporate lawyers — could be made independent of the process, with set salaries, security of tenure and no financial ties to litigants. The definition of investor could be tightened, giving only companies that contribute to economic development the right to access ISDS.

But the easiest way to fix ISDS is to throw it out. Several countries, including India, Indonesia and Ecuador, have told their trade partners they’re considering terminating bilateral treaties because of ISDS. Some experts question whether the system is necessary even in the situations it was originally designed for.

“You’re usually talking about very rich investors that have the power to purchase insurance against these kind of political risks,” said Verheecke. “There’s no reason why it should be the taxpayer [who] pays.”