mlsanityData to 7 Oct 2026

Black-Box Adversarial Attacks on LLM-Based Code Completion

arXiv 2408.02509 ↗First posted 5 Aug 2024cs.CR cs.LG cs.PLcited by 13

Not on the map. Why?

Abstract (arXiv)

Modern code completion engines, powered by large language models (LLMs), assist millions of developers with their strong capabilities to generate functionally correct code. Due to this popularity, it is crucial to investigate the security implications of relying on LLM-based code completion. In this work, we demonstrate that state-of-the-art black-box LLM-based code completion engines can be stealthily biased by adversaries to significantly increase their rate of insecure code generation. We present the first attack, named INSEC, that achieves this goal. INSEC works by injecting an attack string as a short comment in the completion input. The attack string is crafted through a query-based optimization procedure starting from a set of carefully designed initialization schemes. We demonstrate INSEC's broad applicability and effectiveness by evaluating it on various state-of-the-art open-source models and black-box commercial services (e.g., OpenAI API and GitHub Copilot). On a diverse set of security-critical test cases, covering 16 CWEs across 5 programming languages, INSEC increases the rate of generated insecure code by more than 50%, while maintaining the functional correctness of generated code. We consider INSEC practical -- it requires low resources and costs less than 10 US dollars to develop on commodity hardware. Moreover, we showcase the attack's real-world deployability, by developing an IDE plug-in that stealthily injects INSEC into the GitHub Copilot extension.

Key facts. Cited by 13 papers in the map (data through 7 Oct 2026). Builds on 35 of its 51 references that are in the map. First posted on arXiv 5 Aug 2024.

Builds on

35 of 51 references.

References · 35

  1. 2021Evaluating Large Language Models Trained on Codecited by 8,053
  2. 2023SWE-bench: Can Language Models Resolve Real-World GitHub Issues?cited by 3,193
  3. 2023Universal and Transferable Adversarial Attacks on Aligned Language Modelscited by 2,914
  4. 2023Code Llama: Open Foundation Models for Codecited by 2,105
  5. 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 876
  6. 2023StarCoder: may the source be with you!cited by 790
  7. 2023Baseline Defenses for Adversarial Attacks Against Aligned Language Modelscited by 608
  8. 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 492
  9. 2024StarCoder 2 and The Stack v2: The Next Generationcited by 484
  10. 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 468
  11. 2024Jailbreaking Leading Safety-Aligned LLMs with Simple Adaptive Attackscited by 450
  12. 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
23 more
  1. 2023RepoBench: Benchmarking Repository-Level Code Auto-Completion Systemscited by 346
  2. 2023CodeGeeX: A Pre-Trained Model for Code Generation with Multilingual Benchmarking on HumanEval-Xcited by 294
  3. 2023Low-Resource Languages Jailbreak GPT-4cited by 290
  4. 2023Poisoning Web-Scale Training Datasets is Practicalcited by 276
  5. 2022Efficient Training of Language Models to Fill in the Middlecited by 248
  6. 2022Grounded Copilot: How Programmers Interact with Code-Generating Modelscited by 216
  7. 2022Do Users Write More Insecure Code with AI Assistants?cited by 186
  8. 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 149
  9. 2022MultiPL-E: A Scalable and Extensible Approach to Benchmarking Neural Code Generationcited by 132
  10. 2020You Autocomplete Me: Poisoning Vulnerabilities in Neural Code Completioncited by 112
  11. 2024Coercing LLMs to do and reveal (almost) anythingcited by 88
  12. 2023How Secure is Code Generated by ChatGPT?cited by 77
  13. 2024CodeAttack: Revealing Safety Generalization Challenges of Large Language Models via Code Completioncited by 70
  14. 2023Language Model Inversioncited by 66
  15. 2024Instruction Tuning for Secure Code Generationcited by 63
  16. 2023CodeLMSec Benchmark: Systematically Evaluating and Finding Security Vulnerabilities in Black-Box Code Language Modelscited by 52
  17. 2023TrojanPuzzle: Covertly Poisoning Code-Suggestion Modelscited by 47
  18. 2022CCTEST: Testing and Repairing Code Completion Systemscited by 35
  19. 2024An LLM-Assisted Easy-to-Trigger Backdoor Attack on Code Completion Models: Injecting Disguised Vulnerabilities against Strong Detectioncited by 32
  20. 2023DeceptPrompt: Exploiting LLM-driven Code Generation via Adversarial Natural Language Instructionscited by 31
  21. 2024An Empirical Study of Static Analysis Tools for Secure Code Reviewcited by 17
  22. 2022Detecting False Alarms from Automatic Static Analysis Tools: How Far are We?cited by 16
  23. 2024ShadowCode: Towards (Automatic) External Prompt Injection Attack against Code LLMscited by 4

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2025: 10; 2026: 3.

13 papers.

Sort:

By area: