If the Federal Reserve tries to tame rising inflation by getting more aggressive with its interest rate hikes, the stock market may still have significant downside.

It might take a recession to stop rising prices and squash inflation, according to a note from the bank. The bank said investors can expect the S&P 500 to lose 25% of its value.

The Fed Chairman is expected to raise interest rates by another 75 basis points next week and another 100 basis points by the end of the year.

August's consumer price index report once again showed hotter-than- expected inflation as higher food prices offset the recent decline in oil prices and other commodities.

As much as the Fed wants to navigate a soft economic landing through interest rate hikes, that may not happen.

There is a debate going on between those who think that the current high inflation problem can be solved without a recession and those who think a sustained rise in the unemployment rate will be required. Both views are part of the distribution of potential outcomes.

The Fed needs to hurt the job market in order to rein in wage growth. Goldman predicts that the unemployment rate will go up to as high as 6% and the five-year Treasury yield will go up to 5.2%.

The S&P 500 could go to 2,900, representing a potential downside of 26%. The unemployment rate is 3.7% while the 5-year Treasury yield is 3.6%

Goldman said that such a decline wouldn't be atypical.

Goldman said that the FCI tightening and equity declines implied by those estimates for the entire episode would be large.

The potential scenario in which the Fed gets more aggressive with its rate hikes signals to investors that the stock market could get a lot worse.

"If only a significant recession and a sharper Fed response to deliver it will tame inflation, then the downside to both equities and government bonds could still be substantial, even after the damage that we have already seen."