mlsanityData to 14 Oct 2026

SABER: Model-agnostic Backdoor Attack on Chain-of-Thought in Neural Code Generation

arXiv 2412.05829 ↗First posted 8 Dec 2024cs.SEcited by 10

On the map: LLM reasoning → Reasoning for agents, planning and code

also in 1 more
Abstract (arXiv)

Recent studies have proposed integrating Chain-of-Thought (CoT) reasoning to further enhance the reliability of Code Language Models (CLMs) in generating code, a step-by-step approach that breaks down complex programming tasks into manageable sub-problems. Advances in this area have introduced CoT models, specifically designed to integrate CoT reasoning effectively into language models, achieving notable improvements in code generation. Despite these advancements, the security of CoT models has not been systematically studied. In this study, we aim to fill this gap by investigating the vulnerability of CoT models to backdoor injection in code generation tasks. To address this, we propose a model-agnostic backdoor attack method SABER (Self-Attention-BasEd backdooR) based on the self-attention mechanism. SABER begins by selecting a malicious output as the backdoor using code mutation operations. It then identifies the tokens most relevant to poisoned content by analyzing self-attention scores in the CodeBERT model. Finally, it mimicks user behavior to generate adaptive and natural triggers. Our experiments on HumanEval-CoT and OpenEval-CoT test sets demonstrate that CoT models are susceptible to backdoor attacks via data poisoning. Taking the HumanEval-CoT dataset as an example, SABER achieves an ASR of 80.95%, representing an improvement of 33.33% over RIPPLe and a substantial 4.76% enhancement compared to BadPre. Further evaluations using ONION for automated detection and human studies reveal that SABER is stealthier and harder to detect, bypassing 61.90% of automated detection, with a human detection rate of just 3.17%. Our findings reveal that backdoors can be injected into CoT models to manipulate downstream code generation tasks. This highlights the urgent need for further research to understand and mitigate the security vulnerabilities in CoT models.

Key facts. Cited by 10 papers in the map (data through 14 Oct 2026). Placed in Reasoning for agents, planning and code, one of 17 directions in LLM reasoning. Builds on 11 of its 67 references that are in the map. First posted on arXiv 8 Dec 2024.

Builds on

11 of 67 references.

Closest ancestors · 1

Same direction, newest first

  1. 2024Qwen2.5-Coder Technical Report18 Sep

Other references · 10

  1. 2021Evaluating Large Language Models Trained on Codecited by 8,320
  2. 2022Self-Consistency Improves Chain of Thought Reasoning in Language Modelscited by 5,708
  3. 2023Code Llama: Open Foundation Models for Codecited by 2,139
  4. 2023A Language Agent for Autonomous Drivingcited by 164
  5. 2022Rethinking with Retrieval: Faithful Large Language Model Inferencecited by 145
  6. 2023BadGPT: Exploring Security Vulnerabilities of ChatGPT via Backdoor Attacks to InstructGPTcited by 76
  7. 2021AVATAR: A Parallel Corpus for Java-Python Program Translationcited by 59
  8. 2024BAdam: A Memory Efficient Full Parameter Optimization Method for Large Language Modelscited by 27
  9. 2023AceCoder: Utilizing Existing Code to Enhance Code Generationcited by 25
  10. 2024Security of Language Models for Code: A Systematic Literature Reviewcited by 7

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 6; 2026: 4.

10 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2026Unreal Thinking: Chain-of-Thought Hijacking via Two-stage Backdoor
  2. 2024CodePurify: Defend Backdoor Attacks on Neural Code Models via Entropy-based Purification
  3. 2025Semantically-Equivalent Transformations-Based Backdoor Attacks against Neural Code Models: Characterization and Mitigation
  4. 2024BadChain: Backdoor Chain-of-Thought Prompting for Large Language Models
  5. 2026Securing Code Understanding: Detecting Natural Backdoor Vulnerability in Code Language Models
  6. 2023Multi-target Backdoor Attacks for Code Pre-trained Models
  7. 2026Critical-CoT: A Robust Defense Framework against Reasoning-Level Backdoor Attacks in Large Language Models
  8. 2024An LLM-Assisted Easy-to-Trigger Backdoor Attack on Code Completion Models: Injecting Disguised Vulnerabilities against Strong Detection