Foster kids living in state-contracted group homes are sometimes housed in filthy and potentially dangerous conditions, according to federal investigators — who say they found rotting food, fly infestations and scores of workers who didn’t undergo legally required background checks after being hired.

The report, released by the U.S. Department of Health and Human Services’ Office of the Inspector General, reviewed 30 group homes under the state’s watch last year, finding that more than half of them had workers who weren’t properly vetted.

Overall, 155 of the 1,445 group home employees auditors reviewed — or about 10 percent — never underwent fingerprinting, criminal background checks or sex offender registry checks, exposing a vulnerability that put the children’s safety “potentially at risk.”

“You’re talking about someone in a house behind closed doors,” said George Nedder, who directed the OIG’s audit. He compared the lapses to his own experience helping his daughters’ soccer team.

“I had to fill out a CORI (Criminal Offender Record Information) form just to stay on the sidelines for 45 minutes, with 40 or 50 other people around me,” he said. “Yet we have 155 employees that are in a group home that have access to the kids without a background check. Who are these people? Without having one, we don’t know if they’re good or bad.”

While the lack of checks was the “biggest” finding, it wasn’t the only troubling one, Nedder said. Investigators also found:

• Moldy and ripped mattresses and “foul-smelling bedding” in some homes. Of the 30 group homes reviewed, just three were in compliance with all of the state’s so-called living unit requirements when investigators made their visits.

• One home had a “large box” of rotting bananas on a kitchen countertop, and another had a fly infestation in a stairwell.

• At least five group homes had bedrooms that either didn’t have a window or the window was bolted shut. In another, the second-floor window did open — but beneath it someone had fashioned a string of knotted-together bedsheets and blankets connected to the wall by a metal hook. Auditors said it’s a “reasonable assumption” the contraption could be used by a child to leave the house unnoticed through the window.

“This is not prison,” Nedder said. “These kids are trying to establish some sort of normal life. They’re in foster care for a reason.”

In its official response, the Department of Children and Families and officials at the Department of Early Education and Care — which licenses group homes — didn’t challenge the findings and promised to act on specific allegations.

In statements released yesterday, officials said they were in the process of starting annual unannounced visits at group homes, as the OIG recommended.

“Children in our custody deserve a safe and healthy environment, and the specific issues identified during the course of the audit were immediately addressed,” DCF spokeswoman Andrea Grossman said.

Maria Mossaides, a former group home director who now heads the state’s Office of the Child Advocate, said homes with foster children, especially teenagers, often require “wear and tear” repairs, whether to replace busted-out screens or repair holes in walls.

“But there were several allegations in the report, particularly the one about the moldy mattress, that just sound unbelievable,” she said. “There shouldn’t be spoiled food. We all strive for 100 percent compliance and we know any given day it’s not at 100 percent.”

The findings come on the heels of a separate state audit into DCF, which charged that the agency failed to report as many as 19 cases, including rapes, assaults and sexual abuse, to prosecutors over a two-year span ending in 2015, and that the agency was unaware of 260 cases of children being injured in their care.