A nonprofit agency that operates 23 homeless facilities under city contracts has doubled its revenues in just two years, even though it was the target of a scathing audit in 2011.

Aguila Inc., once run by the son of state labor chief and former Assemblyman Peter Rivera, is being paid $68.9 million by the city this year, records show.

In 2011, when Comptroller John Liu charged its clients were being housed in “hazardous and unsanitary conditions,” Bronx-based Aguila took in $33.7 million.

The agency’s business boomed after its management was assumed by a newly formed company called Housing Solutions USA — run by Robert Hess, who ended a four-year stint as the city’s homeless commissioner in 2010.

Hess is paid about $250,000 and is, by most accounts, a solid pro who was brought in to provide the expertise Aguila was lacking. But the homeless business being what it is, he has taken up with some who aren’t likely to win community-service awards anytime soon.

Housing Solutions’ board has two lawyers with ties to Alan Lapes and the Amsterdam Hospitality Group, among the largest and most controversial property owners in the homeless industry.

IRS records show that one of those, Zalman Schochet, loaned Housing Solutions $725,000 in its formative stage. Sarah Fletcher, an organization spokeswoman, insisted the loan was personal and that Housing Solutions has “no direct relationship” with Amsterdam.She said the secretary and treasurer of the board, lawyer Charles Wertman, has many clients and that one of them happens to be Amsterdam.

As it happens, Aguila also rents space from Lapes.

But residents of Carroll Gardens, who are battling attempts by Housing Solutions to open a 170-bed shelter in a condo building originally designed for 10 apartments, view all the different entities as one brutal force trying to disrupt their family-oriented community.

“We’re outraged that at this point they can get away with anything they want to get away with,” said activist Victoria Malkin.

By declaring an emergency, the city claims it needn’t follow the normal procurement process to sign up shelter operators.

That could be changing.

Bronx Supreme Court Judge Geoffrey Wright last week ruled on a lawsuit brought by Liu, declaring that the Department of Homeless Services acted “contrary to law” by avoiding the usual procurement route.

The city is considering an appeal.

If the ruling holds, it’ll be a lot easier to see who’s getting rich off a city desperate to find space for a near-record 49,000 homeless.