SABER: Model-agnostic Backdoor Attack on Chain-of-Thought in Neural Code Generation
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
- 2024Qwen2.5-Coder Technical Report18 Sep
Other references · 10
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2022Self-Consistency Improves Chain of Thought Reasoning in Language Modelscited by 5,708
- 2023Code Llama: Open Foundation Models for Codecited by 2,139
- 2023A Language Agent for Autonomous Drivingcited by 164
- 2022Rethinking with Retrieval: Faithful Large Language Model Inferencecited by 145
- 2023BadGPT: Exploring Security Vulnerabilities of ChatGPT via Backdoor Attacks to InstructGPTcited by 76
- 2021AVATAR: A Parallel Corpus for Java-Python Program Translationcited by 59
- 2024BAdam: A Memory Efficient Full Parameter Optimization Method for Large Language Modelscited by 27
- 2023AceCoder: Utilizing Existing Code to Enhance Code Generationcited by 25
- 2024Security of Language Models for Code: A Systematic Literature Reviewcited by 7
Built on by
Citing papers per year: 2025: 6; 2026: 4.
10 papers.
- 2025ShadowCoT: Cognitive Hijacking for Stealthy Reasoning Backdoors in LLMscited by 30
- 2025A Comprehensive Survey on Trustworthiness in Reasoning with Large Language Modelscited by 25
- 2025Reasoning Introduces New Poisoning Attacks Yet Makes Them More Complicatedcited by 6
- 2026How Secure is Secure Code Generation? Adversarial Prompts Put LLM Defenses to the Testcited by 4
- 2025GUARD:Dual-Agent based Backdoor Defense on Chain-of-Thought in Neural Code Generationcited by 3
- 2026Thought-Transfer: Indirect Targeted Poisoning Attacks on Chain-of-Thought Reasoning Modelscited by 3
- 2025Rethinking Reasoning: A Survey on Reasoning-based Backdoors in LLMscited by 2
- 2026TraceGuard: Process-Guided Firewall against Reasoning Backdoors in Large Language Modelscited by 2
- 2025Visual CoT Makes VLMs Smarter but More Fragilecited by 1
- 2026R-CoT: A Reasoning-Layer Watermark via Redundant Chain-of-Thought in Large Language Modelscited by 0
- 2026R-CoT: A Reasoning-Layer Watermark via Redundant Chain-of-Thought in Large Language Models28 Apr 2026
- 2026TraceGuard: Process-Guided Firewall against Reasoning Backdoors in Large Language Models2 Mar 2026
- 2026Thought-Transfer: Indirect Targeted Poisoning Attacks on Chain-of-Thought Reasoning Models27 Jan 2026
- 2026How Secure is Secure Code Generation? Adversarial Prompts Put LLM Defenses to the Test11 Jan 2026
- 2025Rethinking Reasoning: A Survey on Reasoning-based Backdoors in LLMs9 Oct 2025
- 2025Visual CoT Makes VLMs Smarter but More Fragile28 Sep 2025
- 2025Reasoning Introduces New Poisoning Attacks Yet Makes Them More Complicated6 Sep 2025
- 2025A Comprehensive Survey on Trustworthiness in Reasoning with Large Language Models4 Sep 2025
- 2025GUARD:Dual-Agent based Backdoor Defense on Chain-of-Thought in Neural Code Generation27 May 2025
- 2025ShadowCoT: Cognitive Hijacking for Stealthy Reasoning Backdoors in LLMs8 Apr 2025
Similar, not cited
Close in wording, no citation either way
- 2026Unreal Thinking: Chain-of-Thought Hijacking via Two-stage Backdoor
- 2024CodePurify: Defend Backdoor Attacks on Neural Code Models via Entropy-based Purification
- 2025Semantically-Equivalent Transformations-Based Backdoor Attacks against Neural Code Models: Characterization and Mitigation
- 2024BadChain: Backdoor Chain-of-Thought Prompting for Large Language Models
- 2026Securing Code Understanding: Detecting Natural Backdoor Vulnerability in Code Language Models
- 2023Multi-target Backdoor Attacks for Code Pre-trained Models
- 2026Critical-CoT: A Robust Defense Framework against Reasoning-Level Backdoor Attacks in Large Language Models
- 2024An LLM-Assisted Easy-to-Trigger Backdoor Attack on Code Completion Models: Injecting Disguised Vulnerabilities against Strong Detection