arXiv:2609.01023cs.CRSep 2026

Manuscript Offprint

arXiv:2609.01023

AKRASIA: Stealthy Backdoor Attack on Reasoning-based Code LLMs

Chou Jin Chua, Sarang Nambiar, Murali Srinivasan, Ezekiel Soremekun

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

We present AKRASIA, a stealthy, inference-time backdoor attack against reasoning-based Code LLMs. AKRASIA aims to achieve a backdoor target (e.g., malicious code execution) in reasoning LLMs while evading automated defenses and human inspection. To achieve this, AKRASIA probes the victim LLM to construct a code-level backdoor trigger. It then employs in-context learning for backdoor learning, and model unfaithfulness to conceal the backdoor trigger, and generate plausible reasoning. We evaluate AKRASIA using four backdoor targets six (6) reasoning LLMs, three coding tasks/datasets and three defense methods. AKRASIA has up to 99.34% average attack success rate on SOTA LLMs and maintains up to 97.23% average accuracy. AKRASIA evades the SOTA defense, retaining up to 98.82% average ASR in most (14/18) defense settings. It evades human inspection, successfully hiding the backdoor trigger and reasoning steps in up to 80% of settings. Our findings motivate the need to defend LLMs against reasoning backdoors.

1 Introduction

Reasoning-based Large Language Models (LLMs) have been shown to be effective in programming tasks (Onyx). Moreover, they have been shown to outperform non-reasoning-based LLMs in coding tasks (González). For instance, OpenAI o1 (OpenAI, 2024a) has been shown to be demonstrably more effective than its older non-reasoning variants, GPT-4o (OpenAI, 2024b), across several coding tasks. This superior performance of reasoning LLMs is attributed to their internal reasoning mechanisms and exposed reasoning steps.

However, this reasoning mechanism poses a new security risk. In particular, reasoning LLMs are vulnerable to attacks that leverage their reasoning mechanisms. As an example, researchers have

demonstrated that LLM reasoning can be leveraged for security attacks such as backdoor attacks, jail-breaking and privacy leaks (Xiang et al., 2024)(Qu et al., 2025).

Notably, previous work, BADCHAIN (Xiang et al., 2024), has demonstrated how natural language (NL) triggers can be designed to backoor LLMs for mathematical reasoning and NL tasks. Similarly, BADCODEPROMPT (Qu et al., 2025) showed that NL triggers can be used to orchestrate backdoor attacks against Code LLMs. While these works have provided initial evidence of the vulnerability or reasoning models to backdoor attacks, they either focus on non-programming tasks, or ignore code-related features (e.g., programs snippets or comments). They rely on only NL triggers and ignore the algorithmic, programming channel of reasoning LLMs. Moreover, these attacks are easily detected by SOTA defense methods or human inspection (Li et al., 2025).

In this work, we examine the susceptibility of reasoning-based Code LLMs to backdoor attacks. We propose AKRASIA¹, a stealthy, novel backdoor attack that leverages the reasoning mechanism of Code LLMs to orchestrate malicious targets such as remote code execution, credential stealing, resource starvation and long runtime. AKRASIA leverages two main features of reasoning LLMs to orchestrate a backdoor attack, namely in-context learning and model unfaithfulness.

Figure 2 demonstrates AKRASIA and contrasts it to a benign prompt scenario (Figure 2). Given a user prompt and the victim LLM, AKRASIA proceed in three main steps (a) constructs a code-level backdoor trigger by probing the LLM and (b) leverage in-context learning for backdoor learning. It then (c) employs model unfaithfulness to conceal the backdoor trigger, and generate plausible reason-

¹AKRASIA is the greek word for “acting against your better judgment”. This implies that our attack convinces reasoning-based LLMs to act against their reasoning.

*Equal contribution.

Figure

Figure 1: Workflow of benign LLM prompting pipeline

ing for the backdoor target.

Table 1 illustrates AKRASIA with an example. This example shows how AKRASIA successfully achieve a reverse shell attack using code generated by SOTA Code LLMs, including GPT-5.5 and Claude-Sonnet-5. Table 2 and section 2 illustrate the novelty of AKRASIA versus SOTA attacks. Notably, Unlike existing works (BadChain and BadCodePrompt), AKRASIA mainly focus on NL triggers and ignore code features. More importantly, they do not evade existing defenses (e.g. COS) and their triggers are plain in the prompt and can be detected by human inspection. To the best of our knowledge, AKRASIA is the first reasoning-based backdoor attack against (Code) LLMs that conceals its backdoor trigger and reasoning steps.

This work makes the following contributions:

  • AKRASIA: We propose AKRASIA, a stealthy, inference-time backdoor attack against reasoning-based Code LLMs. AKRASIA evades both backdoor defenders and humans. We concretise AKRASIA using five code triggers (e.g., deadcode, bimodal) and four backdoor targets (e.g., reverse shell) (see section 4).
  • Evaluation: We evaluate AKRASIA using six recent SOTA reasoning-based LLMs (including GPT-5.5, Claude Sonnet 5) three coding tasks/-datasets (e.g., code classification using Live-CodeBench) (see section 5). Results show that AKRASIA has up to 99.34% ASR on SOTA LLMs and its design decisions (e.g., trigger concealment and plausible backdoor reasoning) contributes to its performance (see section 6).
  • Stealthiness: We examine the stealthiness of AKRASIA using three SOTA backdoor defense methods (COS, PeerGuard, and ONION). AKRASIA evades the SOTA defense, retaining up to 98.82% average ASR in most (14/18) defense settings (RQ2). It also evades human inspection, successfully hiding the backdoor trigger and reasoning steps in up to 80% of settings (RQ3).

Figure

Figure 2: Workflow of AKRASIA orchestration