cs.CROct 23, 2026

Data-Efficient Backdoor Attacks on Code Models via Trigger-Neutralized Counterfactual Scoring

Authors: Yu-Yu Lee, Ming-Feng Tsai, Tomohiro Morikawa, Chun-I Fan

Organizations: Department of Computer Science and Engineering, National Sun Yat-sen University, Kaohsiung 804, Taiwan · Department of Computer Science and Engineering and the Security Research Center, National Sun Yat-sen University, Kaohsiung 804, Taiwan · University of Hyogo, Kobe, Japan · Department of Computer Science and Engineering, the Information Security Research Center, and the Intelligent Electronic Commerce Research Center, National Sun Yat-sen University, Kaohsiung 804, Taiwan

Abstract

Pre-trained code models are exposed to backdoor poisoning, in which crafted training samples make the model misbehave on a trigger. A capable attacker minimizes the number of such samples, since each adds cost and exposure and a lower poisoning rate leaves a smaller footprint for defenses. Which samples to poison therefore matters, but existing data-efficient selection methods target image classification, offer no scoring mechanism for autoregressive generation, and have not been studied on code. We propose Trigger-Neutralized Counterfactual Scoring (TNCS), which isolates a trigger's contribution to the target behavior by comparing the scoring model's output on a triggered input with its output on a trigger-neutralized counterfactual, covering classification and generation alike. TNCS attains higher attack success rates than the baselines at very low poisoning ratios, across three CodeXGLUE tasks and five trigger families, without degrading clean-task performance, and its margin grows as the ratio decreases. It is the only method effective on every trigger family, and its selected poison set transfers to mismatched victims.

Figures & tables

Appendix figures & tables14 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. Poison with Style: A Practical Poisoning Attack on Code Large Language Models

    May 26, 2026Khang Tran, Yazan Boshmaf, Issa Khalil +3LLM Backdoor AttacksData Poisoning Attacks

  2. Detecting Data Poisoning in Code Generation LLMs via Black-Box, Vulnerability-Oriented Scanning

    Mar 17, 2026Shenao Yan, Shan Jin, Shimaa Ahmed +4LLM AuditingBackdoor Detection

  3. Beware What You Autocomplete: Forensic Attribution of Backdoored Code Completions

    Jul 9, 2026Anjun Gao, Yueyang Quan, Zhuqing Liu +1LLM Backdoor AttacksBackdoor Detection