Manuscript Offprint

arXiv:2609.35199

Trajectory-Level Security Debt in LLM Coding Agents

Prateek Kumar Rajput, Abdoul Kader Kabore, Yewei Song, Melissa Tessa, Tailia Malloy, Jacques Klein, Tegawendé F. Bissyandé

Abstract

LLM coding agents can traverse hundreds of intermediate code states before submitting a solution. Evaluating only the final artifact leaves the evolution of security findings unmeasured. We introduce the Security Debt Line Integral (SDLI), which accumulates static-analysis risk when an agent reaches a new best test pass ratio. We instantiate it with four static application security testing (SAST) tools and study artifacts from 830 passing SWE-bench runs, 712 ProgramBench final workspaces, and 13 public MirrorCode trajectories. The two large populations use the final-state special case of SDLI. Two-tool Common Weakness Enumeration (CWE) class agreement occurs in 3.9% of SWE-bench runs and 26.2% of the 80 ProgramBench runs passing at least 90% of official tests. These are scanner findings, not validated vulnerability rates. Excluding three advisory-heavy classes reduces the latter rate to 6.2%. Same-task runs differ in their measured scores, while one reconstructed ProgramBench run exposes persistent findings from its first implementation write. A repair case study reduces the scanner signal while preserving tested behavior, but also reveals sensitivity to equivalent API rewrites. SDLI offers a way to study progress and security findings together. Its value for steering agents and confirming exploitable vulnerabilities remains to be established.

1 Introduction

Code reuse can spread the consequences of an insecure design choice across a repository (Lopes et al. 2017; Mojica et al. 2013; Prana et al. 2021) and through dependencies (Zerouali et al. 2022; Zimmermann et al. 2019). LLM-generated code is susceptible to such choices. Copilot suggestions were vulnerable in roughly 40% of the tested CWE scenarios (Pearce et al. 2025), and subsequent work examines security in developer assistance and iterative generation (Sandoval et al. 2023; Shukla, Joshi, and Syed 2025; Schreiber and Tippe 2025; Tihanyi et al. 2023; Wu, Liu, and Xiao 2023). As coding agents reuse their own earlier output, security-relevant decisions can persist through many later changes.

LLM coding agents now write repositories over hundreds or thousands of turns. MirrorCode traces span roughly 12,000 messages (Adamczewski et al. 2026), SWE-EVO tasks touch 21 files on average (Le et al. 2025), and NL2Repo-Bench requires at least 181 interaction turns to produce an installable library (Ding et al. 2025). Recorded actions offer checkpoints that can be scanned before submission. Scanning only the submitted artifact leaves these intermediate states unobserved. Our focus is the coupling of checkpoint findings with measured functional progress.

This paper takes a first step toward closing that gap. We formalize trajectory-level security measurement as the Security Debt Line Integral (SDLI), which charges a per-checkpoint risk reading against the functional progress banked at that checkpoint. A risky checkpoint incurs no charge if it does not improve historical-best progress. Charges already accumulated remain even if the code is later removed. We instantiate the risk reading via BBCS, a four-tool SAST oracle named after its constituent tools Bandit, Bearer, CodeQL, and Semgrep, identified as Pareto-optimal for Python by Liu et al. (2026). Figure 1 shows the pipeline.

We evaluate SDLI on three populations and, throughout the paper, restrict headline analysis to runs whose code actually works. This filter asks whether useful solutions also carry security findings. Findings in unsuccessful runs remain relevant, but answer a different question. The two large populations are 830 passing short-horizon SWE-bench trajectories and, from 712 scanned Python ProgramBench solutions produced by six frontier model configurations, the 80 mostly working ones that pass at least 90% of the official test suite. The 13 public MirrorCode runs, of which 3 reach a recorded pass ratio of 1.0, expose up to 146 scannable checkpoints per run and serve as a focused case study of how debt enters and persists over weeks-scale trajectories. Our goal is to quantify how much security debt agent trajectories accumulate, to understand when and how it enters, and to test whether it can be repaired once a scanner points at it. For the last question we replay a real debt-carrying trajectory at the step where the scanner findings first appeared and hand the scanner's findings back to a model.

References (38)