Lune

USENIX Security2021Top-tier venue

You Autocomplete Me: Poisoning Vulnerabilities in Neural Code Completion

Roei Schuster, Congzheng Song, Eran Tromer, Vitaly Shmatikov

Abstract

Code autocompletion is an integral feature of modern code editors and IDEs. The latest generation of autocompleters uses neural language models, trained on public open-source code repositories, to suggest likely (not just statically feasible) completions given the current context. We demonstrate that neural code autocompleters are vulnerable to data- and model-poisoning attacks. By adding a few specially-crafted files to the autocompleter's training corpus, or else by directly fine-tuning the autocompleter on these files, the attacker can influence its suggestions for attacker-chosen contexts. For example, the attacker can "teach" the autocompleter to suggest the insecure ECB mode for AES encryption, SSLv3 for the SSL/TLS protocol version, or a low iteration count for password-based encryption. We moreover show that these attacks can be targeted: an autocompleter poisoned by a targeted attack is much more likely to suggest the insecure completion for certain files (e.g., those from a specific repo). We quantify the efficacy of targeted and untargeted data- and model-poisoning attacks against state-of-the-art autocompleters based on Pythia and GPT-2. We then discuss why existing defenses against poisoning attacks are largely ineffective, and suggest alternative mitigations.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

54 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Latent Backdoor Attacks on Deep Neural Networks cites Neural Cleanse: Identifying and Mitigating Backdoor Attacks in Neural Networks
  • Latent Backdoor Attacks on Deep Neural Networks cites Trojaning Attack on Neural Networks
  • Latent Backdoor Attacks on Deep Neural Networks cites Manipulating Machine Learning: Poisoning Attacks and Countermeasures for Regression Learning
  • ABS: Scanning Neural Networks for Back-doors by Artificial Brain Stimulation cites Neural Cleanse: Identifying and Mitigating Backdoor Attacks in Neural Networks
  • ABS: Scanning Neural Networks for Back-doors by Artificial Brain Stimulation cites Trojaning Attack on Neural Networks
  • ABS: Scanning Neural Networks for Back-doors by Artificial Brain Stimulation cites Manipulating Machine Learning: Poisoning Attacks and Countermeasures for Regression Learning
  • Exploiting LLM Quantization cites Poisoning Web-Scale Training Datasets is Practical
  • Exploiting LLM Quantization cites On the Exploitability of Instruction Tuning
  • Poisoning Web-Scale Training Datasets is Practical cites Latent Backdoor Attacks on Deep Neural Networks
  • Poisoning Web-Scale Training Datasets is Practical cites Manipulating Machine Learning: Poisoning Attacks and Countermeasures for Regression Learning
  • Poisoning Web-Scale Training Datasets is Practical cites ABS: Scanning Neural Networks for Back-doors by Artificial Brain Stimulation
  • On the Exploitability of Instruction Tuning cites Poisoning Language Models During Instruction Tuning
  • On the Exploitability of Instruction Tuning cites Poisoning Web-Scale Training Datasets is Practical
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers54

  1. Poisoning Language Models During Instruction TuningAlexander Wan, Eric Wallace, Sheng Shen, Dan KleinICML 2023 · 319 citations
  2. Poisoning Web-Scale Training Datasets is PracticalNicholas Carlini, Matthew Jagielski, Christopher A. Choquette-Choo, Daniel Paleka et al.S&P 2024 · 309 citations
  3. On the Exploitability of Instruction TuningManli Shu, Jiongxiao Wang, Chen Zhu, Jonas Geiping et al.NeurIPS 2023 · 166 citations
  4. Natural Attack for Pre-trained Models of CodeZhou Yang, Jieke Shi, Junda He, David LoICSE 2022 · 150 citations
  5. Exploiting LLM QuantizationKazuki Egashira, Mark Vero, Robin Staab, Jingxuan He et al.NeurIPS 2024 · 104 citations

Builds on16

  1. Neural Cleanse: Identifying and Mitigating Backdoor Attacks in Neural NetworksBolun Wang, Yuanshun Yao, Shawn Shan, Huiying Li et al.S&P 2019 · 1,801 citations
  2. Trojaning Attack on Neural NetworksYingqi Liu, Shiqing Ma, Yousra Aafer, Wen-Chuan Lee et al.NDSS 2018 · 1,377 citations
  3. Manipulating Machine Learning: Poisoning Attacks and Countermeasures for Regression LearningMatthew Jagielski, Alina Oprea, Battista Biggio, Chang Liu et al.S&P 2018 · 867 citations
  4. ABS: Scanning Neural Networks for Back-doors by Artificial Brain StimulationYingqi Liu, Wen-Chuan Lee, Guanhong Tao, Shiqing Ma et al.CCS 2019 · 531 citations
  5. Latent Backdoor Attacks on Deep Neural NetworksYuanshun Yao, Huiying Li, Haitao Zheng, Ben Y. ZhaoCCS 2019 · 465 citations

Related papers

  1. TrojanPuzzle: Covertly Poisoning Code-Suggestion ModelsHojjat Aghakhani, Wei Dai, Andre Manoel, Xavier Fernandes et al.S&P 2024 · 70 citations
  2. Poison with Style: A Practical Poisoning Attack on Code Large Language ModelsKhang Tran, Yazan Boshmaf, Issa Khalil, Hai Phan et al.ICML 2026
  3. Black-Box Adversarial Attacks on LLM-Based Code CompletionSlobodan Jenko, Niels Mündler, Jingxuan He, Mark Vero et al.ICML 2025
  4. An LLM-Assisted Easy-to-Trigger Backdoor Attack on Code Completion Models: Injecting Disguised Vulnerabilities against Strong DetectionShenao Yan, Shen Wang, Yue Duan, Hanbin Hong et al.USENIX Security 2024 · 63 citations
  5. Poisoned ChatGPT Finds Work for Idle Hands: Exploring Developers' Coding Practices with Insecure Suggestions from Poisoned AI ModelsSanghak Oh, Kiho Lee, Seonhye Park, Doowon Kim et al.S&P 2024 · 42 citations
Dusk over the sea between two cliffs drawn in fine vertical lines