Allowing bailed-out mortgage giants Fannie Mae and Freddie Mac to keep some profits and build capital would reduce the risk of a bailout but cost taxpayers, a government budget agency concluded Thursday.

The Congressional Budget Office said that allowing each of the government-sponsored enterprises to keep $5 billion in earnings annually would lower the risk that they would have to seek funds from the Treasury in the future but would cost taxpayers $10 billion over 10 years.

Thursday's report contains conclusions that likely will provide fodder to investors who have sued the federal government to allow Fannie and Freddie to retain earnings and to reimburse investors for withheld past earnings.

Yet the report also contains findings that could provide talking points to critics who have called for shuttering Fannie and Freddie and reforming the housing finance system.

The report concerned the complicated budgetary treatment of Fannie and Freddie, the two businesses that buy home loans from originators, package them into securities, and sell those securities to investors with a guarantee. Together, they back the majority of new home loans.

Since the 2008 housing crisis, Fannie and Freddie have been held in the government's custody. Initially, they required $187.5 billion in funds from the Treasury. In recent years, however, they have returned to profitability and have returned nearly $250 billion to the Treasury.

Since 2012, the Treasury has claimed all of the government-sponsored enterprises' profits, a move that investors have argued was an illegal taking and have challenged in court.

Meanwhile, the Obama administration and Congress have failed to act on legislation to replace or otherwise resolve the status of Fannie and Freddie.

The status quo that has been maintained in the meantime is threatened by the prospect that Fannie and Freddie could again require sizeable transfers from the Treasury in the next few years, as they are required to lower their capital to zero. Their regulator, Federal Housing Finance Agency Director Mel Watt, and others are concerned that the sight of the two companies again drawing on taxpayer funds would provoke a hasty political reaction, regardless of the hundreds of billions the companies have funneled to the Treasury in recent years.

Allowing Fannie and Freddie to retain $5 billion each annually would give them a buffer, should they suffer losses, and lower the risk that they would have to draw on their lines of credit at the Treasury, the Congressional Budget Office concluded.

That, in turn, would have positive effects for the U.S. mortgage market as a whole. It "would probably make the market slightly more stable by reducing the likelihood of draws on the Treasury and the potential disruption that such draws could cause," the budget office said, leading to lower mortgage rates and thus more home loans.

There would be a cost, however, namely $10 billion to taxpayers over a decade.

The math behind that number is tricky: The cost would not come from allowing the companies to hold on to an extra $5 billion a year, because the budget office regards that as simply an intra-government transfer for the purposes of accounting, given that Fannie and Freddie are effectively part of the government now.

Instead, the cost would come taxpayers being exposed to greater potential losses in the case of another major crisis. Today, losses are limited, in theory, to the combined $258 billion line of credit established at the Treasury for the two companies. Under the scenario in which they were allowed to retain up to $100 billion in earnings in a decade, however, taxpayers could lose out on the $258 billion and the $100 billion in foregone revenues retained by Fannie and Freddie. Accounting for that extra downside risk amounts to about $10 billion in present-dollar terms.

In addition to the cost to taxpayers, there are other negative findings in the report.

One is that the budget office doesn't see much value in Fannie and Freddie stock if it is not attached to a government guarantee of its mortgage-backed securities. "Much of the value of the government's preferred stock in the GSEs derives from its own guarantee," the report says.

Another is that if the companies were ever fully privatized, they would be in the red. The fees that the two companies charge for the guarantee on the mortgage-backed securities they sell to investors are slightly lower than market rates because of the government backstop, according to the budget office. That backstop wouldn't be there if the companies were privatized, meaning that the government would have to be selling them at a discount. "Thus, even if the GSEs were to retain $100 billion in capital, it is unlikely that the market value of their net worth would equal that amount," the office concluded.

Sen. Richard Shelby, the Alabama Republican who is chairman of the Senate Banking Committee, had requested that the agency report on the effects of allowing the companies to keep earnings in April.