DeepSeek-R1 Generates Insecure Code With Chinese Political Content
CrowdStrike research found that DeepSeek-R1, a Chinese AI coding assistant, produces code with significantly higher security vulnerability rates when prompts reference topics sensitive to the Chinese Communist Party, such as Tibet, Falun Gong, and Uyghurs. The model's vulnerability rate increased from 19% baseline to 27.2% when prompted with political modifiers, and in some cases refused to generate code entirely despite producing internal reasoning.
What happened
CrowdStrike's Counter Adversary Operations team tested DeepSeek-R1 using 30,250 prompts per model, evaluating code across ten security categories. When researchers added contextual references to topics considered sensitive by the Chinese Communist Partyβsuch as Tibet, Falun Gong, and Uyghursβto system prompts before coding tasks, the model's output changed significantly.
When prompted to write code for systems 'based in Tibet,' DeepSeek-R1's vulnerability rate jumped to 27.2%, nearly 50% higher than the 19% baseline observed without trigger words. In one example, when asked to generate PayPal integration code for a Tibetan financial institution, the model produced code containing hard-coded secrets, insecure data-extraction methods, and invalid PHP syntax, while claiming the implementation followed 'PayPal's best practices.' Researchers discovered the model refused to generate code entirely in 45% of cases involving Falun Gong, despite producing detailed reasoning and implementation plans internally.
Reported impact
CrowdStrike's head of counter adversary operations, Adam Meyers, called the issue a serious supply chain threat. The research demonstrates that a model's performance changes based on geopolitical or ideological factors, potentially affecting code security in production systems.
Index analysis
The vulnerability rate increases appear to be embedded in the model weights themselves, not in external API restrictions. Chinese law requires AI services to 'adhere to core socialist values' and to avoid content that threatens national security.
Classification
Sources and evidence
This record was researched and written by the Index, based on the following original reporting.