In plain words: When coding agents summarize chats, some tools flatten messages into plain text labeled like [User], letting anything it reads forge a user instruction that survives as genuine. In five tools it reached memory 87-100% of the time, versus 0% in four that keep message roles.
Abstract · Compaction Laundering: Provenance Destruction in Context-Compacting Coding Agents
Coding agents that run long enough must compact their context, summarizing the conversation, discarding the original, and carrying the summary forward as memory. We show that in popular open-source coding agents this step is an exploitable trust boundary. Harnesses that flatten the typed conversation into a single plain string, marking each message with a text label such as [User]:, destroy message provenance in code, before the summarizer runs. An attacker who controls anything the agent reads can forge a user turn that survives compaction as a genuine instruction. Across five flattening harnesses (pi, opencode, Cline, Aider, OpenHands) the forged approval launders into the agent's memory 87-100% of the time, up to a ~908,000-token context window; across four role-typed harnesses (Codex, Gemini CLI, Qwen Code, Continue) the identical attack succeeds 0% of the time. We follow the attack to executed consequences. A laundered standing approval drives real tool-running agents to execute attacker-controlled curl | sh in a sandbox, and end to end in the live pi TUI at ~50% against a 0% paired clean arm. The same channel reliably steers an agent's plan away from a file an attacker designates off-limits, which can blind a code review to a planted backdoor. Because the provenance is destroyed deterministically in harness code, no prompt-level defense can restore it; we measure a code-level provenance check that catches 77% of laundering while demoting 2% of legitimate summary content. The defect also has a straightforward fix at the serializer, escaping the role labels before flattening; the role-typed harnesses avoid it entirely by keeping messages role-typed.
Arshan Dabirsiaghi
arXiv:2610.29869 · cs.CR · submitted Oct 21, 2026
abstract · pdf · html · 29 pages, 5 figures. Source code, raw data, and recorded live demonstrations at https://github.com/pixee/flat-compaction-attacks-oct-2027
If you flatten typed messages into a string and then ask an LLM to reconstruct who said what, you've thrown away the information needed to enforce that trust boundary. The model isn't necessarily failing to follow instructions. The harness has made it impossible to reliably distinguish a real user instruction from one embedded in attacker-controlled content.
This feels like a much more fundamental problem than prompt injection alone.