The "prolonged environment of low growth and low interest rates has been a catalyst for striking changes in nonfinancial corporate credit quality," Mariarosa Verde, Moody's senior credit officer, said in a report. "The record number of highly leveraged companies has set the stage for a particularly large wave of defaults when the next period of broad economic stress eventually arrives."

The ratings agency said low interest rates and investor appetite for yield has pushed companies into issuing mounds of debt that offer comparatively low levels of protection for investors. While the near-term outlook for credit is "benign," that won't be the case when economic conditions worsen.

With corporate debt hitting its highest levels since before the financial crisis, Moody's is warning that substantial trouble is ahead for junk bonds when the next downturn hits.

Though the current default rate is just 3 percent for speculative-grade credit, that has been predicated on favorable conditions that may not last.

Since 2009, the level of global nonfinancial companies rated as speculative, or junk, has surged by 58 percent, to the highest ever, with 40 percent rated B1 or lower, the point that Moody's considers "highly speculative," as opposed to "non-investment grade speculative."

In dollar terms, that translates to $3.7 trillion in total junk debt outstanding, $2 trillion of which is in the B1 or lower category.

"Strong investor demand for higher yields continues to allow all but the weakest issuers to

avoid default by refinancing maturing debt," Verde wrote. "A number of very weak issuers are living on borrowed time while benign conditions last."

The level of speculative-grade issuance peaked in the U.S. in 2013, at $334.5 billion, according to the Securities Industry and Financial Markets Association. American companies have $8.8 trillion in total outstanding debt, a 49 percent increase since the Great Recession ended in 2009.

During that time, there's been a strong divergence in debt issuance, with investment-grade firms (shown below in the green line) pulling back as a share of total debt issuance, while speculative grade debt (the blue line) has increased.

The rise of junk

Credit conditions have been conducive to lower-rated companies going to market, as global central banks have kept rates low and helped keep liquidity flowing through the system.

That's had some positive impacts, as smaller firms with greater access to capital have been able to implement game-changing technologies into multiple industries, particularly energy.

At the same time, higher-rated companies have been issuing debt and using it to reward shareholders with buybacks and dividends. As a result, their debt, while still investment grade, often has fallen a few notches, with the very top of the ladder shrinking from 21 percent pre-crisis to 14 percent currently.

Moody's warned that the trend could result in more "fallen angels," or companies that see their pristine ratings dinged as they continue to roll up debt.

Overall, median debt when compared with EBITDA has risen 30 percent for investment-grade companies and 10 percent for speculative.

"For many speculative-grade issuers, debt capacity may have reached its limit but structural protections continue to weaken," Verde said. "Many of these highly leveraged borrowers have

more latitude than at any other time in the past to engage in potentially credit-eroding activities such as asset sales or debt-accretive transactions without needing to get lender consent."

Lower-rated companies have managed to keep their defaults below the historical average even though their credit metrics are "deeply stretched," Verde added.

"This extended period of benign credit conditions has helped many weak, highly leveraged companies to avoid default," she wrote. "These companies are poised to default when credit conditions eventually become more difficult."