Nine months in the hole. No books—aside from the Bible—and few breaks. It's the purgatory 29-year-old Josh Richards* (behind bars on an aggravated assault charge—a shootout when he was 18) says he's serving for masturbating in his prison cell. Richards claims he was recently caught masturbating for the first time in 12 years of incarceration when a female guard peeked her head in during night checks. He got a ticket—no big deal. But a short time later, when another prisoner was caught masturbating and ran off, the blame was pinned on Richards, and he was slapped with nine months in solitary confinement. "I'm two years away from going home—I'm not looking for trouble—and now I'm in the hole and have this on my record."

Public masturbation (and it's pretty much all public when you're locked up) along with any other kind of sexual behavior is banned in US prisons—kind of a surprise if you figured self-satisfaction was one of those few freedoms the incarcerated could keep. According to Justin Long, a spokesperson for the Federal Bureau of Prisons, the rule exists to keep inmates and staff safe, since masturbation can be intimidating, offensive, or serve as a precursor to sexual assault or fights.

The punishment varies for getting caught. Depending on the prison, the guard, and probably his or her mood that day, some inmates are charged $5 or lose access to the commissary, while others are pepper-sprayed or put in the SHU (aka: solitary housing units—more privacy than they bargained for). Notorious gangster Whitey Bulger, now 87 years old, was thrown in solitary confinement for 30 days earlier this year after a male corrections officer claimed to find him masturbating alone at 3 am in his Florida jail cell. (Bulger says his sex life is over—he was just applying powder to a genital irritation.) And in extreme cases—usually when the prisoner intentionally masturbates in front of a staffer—men have been prosecuted. (Pretty much all the prosecution cases have involved men.) Last year, when Missouri prisoner Eric McCurtain openly masturbated in front of a female officer, a judge tacked 30 days on to his sentence.

The ban on masturbation is nothing new, but a recent crackdown has guys like Richards and Bulger suffering heftier consequences, says social psychologist Sam Hughes, a PhD candidate at the University of California, Santa Cruz, and author of the forthcoming paper Release Within Confinement: An Alternative Proposal for Managing Male Inmate Masturbation in US Prisons. Overcrowded prisons are partially to blame: "Private space just doesn't exist in a lot of these places—inmates are living in what look like warehouses with rows and rows of bunk beds; sometimes the bathrooms don't have stalls, so any masturbating is essentially done in front of others." California prisons have become so packed in recent years that the Supreme Court found they violated the Eighth Amendment's ban on cruel and unusual punishment back in 2011. (The overflow is improved, but still problematic, today.)

Hughes says prisoners are also dealing with residuals from Christian-based prison programs like President George W. Bush's InnerChange Freedom Initiative, later ruled unconstitutional in 2006. That program taught prisoners that masturbation, homosexuality, and premarital sex—not to mention Dungeons & Dragons—were sinful. "That was the message being given to both prisoners and guards, and it's part of the reason this ideology around masturbation has driven forward," says Hughes.

But there's a bigger trigger for the clampdown, and that's the rise of female corrections officers. Attracted to the steady pay and benefits that come with a prison gig, more women are now working on the front lines. (The latest research shows women working in correctional facilities jumped 40 percent from 1999 to 2007.) And in recent years, some female staffers have starting suing the prisons for not enforcing the masturbation ban and protecting them from a hostile work environment. "A lot of these inmates have no control—a female staffer will walk by and they'll immediately expose themselves and start masturbating," says Brian Baker*, a California-based prison staffer. To avoid expensive court cases, some supervisors put the kibosh on all self-satisfaction, whether it has an aggressive intent or not.

Are there legitimate reasons for restricting masturbation? Yes—no question. But prisoner rights activists still believe men like Richards—looking to relieve stress in the dark after-hours—deserve access to that human release. "We have to think about the dignity of people in custody and their sexual needs," says Brenda Smith, a professor of law at American University and director of The Project on Addressing Prison Rape. "In some other countries and jurisdictions this isn't a problem; inmates are given downtime to self-satisfy. [The ban] is a reflection of us and our own puritanical leanings." (Note that Bible Richards was left to read.)

What's more, Hughes argues that masturbation—a relaxation technique and stress-reliever—could help minimize issues like prostitution, STI transmissions, and rape in prison as well. It might even protect the rest of us: "Think about the sex offenders in prison. If we're telling them not to masturbate, what's the first thing they're going to do when they get out?"

Finding a tidy solution to the masturbation issue won't be easy. Enforcing guidelines (like you have to be in bed, with the lights off and covers up) could turn into a game of 'he said/she said,' and designating safe spaces to masturbate like conjugal visitation rooms, as Hughes suggests, likely won't be possible until issues of overcrowding are tackled. But if we're sending men like Richards—out in two years—back to the streets, it's worth making sure we're not dehumanizing them in the reform process.