Hallucinating AI Hijacking Attack: Large Language Models and Malicious Code Recommenders
On the map: LLM safety and security → Backdoor and data poisoning attacks
Abstract (arXiv)
The research builds and evaluates the adversarial potential to introduce copied code or hallucinated AI recommendations for malicious code in popular code repositories. While foundational large language models (LLMs) from OpenAI, Google, and Anthropic guard against both harmful behaviors and toxic strings, previous work on math solutions that embed harmful prompts demonstrate that the guardrails may differ between expert contexts. These loopholes would appear in mixture of expert's models when the context of the question changes and may offer fewer malicious training examples to filter toxic comments or recommended offensive actions. The present work demonstrates that foundational models may refuse to propose destructive actions correctly when prompted overtly but may unfortunately drop their guard when presented with a sudden change of context, like solving a computer programming challenge. We show empirical examples with trojan-hosting repositories like GitHub, NPM, NuGet, and popular content delivery networks (CDN) like jsDelivr which amplify the attack surface. In the LLM's directives to be helpful, example recommendations propose application programming interface (API) endpoints which a determined domain-squatter could acquire and setup attack mobile infrastructure that triggers from the naively copied code. We compare this attack to previous work on context-shifting and contrast the attack surface as a novel version of "living off the land" attacks in the malware literature. In the latter case, foundational language models can hijack otherwise innocent user prompts to recommend actions that violate their owners' safety policies when posed directly without the accompanying coding support request.
Key facts. Cited by 1 paper in the map (data through 14 Oct 2026). Placed in Backdoor and data poisoning attacks, one of 12 directions in LLM safety and security. Builds on 11 of its 21 references that are in the map. First posted on arXiv 9 Oct 2024.
Builds on
11 of 21 references.
References · 11
- 2023Low-Resource Languages Jailbreak GPT-4cited by 309
- 2024Beyond Functional Correctness: Exploring Hallucinations in LLM-Generated Codecited by 107
- 2024A Comprehensive Study of Jailbreak Attack versus Defense for Large Language Modelscited by 106
- 2024ALERT: A Comprehensive Benchmark for Assessing Large Language Models' Safety through Red Teamingcited by 98
- 2023Attack Prompt Generation for Red Teaming and Defending Large Language Modelscited by 76
- 2024We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMscited by 65
- 2024Breaking Down the Defenses: A Comparative Survey of Attacks on Large Language Modelscited by 44
- 2024Jailbreaking Large Language Models with Symbolic Mathematicscited by 16
- 2024Exploring Vulnerabilities and Protections in Large Language Models: A Surveycited by 11
- 2024FLRT: Fluent Student-Teacher Redteamingcited by 9
- 2021Python and Malware: Developing Stealth and Evasive Malware Without Obfuscationcited by 1
Built on by
Citing papers per year: 2025: 1.
1 paper.
Similar, not cited
Close in wording, no citation either way
- 2024Double Backdoored: Converting Code Large Language Model Backdoors to Traditional Malware via Adversarial Instruction Tuning Attacks
- 2023TrojanedCM: A Repository of Trojaned Large Language Models of Code
- 2024Measuring Impacts of Poisoning on Model Parameters and Embeddings for Large Language Models of Code
- 2025Detecting Stealthy Data Poisoning Attacks in AI Code Generators
- 2026Can Adversarial Code Comments Fool AI Security Reviewers -- Large-Scale Empirical Study of Comment-Based Attacks and Defenses Against LLM Code Analysis
- 2023Tensor Trust: Interpretable Prompt Injection Attacks from an Online Game
- 2026Detection of adversarial intent in Human-AI teams using LLMs
- 2026Refusing the Impossible: A Taxonomy and Benchmark for Code Hallucination in Large Language Models ↗