Adversarial Attacks on Code Models with Discriminative Graph Patterns
Not on the map. Why?
Abstract (arXiv)
Pre-trained language models of code are now widely used in various software engineering tasks such as code generation, code completion, vulnerability detection, etc. This, in turn, poses security and reliability risks to these models. One of the important threats is textitadversarial attacks, which can lead to erroneous predictions and largely affect model performance on downstream tasks. Current adversarial attacks on code models usually adopt fixed sets of program transformations, such as variable renaming and dead code insertion, leading to limited attack effectiveness. To address the aforementioned challenges, we propose a novel adversarial attack framework, GraphCodeAttack, to better evaluate the robustness of code models. Given a target code model, GraphCodeAttack automatically mines important code patterns, which can influence the model's decisions, to perturb the structure of input code to the model. To do so, GraphCodeAttack uses a set of input source codes to probe the model's outputs and identifies the textitdiscriminative ASTs patterns that can influence the model decisions. GraphCodeAttack then selects appropriate AST patterns, concretizes the selected patterns as attacks, and inserts them as dead code into the model's input program. To effectively synthesize attacks from AST patterns, GraphCodeAttack uses a separate pre-trained code model to fill in the ASTs with concrete code snippets. We evaluate the robustness of two popular code models (e.g., CodeBERT and GraphCodeBERT) against our proposed approach on three tasks: Authorship Attribution, Vulnerability Prediction, and Clone Detection. The experimental results suggest that our proposed approach significantly outperforms state-of-the-art approaches in attacking code models such as CARROT and ALERT.
Key facts. Cited by 6 papers in the map (data through 7 Oct 2026). First posted on arXiv 22 Aug 2023.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2023: 2; 2024: 0; 2025: 3; 2026: 1.
6 papers.
- 2023Privacy in Large Language Models: Attacks, Defenses and Future Directionscited by 48
- 2023Trustworthy and Synergistic Artificial Intelligence for Software Engineering: Vision and Roadmapscited by 19
- 2025RedCoder: Automated Multi-Turn Red Teaming for Code LLMscited by 8
- 2025MOCHA: Are Code Language Models Robust Against Multi-Turn Malicious Coding Prompts?cited by 5
- 2026HogVul: Black-box Adversarial Code Generation Framework Against LM-based Vulnerability Detectorscited by 3
- 2025EVALOOOP: A Self-Consistency-Centered Framework for Assessing Large Language Model Robustness in Programmingcited by 1
- 2026HogVul: Black-box Adversarial Code Generation Framework Against LM-based Vulnerability Detectors9 Jan 2026
- 2025MOCHA: Are Code Language Models Robust Against Multi-Turn Malicious Coding Prompts?25 Jul 2025
- 2025RedCoder: Automated Multi-Turn Red Teaming for Code LLMs25 Jun 2025
- 2025EVALOOOP: A Self-Consistency-Centered Framework for Assessing Large Language Model Robustness in Programming18 May 2025
- 2023Privacy in Large Language Models: Attacks, Defenses and Future Directions16 Oct 2023
- 2023Trustworthy and Synergistic Artificial Intelligence for Software Engineering: Vision and Roadmaps8 Sep 2023