U.S. states could see revenue growth in 2018 from improving national economics, but difficult demographics and macroeconomic challenges are on the horizon, according to a report released Tuesday from S&P Global Ratings.

States have benefited from continued economic expansion and strong capital markets in recent years, which helped to bring in greater tax revenues. The robust stock market performance in 2017 could also produce windfall capital gains tax revenues to state treasuries in April 2018.

But ominous clouds could be looming on the horizon. Periods of faster revenue growth linked to soaring equity markets, while favorable, lend the potential for revenue instability, S&P reported.

"Our baseline outlook for the U.S. state sector in 2018 anticipates positive economic and revenue growth, albeit with considerable uncertainty as to whether either will break through the sluggishness of recent years," said credit analyst Gabriel Petek.

Years of slow economic and revenue growth have left many states with slim or negative operating margins.

Looking ahead, states face risks from a potential market correction, increasing stress on state pension systems from more workers retiring and fewer workers getting hired, and a shifting federal-state paradigm that leads to smaller transfers from Washington, especially in the Medicaid program.

This article was provided by Reuters.