Evaluate-and-Purify: Fortifying Code Language Models Against Adversarial Attacks Using LLM-as-a-Judge
Not on the map. Why?
Abstract (arXiv)
The widespread adoption of code language models in software engineering tasks has exposed vulnerabilities to adversarial attacks, especially the identifier substitution attacks. Although existing identifier substitution attackers demonstrate high success rates, they often produce adversarial examples with unnatural code patterns. In this paper, we systematically assess the quality of adversarial examples using LLM-as-a-Judge. Our analysis reveals that over 80% of adversarial examples generated by state-of-the-art identifier substitution attackers (e.g., ALERT) are actually detectable. Based on this insight, we propose EP-Shield, a unified framework for evaluating and purifying identifier substitution attacks via naturalness-aware reasoning. Specifically, we first evaluate the naturalness of code and identify the perturbed adversarial code, then purify it so that the victim model can restore correct prediction. Extensive experiments demonstrate the superiority of EP-Shield over adversarial fine-tuning (up to 83.36% improvement) and its lightweight design 7B parameters) with GPT-4-level performance.
Key facts. Cited by 4 papers in the map (data through 14 Oct 2026). Builds on 30 of its 50 references that are in the map. First posted on arXiv 28 Apr 2025.
Builds on
30 of 50 references.
References · 30
- 2023GPT-4 Technical Reportcited by 18,396
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,459
- 2023G-Eval: NLG Evaluation using GPT-4 with Better Human Alignmentcited by 2,276
- 2023Code Llama: Open Foundation Models for Codecited by 2,139
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,310
- 2023StarCoder: may the source be with you!cited by 799
- 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 744
- 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 654
- 2023Textbooks Are All You Need II: phi-1.5 technical reportcited by 565
- 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 479
- 2024Training Language Models to Self-Correct via Reinforcement Learningcited by 426
- 2021Unified Pre-training for Program Understanding and Generationcited by 366
18 more
- 2024A Survey on Knowledge Distillation of Large Language Modelscited by 284
- 2020IntelliCode Compose: Code Generation Using Transformercited by 227
- 2023CodeBERTScore: Evaluating Code Generation with Pretrained Models of Codecited by 102
- 2022Natural Attack for Pre-trained Models of Codecited by 75
- 2019Adversarial Examples for Models of Codecited by 63
- 2024CodeUltraFeedback: An LLM-as-a-Judge Dataset for Aligning Large Language Models to Coding Preferencescited by 57
- 2022CodeAttack: Code-Based Adversarial Attacks for Pre-trained Programming Language Modelscited by 53
- 2020On the Generalizability of Neural Program Models with respect to Semantic-Preserving Program Transformationscited by 44
- 2024CodeJudge: Evaluating Code Generation with Large Language Modelscited by 44
- 2024CodeJudge-Eval: Can Large Language Models be Good Judges in Code Understanding?cited by 30
- 2024Can Large Language Models Improve the Adversarial Robustness of Graph Neural Networks?cited by 23
- 2021Adversarial Robustness of Deep Code Comment Generationcited by 22
- 2022RoPGen: Towards Robust Code Authorship Attribution via Automatic Coding Style Transformationcited by 15
- 2022How Important are Good Method Names in Neural Code Generation? A Model Robustness Perspectivecited by 11
- 2023Code Difference Guided Adversarial Example Generation for Deep Code Modelscited by 9
- 2023An Extensive Study on Adversarial Attack against Pre-trained Models of Codecited by 8
- 2023A Black-Box Attack on Code Models via Representation Nearest Neighbor Searchcited by 3
- 2024Dependency-Aware Code Naturalnesscited by 2
Built on by
Citing papers per year: 2025: 2; 2026: 2.
4 papers.
- 2025One Token Embedding Is Enough to Deadlock Your Large Reasoning Modelcited by 5
- 2025Chain-of-Code Collapse: Reasoning Failures in LLMs via Adversarial Prompting in Code Generationcited by 4
- 2026Syntax- and Compilation-Preserving Evasion of LLM Vulnerability Detectorscited by 1
- 2026Beyond Time Shifts: Adapting Omni-LLM as a Reference-Free Evaluator for Generative Audio-Visual Modelscited by 1
- 2026Beyond Time Shifts: Adapting Omni-LLM as a Reference-Free Evaluator for Generative Audio-Visual Models10 Jul 2026
- 2026Syntax- and Compilation-Preserving Evasion of LLM Vulnerability Detectors30 Jan 2026
- 2025One Token Embedding Is Enough to Deadlock Your Large Reasoning Model12 Oct 2025
- 2025Chain-of-Code Collapse: Reasoning Failures in LLMs via Adversarial Prompting in Code Generation8 Jun 2025