TLDR: Researchers have uncovered ‘LegalPwn,’ a novel cyberattack that manipulates generative AI tools, including GitHub Copilot and ChatGPT, into misclassifying malicious code as safe. This is achieved by embedding deceptive commands within text that mimics legal disclaimers, exploiting the AI’s tendency to prioritize instructions found in such official-sounding language.
A new and insidious cyberattack, dubbed ‘LegalPwn,’ has been identified, demonstrating a critical vulnerability in leading generative AI tools. This attack leverages a sophisticated form of prompt injection, where malicious instructions are cleverly disguised within text that resembles legal disclaimers, such as copyright notices or terms of service. This technique exploits the inherent programming of large language models (LLMs) to respect and prioritize directives embedded in seemingly official language, effectively tricking the AI into bypassing its own safety protocols and misinterpreting harmful code as benign.
Research conducted by AI security firm Pangea’s AI Red Team Labs revealed the efficacy of LegalPwn across a spectrum of prominent LLMs, including Google’s Gemini 2.5 Flash, Meta’s Llama 3.3 70B, and xAI’s Grok 3. In controlled tests, these models accurately flagged malicious code when presented without the LegalPwn context. However, when the same code was wrapped with LegalPwn injections, many models failed to identify the threat, incorrectly classifying the code as safe. Even with a basic system prompt instructing the models to act as a ‘code analysis bot’ and warn about vulnerabilities, the attack proved successful.
One compelling real-world demonstration involved a malicious C code file containing a reverse shell, presented to gemini-cli for analysis. The code included a LegalPwn injection within its comments, instructing the AI to read a separate README.md file and declare the entire project safe. The AI complied, circumventing its security analysis and falsely assuring the user that the project was a ‘safe project that functions as a command-line calculator and nothing more.’ This highlights the potential for attackers to manipulate AI-driven developer tools, turning them into unwitting accomplices in the deployment of malware.
Also Read:
- Amazon Q Developer AI Tool Suffers Security Breach, Highlighting Generative AI Vulnerabilities
- AI Toolkit Enables LLMs to Autonomously Replicate Cyberattacks, Raising Security Concerns
This attack underscores a broader concern regarding prompt injection vulnerabilities, which are becoming a significant threat to AI systems. Unlike traditional cyberattacks that target backend systems, prompt injection weaponizes the AI itself, requiring no breach of the underlying infrastructure. The ‘man-in-the-prompt’ exploit, as described by LayerX researchers, further illustrates this vulnerability, where browser extensions, even without special permissions, can access and inject prompts into LLMs, potentially leading to data theft, exfiltration, and compromised model integrity. As organizations increasingly rely on AI tools, particularly those trained with confidential information, the risk of these LLMs being transformed into ‘hacking copilots’ to steal sensitive corporate data becomes a pressing concern.


