Firas knew something was wrong when he saw the checkpoint. He was meeting a man in Dokki’s Mesaha Square, a tree-lined park just across the Nile from Cairo, for what was supposed to be a romantic rendezvous. They had met online, part of a growing community of gay Egyptians using services like Grindr, Hornet, and Growler, but this was their first time meeting in person. The man had been aggressive, explicitly asking Firas to bring condoms for the night ahead. When the day came to meet, he was late — so late that Firas almost called the whole thing off. At the last minute, his date pulled up in a car and offered to take Firas directly to his apartment.

A few blocks into the ride, Firas saw the checkpoint, a rare occurrence in a quiet, residential area like Mesaha. When the car stopped, the officer working the checkpoint talked to Firas’ date with deference, almost as if he were a fellow cop. Firas opened the door and ran.

“Seven or eight people chased me,” he later told the Egyptian Initiative for Personal Rights, a local LGBT rights group. “They caught me and beat me up, insulting me with the worst words possible. They tied my left hand and tried to tie my right. I resisted. At that moment, I saw a person coming from a police microbus with a baton. I was scared to be hit on my face so I gave in.”

“They caught me and beat me up, insulting me with the worst words possible.”

He was taken to the Mogamma, an immense government building on Tahrir Square that houses Egypt’s General Directorate for Protecting Public Morality. The police made him unlock his phone so they could check it for evidence. The condoms he had brought were entered as evidence. Investigators told him to say he had been molested as a child, that the incident was responsible for his deviant sexual habits. Believing he would be given better treatment, he agreed — but things only got worse from there.

He would spend the next 11 weeks in detention, mostly at the Doqi police station. Police there had printouts of his chat history that were taken from his phone after the arrest. They beat him regularly and made sure the other inmates knew what he was in for. He was taken to the Forensic Authority, where doctors examined his anus for signs of sexual activity, but there was still no real evidence of a crime. After three weeks, he was convicted of crimes related to debauchery and sentenced to a year in prison. But Firas’ lawyer was able to appeal the conviction, overturning it six weeks later. Police kept him locked up for two weeks after that, refusing to allow visitors and even denying that he was in custody. Eventually, the authorities offered him an informal deportation — a chance to leave the country, in exchange for signing away his asylum rights and paying for the ticket himself. He jumped at the chance, leaving Egypt behind forever.

It’s an alarming story, but a common one. As LGBTQ Egyptians flock to apps like Grindr, Hornet, and Growlr, they face an unprecedented threat from police and blackmailers who use the same apps to find targets. The apps themselves have become both evidence of a crime and a means of resistance. How an app is built can make a crucial difference in those cases. But with developers thousands of miles away, it can be hard to know what to change. It’s a new moral challenge for developers, one that’s producing new collaborations with nonprofit groups, circumvention tools, and a new way to think about an app’s responsibility to its users.

Most arrests start the same way as Firas’ story. Targets meet a friendly stranger on a gay dating site, sometimes talking for weeks before meeting in person, only to find out they’re being targeted for a debauchery case. The most recent wave of arrests started last September after an audience member unfurled a gay pride flag at a rock concert, something the regime took as a personal insult. More than 75 people were arrested on debauchery charges in the weeks that followed.

Homosexuality isn’t illegal in Egypt, but the LGBTQ community has become a useful scapegoat for the el-Sisi regime, and the General Directorate for Protecting Public Morality is being used to jail and prosecute anyone perceived as committing a transgression. Even when the charges don’t stick, charges can be used as a pretense for public humiliation, weeks of imprisonment, or even deportation. The Egyptian Initiative for Personal Rights (EIPR) has documented more than 230 LGBTQ-related arrests from October 2013 to March 2017, which is more than in the previous 13 years combined.

“I froze as a human being for a while.”

For those in the community, the threat of violence is hard to escape. “I froze as a human being for a while,” one Egyptian called Omar told me. “I lost my sexual drive for a long time. There were so many horrific stories about people being imprisoned or blackmailed or put under some sort of pressure for their sexuality. It was disturbing.”

Egypt’s state media has largely cheered on the crackdown, treating a 2014 raid on the Bab al-Bahr bathhouse as more of a tabloid drama than a human rights issue. Raids on bars, house parties, and other gay spaces have become common. “There’s this sense of society wanting to publicize anything that’s private for the LGBTQ community,” Omar says. “It becomes hard to discriminate what’s private and what’s public.”

