Imagine China is the Titanic and local government debt of up to 40 trillion yuan (US$5.78 trillion) is a giant iceberg lurking in a sea of economic uncertainty.

Now, consider the effects of a collision.

A report released by one of the “Big Three” credit rating agencies, S&P Global, has painted this vivid picture of a looming financial disaster in the world’s second-largest economy.

“The extent of off-balance-sheet borrowing among local governments isn’t known, but could be as high as 40 trillion renminbi,” S&P Global Ratings stated in a report released on Tuesday. “That’s a debt iceberg with titanic credit risks.”

Most of the “hidden debt” is festering in local government financing vehicles, or LGFVs, which were set-up by state-owned companies to raise funds for massive infrastructure and development programs.

Usually, this sort of “off-balance-sheet borrowing” is done outside the normal channels of central government, which has alarmed Beijing as it battles to crack down on debt.

Last month, Liu Shijin, a member of the Monetary Policy Committee of the powerful People’s Bank of China, warned that excessive investment in infrastructure and property projects was not the long-term answer to China’s growth dilemma.

In the wake of a cooling economy, funding has accelerated again for major road and rail developments, as well as housing schemes.

“Although investment in building roads, railways and housing can play a role in preventing a precipitous decline in growth, its potential to drive economic expansion over the long run has waned,” Liu said, adding that this would only exacerbate China’s deleveraging problems.

His comments have not been lost on the State Council. The de facto cabinet of President Xi Jinping’s government has made tackling debt in the corporate and local government sectors a priority.

Naturally, this has included off-balance-sheet “hidden” risks, which have been accumulating for the best part of nearly two decades.

By the end of April, “the official” debt mountain had topped 16.61 trillion yuan, data from the Ministry of Finance showed. The S&P report puts the figure at more than double that.

“Local government officials never worry about repaying debts, they only worry that no one is lending them money,” Yin Zhongqing, the deputy director of the financial and economic affairs committee at the National People’s Congress, said earlier this year.

“Part of the reason was that all local governments are part of a centralized authority that will eventually be bailed out.”

Tighter regulations have been brought in during the past 12 months, but the addiction to debt remains, squeezing spending on health care, social security and welfare, as well as environmental issues.

At least, Beijing is on the right track, S&P pointed out, despite battling the fallout of the trade war with the United States and a sluggish economy.

“Defusing financial risks, including hidden local government debt, is one of three overarching priorities of the country’s top leadership,” the rating agency said.

As SS China steams toward a huge debt iceberg, changing course has become crucial in keeping local governments afloat.