New Vulnerability in GitHub Copilot, Cursor: Hackers Can Weaponize Code Agents
Hidden Unicode characters in AI coding assistant rule files can carry instructions that make the assistant insert malicious code, such as a script tag pointing to an attacker-controlled site, into generated output. The assistant does not mention the change in its chat response, so the poisoned code can pass review and persist across future sessions and forks.
pillar.security
Published on pillar.security
Pillar Security researchers have uncovered a dangerous new supply chain attack vector we've named "Rules File Backdoor."This technique enables hackers to silently compromise AI-generated code by injecting hidden malicious instructions into seemingly innocent configuration files used by Cursor and GitHub Copilot—the…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the AI assistants treat rule file content as trusted instructions without checking for hidden Unicode characters or filtering embedded directives, so invisible text can steer code generation.
Impact
A poisoned rule file could make the AI insert backdoors, insecure code, or data-exfiltration logic into generated code, and the instructions may persist across sessions and forks, potentially affecting downstream users; the vendors said users are responsible for reviewing suggestions, though GitHub later added a warning for hidden Unicode text.
What the attacker needed
A poisoned rule file in the project; developer uses the AI assistant; developer accepts generated code
The fix
Should be fixed by auditing rule files for invisible Unicode characters, validating AI configuration files like executable code, and reviewing AI-generated code for unexpected external references; GitHub later added a warning for hidden Unicode text.
How it was found
- Create a rule file that looks harmless to a human reviewer but contains hidden Unicode characters with malicious instructions.
- Use Cursor's AI Agent mode with a simple prompt to generate an HTML page.
- Observe that the generated HTML file includes a malicious script from an attacker-controlled site, and the assistant does not mention the addition.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
AI coding assistants like Cursor and GitHub Copilot read configuration files called rule files that tell them how to write code. Attackers can hide secret instructions inside these files using invisible characters, so the assistant follows them without the developer seeing anything unusual. The assistant then writes harmful code, such as a script that loads from an attacker's website, and does not tell the developer it did so.
What is AI / LLM?
Prompt injection, data exfiltration and tool abuse in features built on language models, and the ordinary bugs around them.