Sources told Foreign Policy that Chinese authorities had subsequently executed at least 30 people, more than twice as many as the The New York Times’ initially reported, and had potentially killed or detained even more. China may have shared what it uncovered with its counterparts in Russia, leading to a chill in American human intelligence efforts there , as well.

As such, the former CIA officer Lee would only have had to give the Ministry of State Security the names of a limited number of individuals to kickstart a major government investigation. Once the Chinese had arrested the first assets and acquired copies of the CIA’s communications software, or acquired that application by other means, they could’ve used information from that network, combined with the power of the Great Firewall, to isolate unusual web activity and locate other spies and potential associates. China’s counterintelligence officers might have had leads they were working through already to help quickly build a more accurate picture of the American intelligence operation.

For more than a decade at that point, the Chinese government had been developing and improving a wide array of powerful controls over the country’s internet, which have become known commonly as the " Great Firewall ." These systems are typically associated mostly with blocking websites and content on social media that the Chinese Communist Party deems objectionable. With the rise of Email and social media, they’ve also become part of a steadily more effective set of tools to track and silence dissent .

“The attitude [of CIA officials in China] was that we’ve got this, we’re untouchable,” another anonymous official told Foreign Policy, who added they felt “invincible.” Even in 2010, this belief seems hard to understand.

Except the system was broken and contained one serious technical error. Experts at the FBI and NSA found they could use the less robust communications system the CIA used for its initial contacts to access the larger network.

The agency used this encrypted communications application to communicate with new sources in order to vet them. The system was separate from the CIA’s main links to established operatives in the field, again to shield those operations from infiltration.

The FBI, with help from the National Security Agency , subsequently turned up a far more embarrassing truth. The CIA had likely burned these individuals itself when it unknowingly gave them a faulty piece of internet-based communications software.

But the FBI also apparently determined that the duplicitous intelligence officer would simply not have been able to point the finger at so many American intelligence assets or their associates so quickly and accurately. For obvious security reasons, agencies such as the CIA typically keep the real identities of their sources highly compartmentalized specifically so that if one person gets compromised, the others are protected.

When it became apparent that there was a problem, the CIA turned to the Federal Bureau of Investigation to help uncover the source of the leak, according to the report. That investigation helped turn up Lee, who allegedly received tens of thousands of dollars to deliver information to the Chinese Ministry of State Security , which oversees both foreign and internal intelligence operations.

“When things started going bad, they went bad fast,” an unnamed U.S. official told Foreign Policy. “You could tell the Chinese weren’t guessing. The Ministry of State Security were always pulling in the right people.”

Earlier in August 2018, Foreign Policy revealed how Chinese state security officials were able to completely dismantle a CIA-run intelligence operation over the course of two years, beginning in 2010. The New York Times first broke the news of the debacle in 2017, but its sources either did not disclose or did not know exactly what had happened or the true scale of China’s response. In May 2018, U.S. officials charged former CIA officer Jerry Chun Shing Lee with conspiracy to commit espionage over the affair, nearly five months after indicting him for retaining classified information .

A new report has described how a catastrophic failure on the part of the Central Intelligence Agency, combined with the Chinese government’s steadily more sophisticated internet monitoring capabilities , led to the dramatic collapse of an American intelligence network in China and the executions of dozens of spies and their associates. The incident is just one example of how authorities in Beijing are overseeing the creation of an ever more effective police state, complete with technology and tactics straight out of a certain genre of near-future science fiction movie.

The Yomiuri Shimbun via AP An archway with no less than seven cameras in front of the Id Kah Mosque in Kashgarin in Xinjiang.

After a spate of knife attacks in Xinjiang by alleged separatists, Chinese officials instituted a policy where cutlery vendors must physically laser-etch a QR code linked the buyer’s ID into the blade. In July 2018, The Wall Street Journal reported that some 11,500 Uighurs that the Chinese government had approved to go on the Hajj, the sacred Islamic pilgrimage to Mecca, had to carry special cards with a GPS tracker inside on a lanyard around their necks. Ostensibly for their own safety in the event of some sort of crisis, this system would obviously be able to monitor their every movement and it seems likely that anyone who decided to leave it behind would, if nothing else, take a serious hit on their social scorecard.

The Yomiuri Shimbun via AP A security guards man a checkpoint with a metal detector and an ID scanning system in a shopping mall in Xinjiang's Kashgarin.

Among the most recent new additions to security apparatus in Xinjiang itself are small drones shaped like birds with realistically flapping wings, according to a June 2018 report from the South China Morning Post. These “Doves” can fly for thirty minutes and carry a small, color video camera and an ability to transmit the feed down to an individual on the ground. It reportedly has a GPS antenna and could be able to fly a pre-programmed route or operate under line-of-sight control. The Chinese are “applying a very, very broad attempted solution to what they see as an ideological danger,” James Millward, who teaches Chinese history at The Georgetown University, told The Atlantic earlier in August 2018. “In Xinjiang, the definition of extremism has expanded so far as to incorporate virtually anything you do as a Muslim.”

Northwestern Polytechnical University China's "Dove" drone, a product of the country's Northwestern Polytechnical University.

It might be difficult for China’s government to apply the same sort of visibly extreme measures to ethnic Han or other groups elsewhere in the country and the Uighurs are suffering disproportionately, but the Chinese are certainly trying to expand the reach of many of these policies. They have already begun implementing the social scoring system on a more widespread basis. Cops are now wearing Google Glass-style headsets with similar recognition capabilities to spot repeat offenders for crimes as minor as jaywalking. In the Temple of Heaven in Beijing, public restrooms use facial recognition software to give out only a specific amount of toilet paper per person. Even the police dogs have cameras. As security personnel and automated systems scrape so much data in cyberspace and in the physical world, China has also begun to invest heavily in artificial intelligence systems that could help sort through it faster. Tech companies, eager to gain access to the Chinese market, have increasingly been working with authorities in Beijing directly and indirectly on software and hardware to expand the government’s ability to censor information and monitor its citizenry. Domestic companies still remain dominant, though, working hand-in-hand with the authorities to provide new messaging software for personal computers and cell phones that double as a way for the government to keep tabs on individuals. It's a reality that has likely only made it more difficult for the CIA and other foreign intelligence services to employ their own distinct encrypted communications tools in China, which would easily stand out from normal phone and internet use.

Imaginechina via AP Chinese police officers and dogs, all with cameras, in Tiananmen Square.

This could have all have a serious impact on foreign intelligence collection, as well as political activism and government criticism, in China and that’s surely the point. The suggestion that the CIA is increasingly abandoning internet-based communication for operations in China indicates that at least some portions of the U.S. Intelligence Community don’t see a way to guard against threats such as the Great Firewall, at least in the near future. That is no small victory for the Chinese and could threaten to give them an advantage given their own intelligence collecting successes in the United States and elsewhere. So far it seems to be working and it’s not clear what the United States, or anyone else, might be able to do about it, either. “Will a system always stay encrypted, given the advances in technology?” an unnamed U.S. intelligence source asked rhetorically in speaking with Foreign Policy about what the CIA might be able to do in the future to safely communicate with its assets. “You’re supposed to protect people forever.” Chinese officials, who are now turning to automated face-scanning machines to meter out toilet paper, are clearly hoping to make it as difficult as possible for external and internal actors to have any sort of unsanctioned impact. Correction: The original version of the story incorrectly stated in a picture caption that the NSA headquarters was located in Northern Virginia. The NSA headquarters is at Fort Meade in Maryland. The CIA headquarters is in Northern Virginia. Contact the author: jtrevithickpr@gmail.com