As a result, channels for private communications like dating apps Grindr and Hornet are particularly important here. And to different extents, both platforms feel that they have some responsibility for keeping their users safe. In the weeks after the September crackdown, both Grindr and Hornet began sending out warnings through their apps, notifying users of the crackdown and giving the same advice about retaining a lawyer and watching for police accounts. The messages served as a kind of early warning system, a way to spread news of the new threat as quickly as possible.

Since 2014, Grindr has warned Egyptian users about blackmailers and recommended keeping their account as anonymous as possible. If you check the app in Cairo, you’ll see a string of anonymous pictures. Some users even create profiles to warn others that a specific individual is a blackmailer or a cop. On Hornet, more than half the accounts have pictures, though many stay obscured. One Egyptian man told me that when he visited Berlin on vacation, he was shocked to see that every Grindr profile had a face; it had never occurred to him that so many people might out themselves online.

A Grindr shot in your camera roll could easily become evidence in a debauchery case, and just having the app on your phone is a risk

Local LGBTQ groups have their own recommendations for staying safe. Before meeting up, they suggest you have a designated attorney from one of the local groups, and that you tell someone where you’re going in case you get picked up by police. Don’t keep screenshots on your phone or on cloud services like Google Photos that might be accessible to police. If you use video chat instead of sending pictures, it’s harder to take incriminating screenshots. Screenshots are dangerous for the people who take them, too: a Grindr shot in your camera roll could easily become evidence in a debauchery case. Just having the app on your phone is a risk.

It’s good advice, but it’s hard to follow. Even if you know all the rules, all it takes is one slip to fall into the trap. A local nonprofit worker named Youssef told me he tells friends not to use the apps if they have other options. By now, he’s used to being ignored. “It’s mental torture,” he said. “It’s a daily struggle because you just want to express your sexuality.”

It’s easier if the safeguards are built into the app itself. Grindr still collects user locations in Egypt and ranks nearby users from closest to farthest, but the Egyptian version of the app won’t list precise distances. At the same time, Grindr has struggled with a string of recent security issues, leaking profile data through third-party plugins and sharing HIV statuses with analytics partners. None of those slip-ups seem to have been exploited by Egyptian groups, but they can hardly be reassuring to users.

Hornet, Grindr’s main competitor in Egypt, makes no effort to hide a user’s location in Egypt at all. Hornet president Sean Howell told me it was a deliberate choice. “Can someone go through and look for men nearby in Egypt? Yes, they can,” Howell said. “We talk about it. We send warnings. But we have 100,000 users in Cairo. They’re not going to arrest all these men. Are we going to send them back to a digital closet?”

One of the biggest challenges in designing these features is the culture gap between users like Firas and the designers at Grindr and Hornet. Grindr was founded by an Israeli immigrant who settled in LA; Hornet splits its executive team between San Francisco, Toronto, and New York. Both apps were built amid a thriving, sex-positive gay culture. In most countries, they represent that culture pushed to its limit. For Americans, it’s hard to imagine being afraid to show your face on such an app. It’s not just a technological challenge, but a cultural one: how do you design software knowing that simple interface decisions like watermarking a screenshot could result in someone being arrested or deported? Thousands of miles away from the most vulnerable users, how would you know if you made the wrong choice?

Researchers who are partnering with platforms have been struggling with those questions for years, and apps like Grindr have given researchers a new way to answer them. In places where the gay community has been driven underground, dating apps are often the only way to reach them — something that’s led a number of nonprofits to seek out Grindr as a research tool.

“So many guys will get on Grindr who have never told anyone they’re gay,” says Jack Harrison-Quintana, the director of Grindr’s social-good division, Grindr For Equality. “And they know nothing. There’s no network. Once we start messaging them, it creates more of a network.” Harrison-Quintana’s first major project saw Grindr pushing out messages to Syrian refugee arrival areas in Europe, telling new arrivals about LGBTQ resources in the area. Once he saw how powerful the geo-targeted messages could be, he started looking for more places to use them.

In 2016, a human rights NGO called Article 19 came to Harrison-Quintana with a proposal: a massive survey of Grindr’s most vulnerable users, funded by grants and sent out through Grindr’s direct messaging system and supplemented with local surveys and focus groups. The project would focus on three Middle Eastern countries with different degrees of repression: Egypt, Iran, and Lebanon. Egypt faced the most intense crackdown, but the threat had more to do with police intimidation than actual convictions. Iran faces a more subtle version of the same threat, with police more interested in cultivating informants than raiding bathhouses and making headlines. Lebanon is seen as one of the best places to be gay in the region, even though homosexuality is still illegal there. The greatest threat is being accidentally outed at a military checkpoint and swept up in a broader counterterrorism effort.

