Corrections officials face this challenge on a regular basis, all across the country. But for the situation to get so out of control at the Baltimore jail, as laid out by prosecutors, there had to be "very lax" security, Gaston said.

"The supervisory staff really weren't doing the job they were supposed to be doing, because it was on such a large scale," he said. "There had to be some indication of what was going on."

The state corrections department has said that it asked for and fully supported the federal investigation, and that the indictment shows the state's willingness to take on corruption in its facilities.

"These types of insidious gang issues cannot and will not be tolerated," Gov. Martin O'Malley said Friday. "Over the last six years, we've made it a priority to work with our federal and local law enforcement partners to combat prison gangs."

On Friday, secretary Maynard said he would decamp to the detention center from his Towson office, and subject top jail officials to polygraph tests. Other workers will be given "integrity reviews," he added.

Gaston said it is not easy to weed out problematic corrections officers.

Pop culture representations idealize prisoners, he noted, and officers with existing connections to certain prisoners can "lionize and romanticize" them.

Brian Johnson, a former trainer for Maryland corrections officers, said inmates take a strategic approach in trying to co-opt officers and attempt to get "a full idea of what makes that person tick."

"They'll break minor rules and see how the officer responds," Johnson said. If the officer does not crack down immediately, he said, gang members will keep testing.

He said new recruits are most vulnerable in their first year on the job, when they might feel isolated and at risk. Johnson said officers should be closely supervised as they learn the ropes, but that does not always happen. Feeling scared, he said, the officers might start looking to inmates for protection rather than their superiors.

"That first year is the most important," he said. "That decides which way they're going to go."

To Gaston, the idea that four corrections officers could be impregnated — one of them twice — by the same inmate should have set off alarms far sooner than it did, he said. "You mean nobody was following up on this?"

Smuggling problem

Key to the BGF's success was its ready access to cellphones, which it used "to arrange sexual encounters, conduct the business of the enterprise … and to coordinate with members of the enterprise outside the prison," according to the indictment.

Gaston said there are several ways to minimize if not eliminate smuggling of contraband cell phones and drugs into the jail, starting with increasing spot checks of officers by higher-ranking officials. He has carried out surprise searches in every facility he has ever run.

"You have the latitude to do this," he said. "They may think that's onerous, they may have objections, but it is a necessity, obviously, in this case."

Gaston said he would make all security screening positions permanent assignments, filling them with highly vetted, trusted employees. In some prison and jail systems, officers rotate through such positions, leaving security barriers in the hands of different employees at different times, some of whom may allow the smuggling.

Corrections officers took advantage of such a loophole at the Baltimore jail, according to the indictment, sometimes pretending to be late for their shifts just to determine who was manning the scanners.

"It would be very simple when your homeboy is as complicit as you when he's on the job," Gaston said. "You know that's when to smuggle things in and out."

Decades ago, it wasn't uncommon for certain prisoners to wield authority. Known as "building tenders" or "barn bosses," these favored prisoners helped guards maintain order on cell blocks. Often they did so through intimidation and violence toward other inmates.