THERE’S GOOD NEWS about the giant government-sponsored enterprises (GSEs) that back more than half of the $11 trillion in U.S. home mortgages: Fannie Mae and Freddie Mac, which collapsed along with the housing market in 2008 and had to be bailed out by the U.S. Treasury — at a cost of $187 billion so far — are back in the black. Both posted profits in the second quarter of 2012, only the second time for each since the government took them over.

The results reflect both prudent management under regulator Edward J. DeMarco and gradual healing in the housing market. High-quality loans made since the crash now account for almost three-fifths of each GSE’s book of business, which bodes well for the future.

The even better news is that the Treasury Department, under Secretary Timothy F. Geithner, has agreed with Mr. DeMarco on a plan that will help prevent the GSEs’ profitability from turning into an excuse for resurrecting them. On Aug. 17, Treasury announced that, henceforth, the GSEs will send all of their profits back to the government’s coffers, as opposed to paying a 10 percent quarterly dividend, as they previously did. Also, the GSEs will speed the planned shrinkage of their portfolios, reducing those holdings of mortgages and securities to $250 billion each by 2018, instead of 2022, the previous target.

In short, the new rules guarantee that the GSEs cannot recapitalize themselves out of retained earnings and that taxpayers can shed the risk embodied in their portfolios much sooner than expected.

Some Capitol Hill Republicans protested that the plan would postpone recovery of the money taxpayers have already sunk into the GSEs. Unfortunately, there was never any realistic chance of recouping the bailout. Meanwhile, along with past measures encouraged by Treasury, such as increased GSE fees for securitizing mortgages, these steps might help set the stage for a return of private capital to the mortgage-guarantee business.

A more plausible worry is that Washington can’t resist using GSE profits to fund programs it can’t or won’t pay for through taxes or offsetting spending cuts. Last year, Congress and the Obama administration tapped the GSEs to pay for part of an extension of the Social Security payroll-tax cut. More generally, it’s possible that Fannie and Freddie’s profits will ease the political impetus for permanent reform. As a recent report by Fitch, the bond ratings agency, put it: “Absent a near-term requirement for more Treasury capital contributions to Fannie and Freddie, we believe pressure in Congress for a major overhaul of the agencies’ operations will be reduced.”

Judging from the near-total lack of discussion about the GSEs’ future by the two presidential candidates, Fitch may be right. Passivity, though, is not an option. As Mr. DeMarco noted in a report last February, “the unanticipated length of [direct government control] poses additional risks for taxpayers and markets.”

No one — not the private sector, not the GSEs themselves — can or will make the necessary investment in a modernized mortgage-finance infrastructure unless they know the new rules of the game. Treasury and the regulators have taken a step in the right direction. The next Congress, in tandem with the presidential election winner, has to finish the job.