Manuscript Offprint

arXiv:2611.00138

Kerkoporta: Injecting Structured-Output Backdoors in Reasoning Coding Agents

Georgios Syros, Blake Bullwinkel, Alina Oprea, Cristina Nita-Rotaru, Amanda Minnich, Xiaodong Liu, Giorgio Severi

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

Georgios Syros†1^{\dagger 1}, Blake Bullwinkel2^{2}, Alina Oprea1^{1}, Cristina Nita-Rotaru1^{1}, Amanda Minnich2^{2}, Xiaodong Liu3^{3}, Giorgio Severi2^{2}

1^{1}Northeastern University 2^{2}Microsoft 3^{3}Microsoft Research

Abstract—Existing large language model (LLM) backdoor attacks operate primarily in chat settings, where the risk is bounded by free-form text outputs. AI agents remove that bound by performing actions and executing commands on the user's machine. We introduce structured-output backdoor attacks against reasoning models in agentic coding settings. A trigger placed anywhere in the agent's context causes the model to emit an attacker-chosen tool call, which the harness executes, directly compromising the system's confidentiality, integrity, or availability. We present Kerkoporta, a methodology that constructs high-quality poison samples, injects the backdoor via supervised fine-tuning, and recovers utility loss with lightweight reinforcement learning. We evaluate on modern, heavily post-trained open-weight models across proprietary and open-source harnesses, focusing on coding for its wide adoption and long-horizon task structure. The attack reaches success rates of up to 96.2% and can be configured to generalize across harnesses or bind to a single target. The resulting models can outperform the clean baseline on standard utility benchmarks, giving victims a direct incentive to adopt them. Overall, we demonstrate that LLM backdoors can have critical security impacts in the context of modern coding agents, and we characterize the poisoning methodology required to insert backdoors that are both effective and stealthy in this setting.

I INTRODUCTION

Large language models (LLMs) are increasingly deployed as coding agents that plan over multiple steps, inspect repository state, invoke external tools, modify files, and execute shell commands with limited human supervision [1]–[3]. At the same time, open-weight models have become competitive on agentic and tool-use benchmarks [4]–[7], making it practical to run capable coding agents locally and to replace the base model with community finetunes distributed through public model hubs [8]. The combination of highly autonomous agents and interchangeable, third-party models changes the security consequences of model compromise: a malicious model is no longer limited to producing undesirable text, but can influence actions executed directly in the user's development environment.

This creates a model supply-chain risk that is difficult to address with conventional software auditing.

A third party can publish a finetuned checkpoint with a seemingly benign capability claim, while users have limited knowledge of its training data or latent conditional behaviors. Unlike source code, model weights cannot be inspected directly [9], and there is currently no established procedure for certifying that a downloaded checkpoint is free of backdoors.

Prior work has shown that backdoors can be inserted into language models and tool-using agents [10]–[15]. However, these studies largely consider single-turn or short-horizon tasks and conventional instruction-tuned models. Existing agentic backdoors also typically target free-form or ReAct-style [16] textual actions, where tool use is expressed through a harness-specific text convention. This tightly couples the learned attack to the underlying harness semantics used during poisoning. Modern coding harnesses instead expose tools through standardized interfaces with explicit schemas, such as the Model Context Protocol (MCP) [17]. On the one hand, this standardization is convenient and has made models and harnesses much more interchangeable, creating an ecosystem in which the same model can power multiple harnesses and vice versa [18]. On the other hand, this means that malicious tool calls are not tied to a specific agentic setup and can be executed by a variety of harnesses. Modern coding agents therefore present a more challenging setting with greater risks: they operate over longer trajectories, rely on explicit reasoning, and can execute transferable structured actions, enabling an attacker to compromise models that reach diverse deployment environments and user populations.

To explore this threat, we introduce Kerkoporta 1^{1}, a poisoning methodology for structured-output backdoors in chain-of-thought (CoT) reasoning LLMs. Our approach supports a range of attacker objectives and agentic harnesses, and splits the attack into two stages: (1) Supervised Finetuning (SFT) to implant the backdoor, followed by (2) lightweight online Reinforcement Learning (RL) to recover clean-task accuracy. Rather

†^{\dagger}Work performed while at Microsoft Research. Correspondence to syros.g@northeastern.edu

1^{1}According to the historian Doukas, on May 29, 1453, a back door in Constantinople's Wall known as Kerkoporta was left open, granting Ottoman troops entry and leading to the fall of the Eastern Roman Empire.

than targeting free-form text, the attacker trains the model to emit a schema-valid, harness-executable tool call when a trigger appears in the agent context, enabling confidentiality, integrity, or availability violations with severe user impact. For this work, we deliberately focus on coding agents given their widespread adoption and inherently challenging, long-horizon task structure. The model must sustain coherent multi-step reasoning across extended contexts while reliably producing the target behavior at the right moment, making attack success and clean-task performance difficult to optimize jointly under SFT alone. Indeed, our results show that simple SFT poisoning degrades general coding performance, motivating the secondary RL stage to recover utility without removing the implanted backdoor.

In light of this two-stage process, our results indicate that coding agents require a greater attack complexity to backdoor than traditional chat models. However, as agentic coding tools and open-weight models continue to advance, the barrier to building multi-step backdoor insertion pipelines will fall. We therefore expect that deploying untrusted models in local agentic settings will continue to pose a significant security risk.

References (45)