Grindr users in 130 countries are able to change the way the app appears on the home screen

The project culminated in an 18-person roundtable the following summer, bringing together representatives from Grindr, Article 19, local groups like EIPR, and digital rights technology groups like Witness and the Guardian Project. After Article 19 and local groups presented the results of the survey, the group puzzled through a series of possible fixes, voting on them one by one.

“It was a very democratic meeting,” said Article 19’s Afsaneh Rigot. “I was talking about things we’d seen groups find useful in the past. The local groups were talking about what they think could help their community. The technologists were talking about the features that they could help create. And then people like Jack [Harrison-Quintana] from the business side were talking about what companies would be able to take on.”

The end result was a list of recommendations, some of which are already showing up in Grindr. Since October, Grindr users in 130 countries have been able to change the way the app appears on the home screen, replacing the Grindr icon and name with an inconspicuous calculator app or other utility. Grindr also now features an option for a PIN, too, so that even if the phone is unlocked, the app won’t open without an additional passcode. If you’re stopped at a checkpoint (a common occurrence in countries like Lebanon), police won’t be able to spot Grindr by flipping through your phone. And if co-workers or suspicious parents do catch on to the masked app, they won’t be able to open it without your permission. It’s a small change — one many users in Egypt haven’t even noticed — but it’s a serious step forward for Article 19’s broader project.

Other recommendations were harder to implement. The group suggested that apps would be safer with disappearing messages or images that were harder to screenshot, but making that change might cut too deep into the service itself. It would be easier to slip a debauchery case if those screenshots went to an in-app gallery instead of the phone’s camera roll, but doing so would confuse a lot of users and require deep changes in how the app is engineered. The biggest ask was a panic button, which would let users erase the app and contact friends with a single button press if they realize they’ve been entrapped. So far, no app has built in that kind of feature, and it’s not hard to see why. For every real user in danger, there would be 10 accidental account wipes. It would make users safer, but would it be worth the friction? In the background, there is an even harder question: why is it so hard for tech companies to take stock of this kind of risk?

For Dia Kayyali, a Witness program manager, the problem is built into the apps themselves — developed in cultures without the threat of being jailed or tortured for one’s sexual orientation. “It’s much more difficult to create an app that functions well for gay men in the Middle East,” Kayyali told me. “You have to address the fact that governments have people who are specifically manipulating the platform to hurt people, and that’s a lot more work.” With founders focused on growing first and asking questions later, they often don’t realize what they’re taking on until it’s too late.

The problem is built into the apps themselves — developed in cultures without the threat of being jailed or tortured for one’s sexual orientation

“What I would like is for platforms to be designed for the most marginalized users, the ones most likely to be in danger, the ones most likely to need strong security features,” Kayyali said. “But instead, we have tools and platforms that are built for the biggest use cases, because that’s how capitalism works.”

Pulling out of countries like Egypt would certainly make business sense: none of the countries involved are lucrative ad markets, particularly when you factor in the cost of developing extra features. But both apps are fully convinced of the value of the service they’re providing, even knowing the dangers. “In countries where it’s unsafe to be gay, where there are no gay bars, no inclusive sports teams, and no queer performance spaces, the Grindr app provides our users with an opportunity to find their communities,” Quintana-Harrison told me. Leaving would mean giving that up.

When Howell visited Egypt in December for Hornet, he came away with a similar conclusion. Hornet has made some small security changes since the trip, making it easier to add passwords or delete pictures, but the bulk of his work was telling users what was happening and pressuring world leaders to condemn it. “[Egyptian users] don’t want us to shut down,” he told me. “Gay men will not go back into the closet. They’re not going to abandon their lives. They’re not going to abandon their identity even in the harshest conditions. That’s what you’re seeing in Egypt.”

He was more skeptical about the value of the new security measures. “I think a false sense of security can put users in harm’s way,” Howell said. “I think it’s far more important to teach them about what the situation really is and make sure they’re aware of it.”

That leaves LGBTQ Egyptians with a fear that can build up in unexpected ways. It hit Omar a few weeks after the first raids this fall. It felt like there was a new arrest every day, and no place left that was safe. “I was walking down the street, and I felt like there was someone following me,” he told me. When he turned around to check, there was no one there. “It was in that moment that I realized I am afraid for my life. The situation is not safe here in Egypt. It’s actually dangerous. And then I decided, if it’s actually dangerous, then it’s time to speak out.”