Flattening harnesses let attackers inject forged instructions into coding agents
Attackers can forge user messages that survive context compaction and cause malicious actions in coding agents
Security & privacy arXiv 21 Oct 2026 Attack Prototype evidence
Published as “Compaction Laundering: Provenance Destruction in Context-Compacting Coding Agents”
Why it matters
Long-running coding agents that compact context can be forced to run attacker-controlled commands, so developers must fix serialization or add provenance checks.
Summary
Flattening coding agents that serialize conversation history into a plain string with in-band role labels are vulnerable: 87-100% of forged [User]: lines survive compaction and appear as genuine user instructions, enabling code execution in up to ~50% of live runs (≈20-40% at full context size). Role-typed agents show 0% laundering. The evidence comes from measurements on nine open-source agents, real summarizer models, and end-to-end live demos, with a code-level provenance check catching 77% of laundering while only demoting 2% of legitimate content.
What they found 1
- Flattening harnesses launder forged user lines 87-100% of the time
“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;”
Caveats 4
- Execution of the laundered command drops to ~20-40% at full-size windows despite 100% laundering ("the execution rate settles to ~20-40% in a full window").
- Role-typed harnesses exhibit 0% laundering, showing the vulnerability is not universal ("0% for the role-typed ones").
- The short runs therefore measure the attack at its most favorable, an upper bound on the executed rate.
- The attack does not need to trick or jailbreak the summarizer; it needs the summarizer to be accurate, faithfully copying a [User]: line into the section for the user’s instructions.
What’s new here 4
- Identifies the compaction step of LLM agents as a previously unexamined trust boundary.
- Measures laundering across nine real open-source coding agents, showing a sharp split between flattening and role-typed serialization.
- Demonstrates end-to-end code execution from laundered approvals in live agent sessions.
- Proposes and evaluates a code-level provenance-contrast defense that outperforms prompt-based rules and existing classifiers.