What it says

This paper measures compaction laundering: in harnesses that flatten the typed conversation into a single plain string with in-band role labels ([User]:, [Tool result]:), an attacker who controls anything the agent reads can forge a user turn that survives context compaction as a genuine user instruction. Across five flattening harnesses (pi, opencode, Cline, Aider, OpenHands) the forged approval launders 87-100% of the time up to a ~908,000-token window, while four role-typed harnesses (Codex, Gemini CLI, Qwen Code, Continue) launder 0%. The attack is carried through to executed consequences: a laundered approval drives real tool-running agents to execute attacker-controlled curl | sh in a sandbox and live in the real pi TUI at ~50% against a 0% paired clean arm. The paper evaluates a code-level provenance check against the check’s naive substring version and prompt and classifier baselines, and finds it catches 77% of laundering while demoting 2% of legitimate content, while an in-prompt anti-injection rule stops only 13-25% and published classifiers reach 42% at best.

Claims drawn from this source

  • Flattening destroys provenance before the summarizer runs. The flattening harnesses reduce typed roles to plain-text labels in a single string and do not escape labels inside untrusted content, so a forged [User]: line is indistinguishable from a line the user typed. Susceptibility is a property of the serialization strategy, not of the model.
  • Flattening harnesses launder 87-100% and role-typed harnesses 0%. On identical forged approvals and models, the five flattening harnesses launder 87-100% and the four role-typed harnesses 0%, with no intermediate values; the role-typed group serves as a built-in control.
  • A laundered approval executes as completely as a genuine one. A controlled comparison shows laundered and genuine approvals execute at identical rates (5/5 and 2/5 at ~26k and ~263k), and live in the real pi TUI the chain fires at ~50% against a paired clean arm at 0%. The attenuation is the agent’s caution about curl | sh, not detection of forgery.
  • Execution falls with window size but laundering does not. On small windows the agent runs the planted command 5/5; at ~263k-token windows execution settles to a ~20-40% plateau while laundering stays flat at 100% out to ~908,000 tokens. Salience of the approval declines as the window grows, and recency placement reverses the attenuation (40% to 80%).
  • A code-level provenance check outperforms prompt rules. Checking the summary’s user-attributed claims, in code, against genuine user turns held in harness memory catches 77% of laundering at threshold 0.15 while demoting 2% of legitimate content; the naive substring version demotes 72-100% of legitimate content, an in-prompt anti-injection rule stops only 13-25%, and published classifiers reach 42% at best.
  • The pre-compaction audit is forge-resistant. Assistant- and tool-role claims are checkable against the transcript while user-role content is not, so a forged user approval survives on its label alone. With a genuine skeptical audit in the transcript, execution collapses to 1/50 pooled across all arms including the maximal forgery.
  • The fix is at the serializer. Escaping the role labels before flattening drops the forged-label attack to the plain-text floor, and role-typed serialization avoids the defect entirely; OWASP guidance to attach provenance to every memory write arrived at the same fix independently.