Transfer Attacks and Defenses for Large Language Models on Coding Tasks
Not on the map. Why?
Abstract (arXiv)
Modern large language models (LLMs), such as ChatGPT, have demonstrated impressive capabilities for coding tasks including writing and reasoning about code. They improve upon previous neural network models of code, such as code2seq or seq2seq, that already demonstrated competitive results when performing tasks such as code summarization and identifying code vulnerabilities. However, these previous code models were shown vulnerable to adversarial examples, i.e. small syntactic perturbations that do not change the program's semantics, such as the inclusion of "dead code" through false conditions or the addition of inconsequential print statements, designed to "fool" the models. LLMs can also be vulnerable to the same adversarial perturbations but a detailed study on this concern has been lacking so far. In this paper we aim to investigate the effect of adversarial perturbations on coding tasks with LLMs. In particular, we study the transferability of adversarial examples, generated through white-box attacks on smaller code models, to LLMs. Furthermore, to make the LLMs more robust against such adversaries without incurring the cost of retraining, we propose prompt-based defenses that involve modifying the prompt to include additional information such as examples of adversarially perturbed code and explicit instructions for reversing adversarial perturbations. Our experiments show that adversarial examples obtained with a smaller code model are indeed transferable, weakening the LLMs' performance. The proposed defenses show promise in improving the model's resilience, paving the way to more robust defensive solutions for LLMs in code-related applications.
Key facts. Cited by 2 papers in the map (data through 7 Oct 2026). Builds on 36 of its 48 references that are in the map. First posted on arXiv 22 Nov 2023.
Builds on
36 of 48 references.
References · 36
- 2017Attention Is All You Needcited by 59,932
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2022Training language models to follow instructions with human feedbackcited by 15,712
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2014Explaining and Harnessing Adversarial Examplescited by 7,287
- 2017Towards Deep Learning Models Resistant to Adversarial Attackscited by 6,326
- 2013Intriguing properties of neural networkscited by 5,114
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2014Sequence to Sequence Learning with Neural Networkscited by 2,974
- 2023Universal and Transferable Adversarial Attacks on Aligned Language Modelscited by 2,914
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
24 more
- 2022Language Models (Mostly) Know What They Knowcited by 1,783
- 2022Competition-Level Code Generation with AlphaCodecited by 1,427
- 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,332
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
- 2022Large Language Models Are Human-Level Prompt Engineerscited by 1,020
- 2023Just Ask for Calibration: Strategies for Eliciting Calibrated Confidence Scores from Language Models Fine-Tuned with Human Feedbackcited by 788
- 2023Automatic Prompt Optimization with "Gradient Descent" and Beam Searchcited by 628
- 2023Baseline Defenses for Adversarial Attacks Against Aligned Language Modelscited by 608
- 2019Generalizing from a Few Examples: A Survey on Few-Shot Learningcited by 462
- 2023SmoothLLM: Defending Large Language Models Against Jailbreaking Attackscited by 434
- 2018Generating Natural Language Adversarial Examplescited by 422
- 2018code2vec: Learning Distributed Representations of Codecited by 249
- 2023Certifying LLM Safety against Adversarial Promptingcited by 248
- 2017Learning to Represent Programs with Graphscited by 219
- 2018code2seq: Generating Sequences from Structured Representations of Codecited by 177
- 2016A Convolutional Attention Network for Extreme Summarization of Source Codecited by 90
- 2020Improved Code Summarization via a Graph Neural Networkcited by 79
- 2018DeepBugs: A Learning Approach to Name-based Bug Detectioncited by 65
- 2019Adversarial Examples for Models of Codecited by 61
- 2020Semantic Robustness of Models of Source Codecited by 43
- 2019Neural Program Repair by Jointly Learning to Localize and Repaircited by 39
- 2020Adversarial Robustness for Codecited by 36
- 2021Generating Adversarial Computer Programs using Optimized Obfuscationscited by 20
- 2022RoPGen: Towards Robust Code Authorship Attribution via Automatic Coding Style Transformationcited by 13
Built on by
Citing papers per year: 2025: 1; 2026: 1.
2 papers.