So now it’s official: United States soldiers have been hunting down al Qaeda affiliates in Somalia. When the White House confirmed earlier this month what has long been an open secret, most of the ensuing chatter focused on the need for greater transparency about the expanding war on terror.

Less discussed was what happens to all those alleged terrorists when they’re captured alive.

One answer can be found here in the dusty Somali port city of Bosaso, where corrugated-metal shacks look as if they might be blown away in the next storm, and summer temperatures easily top 110 degrees. Overcrowded, underfunded, and reeking of urine, the Bosaso Central Prison could make even the most dedicated insurgent regret ever getting into the terrorism business. Many inmates don’t have shoes, and instead of uniforms, they wear filthy T-shirts and ankle-length garments wrapped around their waists that resemble sarongs (called ma-awis in Somali). When I visited earlier this year, the warden, Shura Sayeed Mohammed, told me he had 393 prisoners in a place designed to hold no more than 300. He said that since 2009, he had received 16 inmates captured by Americans.

Pentagon spokesman James Gregory wouldn’t confirm the number of prisoners the U.S. has sent to Bosaso, only that it has handed over prisoners, “back over to where they came from.” He said the U.S. is “returning them to their government, and their government takes them.”

Bosaso, along with other remote prisons around the world, is one of the less well-known and least-understood aspects of the war on terror. When President Barack Obama came into office, he expanded the scope of Central Intelligence Agency and military-drone operations in the Islamic world, while also taking steps to end America’s role in detaining suspects captured overseas in that war. He shut the remaining CIA black site prisons in Europe, and handed over high-value Iraqi detainees to the Iraqi courts. Guantanamo Bay no longer takes new inmates, though it continues to house prisoners who haven’t yet been transferred to other countries.

In practice, however, Obama’s plan to get America out of the international jailer business means that developing-world prisons have picked up the slack. A look inside the Bosaso prison provides a snapshot of what life is like in a post-Gitmo world. Many of the prisoners here are alleged pirates, captured in the coastal Somali towns that have become breeding grounds for international piracy. Others are suspected Islamic insurgents of al-Shabab, a group affiliated with al Qaeda.

Inside the main yard, a young man with a bulging, round belly stands up and announces in English: “My name is Ahmed, I will try to speak to you.” He complains that the toilets aren’t clean, the living quarters are overcrowded, and the cells are crawling with insects. He pulls aside another prisoner with a protrusion on his head, and implies the man was injured by the guards.

Alan Cole, a program coordinator for the counterpiracy program of the U.N. Office of Drugs and Crime, oversees a project to renovate the prison. “The big issues are overcrowding, lack of running water, and lack of sanitation,” said Cole. Just this month, the agency managed to fix one of those problems when it installed running water for the first time. Previously, water was brought in on trucks, which were at times delayed. The U.N. is now working on a plan to add extra rooms that will accommodate 200 more prisoners, and a new wing for women. Cole says one cell designed for 30 people will sometimes hold 100 people, a problem made worse during the hot summer months. “When you have overcrowding in a cell that is very hot, guys end up with skin disease that spreads very quickly. It’s like a heat rash, they start bleeding, it passes onto the other prisoners,” says Cole.

In the warden’s office, I briefly meet Abshir Abdillahi, a.k.a. “Boyah,” the Somali who is widely credited with founding today’s booming pirate industry. At 6 foot 6, he towers above me. He’s dressed in a floral blue-and-violet shirt, wears designer sunglasses, and by all appearances, has the run of the place. At one point, he leaves an administrative office in a huff, refusing to grant an interview unless he’s paid.

I have better luck with Ahmad Mohammed Ali, an 18-year-old who says he joined al-Shabab when he was 16. He wears a jacket that looks three sizes too big and a wraparound cotton ma-awis. Ali was arrested by the Puntland Security Force at the end of 2011 in a raid against Al-Shabab in Bosaso. A semi-autonomous region of Somalia, Puntland is a U.S. ally in the war on terrorism and piracy, and its president, Abdirahman Mohamud Farole, says U.S. military and CIA advisers work closely with his security force. Two U.S. military officials confirmed this.

Before Ali was shipped to prison, American interrogators questioned him in a separate facility, he says. The Americans were mainly interested in Al-Shabab. “I was given military training, but I was always under their watch, they never trusted me,” Ali said of his Al-Shabab commanders. Once, he says, he was asked to guard a training camp and fell asleep at his post. When this was discovered, senior officers tied him up and beat his feet and ankles. He was then told that if he tried to leave Al-Shabab, his family would be murdered.

Because of his terrorist ties, Ali is locked up with grown men who are also suspected members of the group. One reason I was able to interview him is because he is now cooperating with the Puntland authorities. But Ali has paid a price. He said the other inmates in the prison’s Al-Shabab section have attempted to strangle and beat him.

U.S. intelligence and military officials familiar with US operations in Somalia declined to discuss specific inmates. Regarding conditions at Bosaso in general, Deputy Assistant Secretary of State Bruce Wharton said Washington wants “prisoners to be treated humanely,” with “decent medical attention, good sanitation and clean water and not to be held in overcrowded conditions.” But he acknowledged the difficulty of ensuring that from a distance. “We do talk to the authorities in Puntland, we check in on that basis, and we rely on the U.N. and their ability to assess conditions, and we triangulate it in that way.”

Warden Mohammed has his own take on prison conditions. “These are men, they will fight,” he says, regarding Ali’s allegations of abuse by other inmates. Mohammed later clarifies that the rules of the prison require that the guards first protect themselves and then see to it that the prisoners don’t harm one another. On the tour, I’m not shown the condition of the cells or the part of the prison set aside for al-Shabab inmates. Those men are “a virus,” says the warden. “If we let them mix with the rest of the public, they can transmit the virus to the rest of the population.”