Maybe the bears and cynics and general party-poopers are all wrong. Maybe the stock market these days isn’t a giant Ponzi scheme.

Maybe it’s a shell game.

The cheerleaders on the Street of Shame won’t tell you this, but lurking behind the phenomenon of today’s skyrocketing stock prices is a surge in corporate borrowing.

Companies have been borrowing money with both fists, and spend the money to buy back shares and in the process drive up their share prices.

But what the stock market giveth, the bond market taketh away.

Expect peak energy demand sooner than you think

Despite all the claims that U.S. companies are awash with cash and have “never had it so good,” an analysis by investment bank SG Securities calculates that in reality Corporate America has “overspent” in recent years to the tune of hundreds of billions of dollars.

Over the past five years, equity prices have almost doubled — but so has the net debt of nonfinancial companies. Both have outstripped a 60% rise in profits.

Or, to put it another way, since March 2009, the cash pile of non-financial U.S. corporations has risen by $570 billion, but debt has risen by $1.6 trillion.

Indeed over the past year net debt has risen about 20%,SG estimates — while gross cash flows have risen a more modest 4%.

Indeed, “it is also those companies with the weakest sales growth that are buying back the most,” warns SG quantitative strategist Andrew Lapthorne in a new report for clients.

And that’s not all.

The “net debt” figures for most of the stock market are even worse than many will tell you, for the simple reason that the overall figure is skewed by a handful of companies with big cash piles — such as Apple AAPL, -3.17% . When you remove those from the equation, the picture for the rest of the pack looks a lot worse.

Many of those cash piles are sitting offshore, untaxed or lightly taxed. Net of tax, the levels are lower.

And anyone who tries to give you comfort by pointing out that net debt levels aren’t too bad when compared to asset prices needs to offer a big caveat. Such ratios always look good during a boom, because asset prices get inflated.

If or when the tide turns, the asset prices can tumble — but the value of the debt, alas, sticks around at its previous level.

According to Federal Reserve data, non-financial corporate businesses owe 37% of the value of their net worth. That’s down from a peak of 45% in 2009. But that’s still higher than the 34% registered in 2007, at the peak of the last boom.

It’s no mystery why so many companies have been ramping up debt, either.

The money is virtually free. The Federal Reserve’s policy of zero percent interest rates has made savers so desperate for income that they’ve been willing to buy corporate bonds at pitifully low yields. The average yield on BAA-rated corporate bonds touched an all-time low of 4.29% in January, according to ratings agency Moody’s. (BAA is the lowest level of investment grade bond). In May, 2000, the yield approached 9%.

Corporate CEOs get paid these days for driving up stock prices. Their performance targets are often compared to the total returns on their company stock. Their biggest rewards come in the form of restricted stock units and options. So borrowing other people’s money for free and using it to drive up the stock price is a great deal for them.

Where does this leave the ordinary investor?

They say “the trend is your friend,” and maybe this game will just keep going for a long time. Anyone trying to call the next correction in the stock market is probably on a fool’s errand.

Yet it is a financial certainty that rising debt levels imply rising risks. The most interesting question is whether the bulk of that risk is being carried by stock investors or bond investors. Time will reveal all.