'Detroit' is seen on the top of an iron man-hole cover on a street in Detroit, Michigan July 27, 2013. REBECCA COOK / Reuters

Detroit, you're not alone.

Across the nation, cities and states are watching Detroit's largest-ever municipal bankruptcy filing with fear. Years of underfunded retirement promises to public sector workers, which helped lay Detroit low, could plunge them into a similar financial hole.

A CNBC.com analysis of more than 120 of the nation's largest state and local pension plans finds they face a wide range of financial burdens as aging work forces near retirement.

Thanks to a patchwork of accounting practices and rosy investment assumptions, it's not even clear just how big a financial hole many states and cities have dug for themselves. That may soon change, thanks to a new set of government accounting standards that could serve as a nasty wake-up call to states and cities relying on rosy scenarios and head-in-the-sand accounting.

Even less clear is who will pay to clean up the messes. Will it be the millions of retirees owed trillions of dollars in benefits, the bondholders who lent states and cities trillions more, or local taxpayers who may have to pay more to cover the shortfalls or see deeper cuts in public services?

Regardless, the painful process will likely play out for years.

"Moving pension plans is like steering a blimp: you turn the wheel and you go six miles before it starts to turn," said John Tuohy, Arlington County, Va., deputy treasurer, who chairs the pension committee of the Government Finance Officers Association. "In the political process, that kind of patience is very difficult."

Many state and local governments have set aside enough money to comfortably make good on promised retirement benefits. Seventeen states have funded more than 80 percent of their projected pension liability, a level that's generally seen as financially sound. Most of the rest have been scrambling to make up investment losses inflicted by the 2008 market collapse and the shortfalls in sales, property and incomes taxes produced by the Great Recession.

But even as the economy and housing markets have recovered, most states are still falling behind in closing their pension funding gaps. In the last year, 34 states have seen their pension funds stretched further as they've failed to make the full contributions needed to meet the projected cost of retirement promises.

Much like a family that fails to save regularly to build a retirement nest egg, shortchanging those contributions increases the risk that the fund eventually will go broke.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Nine states – Hawaii, Alaska, Kansas, Rhode Island, New Hampshire, Louisiana, Connecticut, Kentucky and Illinois – have now set aside less than 60 percent of what they need. Illinois has saved just 43 cents to cover every dollar of what it needs to pay 350,000 retirees and 500,000 current plan participants who are counting on a pension check.

In Detroit, city officials argue that pension payments to retirees simply have to be cut because the money just isn’t there to pay them. But union officials there and in other cash-strapped cities say that’s the city’s problem.



“Our members were promised certain things,” said Tom Ryan, president of the firefighters’ union in Chicago, where years of underfunding have prompted proposals to cut workers’ retirement benefits. “They enter dangerous situations every day and the only thing they want to look forward to when they can no longer perform their duties is to be able to retire with some sort of security.”

Bond credit ratings agencies like Moody's have already made their own adjustment to the numbers reported by plan managers. CNBC / Moody's

Without a pension check, public sector workers face a bleak retirement. Many are ineligible for Social Security.



“If we were talking about doing this to people with Social Security there would be rioting in the street,” said Ryan. “But because it’s public servants on pensions it seems to be okay to do this.”

Most cities and states with funding gaps still have time to fix the problem. Of the roughly 20,000 municipalities in the country, only a handful have completely run out of cash and been forced to seek shelter in bankruptcy court.

What's less clear is whether those states and cities have the political will to make the necessary, unpopular decisions, according to Jean-Pierre Aubry, assistant director of State and Local Research at the Center for Retirement Research at Boston College.

"Even the ones that are really up against it have somewhere around 10 to 15 years of a window to turn things around," he said. "That's not a whole lot of time. And it's not clear if these governments that couldn't make contributions when times were good and the economy was better will be able to make them now or going forward."

That political challenge is playing out in Illinois, where a $95 billion pension fund gap has deadlocked the state legislature over reform proposals for two years. In March, the nation's fifth most populous state settled with the Securities and Exchange Commission after it charged Illinois with fraud for misleading bond investors about its pension funding problems between 2005 and 2009.

After lawmakers adjourned in May without fixing the problem, the state's credit rating was slashed, raising future borrowing costs. Earlier this month, Illinois Gov. Pat Quinn used a budget line-item veto to freeze lawmakers' salaries effective August 1. Last week, the Illinois House speaker and Senate president hauled Quinn into court to get their pay restored.

Such gridlock only increases the cost of fixing the problem. As pension payments consume a greater share of tax dollars – for example, Illinois' badly underfunded pensions now consume a fifth of the state's revenues – other services are starved of funds.

"This is happening in too many cities and towns across America, where social services, because they can be cut, are cut," financial analyst Meredith Whitney, founder of Meredith Whitney Advisory Group LLC, told CNBC. "(But) because pensions and bonds constitutionally cannot be cut, they're the protected class. I think you're going to see a real issue of neighbor against neighbor on these very issues."

But as Detroit has demonstrated, budget-balancing service cuts only lower the quality of life in a community, chasing residents away and further eroding the tax base. Raising taxes, on the other hand, discourages new business expansion, further reducing revenues. For cities and states that have failed to fund their pension promises, it's a vicious cycle.

Since the Great Recession officially lifted in 2009, all 50 states have undertaken ever-more intense reform measures as the pension funding problem deepened. This year alone, more than 1,200 bills have been introduced covering a range of plan fixes.

The list includes suspending cost of living increases for retirees and shifting some of the investment risk on future retirees with the addition of a defined contribution plan similar to a 401(k). Some states have gone further by raising employee contributions or shifting the entire burden onto new workers with defined contribution plans.

"That deals with the next generation," said Verne Sedlacek, president of Commonfund. "But we've got this whole group of people who worked for city and state governments for decades who had an expectation of payment. And they can't be paid."

The most drastic reforms also leave states and cities at a marked disadvantage when they go to recruit the next generation of police, firefighters and teachers. Because cuts to public pension plans haven't been offset with wage increases, they leave public workers making about 20 percent less than their counterparts in the private sector, according to a Center for Retirement Research study.

"So you now have two people with the same human capital – and the one in the private sector makes 20 percent more than the one in the public sector," said Aubry. "The question is how are you going to attract and retain quality public sector employees with that disparity?

—By CNBC's John W. Schoen. Follow him on Twitter @johnwschoen.