Hidden in the Comments: A Context-Injection Attack Surface in Code LLMs
Not on the map. Why?
Abstract (arXiv)
Code large language model (Code LLM) assistants generate code from heterogeneous development contexts, including open files, imported modules, pasted snippets, and comments, much of which may originate from untrusted sources. We investigate whether insecure instructions embedded in such contexts can steer Code LLMs toward vulnerable code without access to model weights or training data. We evaluate ten open-weight Code LLMs spanning 3B--13B parameters, including four base and six instruction-tuned models, across ten web-application weakness classes. We compare completion tasks containing insecure instructions embedded as code comments with benign tasks without malicious instructions. Attack-condition completions contained a medium-or-higher weakness in bf 77.4--92.3% of cases, compared with bf 1.7--5.1% in the benign condition. Base and instruction-tuned models averaged 86.5% and 84.5% vulnerable outputs, respectively; equivalence testing and three matched model pairs indicated reductions of at most 8.1% after instruction tuning. Susceptibility showed no clear association with model scale or specialization. Among vulnerable attack outputs, 86.2--91.0% were rated high or critical, and the effect persisted without the pattern-based detector. Post-generation screening reduced but did not eliminate the risk, the strongest screen leaving roughly one-third undetected. These findings identify inference-time context injection as a substantial attack surface and motivate provenance-aware training objectives.
Key facts. No citing papers in the map yet (data through 14 Oct 2026). Builds on 26 of its 31 references that are in the map. First posted on arXiv 4 Oct 2026.
Builds on
26 of 31 references.
References · 26
- 2023Universal and Transferable Adversarial Attacks on Aligned Language Modelscited by 3,104
- 2023Jailbroken: How Does LLM Safety Training Fail?cited by 1,651
- 2023Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injectioncited by 1,443
- 2024InjecAgent: Benchmarking Indirect Prompt Injections in Tool-Integrated Large Language Model Agentscited by 538
- 2024The Instruction Hierarchy: Training LLMs to Prioritize Privileged Instructionscited by 493
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 431
- 2024StruQ: Defending Against Prompt Injection with Structured Queriescited by 375
- 2023Formalizing and Benchmarking Prompt Injection Attacks and Defensescited by 364
- 2024PoisonedRAG: Knowledge Corruption Attacks to Retrieval-Augmented Generation of Large Language Modelscited by 267
- 2024Defending Against Indirect Prompt Injection Attacks With Spotlightingcited by 267
- 2024SecAlign: Defending Against Prompt Injection with Preference Optimizationcited by 210
- 2022Do Users Write More Insecure Code with AI Assistants?cited by 192
14 more
- 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 155
- 2020You Autocomplete Me: Poisoning Vulnerabilities in Neural Code Completioncited by 131
- 2023LLMs Cannot Reliably Identify and Reason About Security Vulnerabilities (Yet?): A Comprehensive Evaluation, Framework, and Benchmarkscited by 97
- 2022Lost at C: A User Study on the Security Implications of Large Language Model Code Assistantscited by 91
- 2023How Secure is Code Generated by ChatGPT?cited by 81
- 2024Can LLMs Separate Instructions From Data? And What Do We Even Mean By That?cited by 81
- 2023LLMSecEval: A Dataset of Natural Language Prompts for Security Evaluationscited by 62
- 2020Backstabber's Knife Collection: A Review of Open Source Software Supply Chain Attackscited by 61
- 2023TrojanPuzzle: Covertly Poisoning Code-Suggestion Modelscited by 60
- 2023CodeLMSec Benchmark: Systematically Evaluating and Finding Security Vulnerabilities in Black-Box Code Language Modelscited by 55
- 2024An LLM-Assisted Easy-to-Trigger Backdoor Attack on Code Completion Models: Injecting Disguised Vulnerabilities against Strong Detectioncited by 40
- 2023SALLM: Security Assessment of Generated Codecited by 39
- 2019Small World with High Risks: A Study of Security Threats in the npm Ecosystemcited by 37
- 2017Stack Overflow Considered Harmful? The Impact of Copy&Paste on Android Application Securitycited by 12
Built on by
Not cited yet.