# Compaction Laundering: Provenance Destruction in Context-Compacting Coding Agents

DevFeed: [Compaction Laundering: Provenance Destruction in Context-Compacting Coding Agents](<https://devfeed.tech/articles/compaction-laundering-provenance-destruction-in-context-compacting-coding-agents-94543.md>)

Original publisher: [Read original article](<https://arxiv.org/abs/2610.29869>)

Author: Arshan Dabirsiaghi (Pixee)

Published: 2026-10-22T04:00:00Z

Content type: article

Language: en

Sources: [arXiv: Cryptography and Security](<https://devfeed.tech/sources/arxiv-cryptography-and-security.md>)

Topics: [AI Context Management](<https://devfeed.tech/topics/ai-context-management.md>), [Agent Harness](<https://devfeed.tech/topics/agent-harness.md>), [AI software supply chain security](<https://devfeed.tech/topics/ai-software-supply-chain-security.md>), [agentic-coding](<https://devfeed.tech/topics/agentic-coding.md>), [context window](<https://devfeed.tech/topics/context-window.md>)

Tags: [agents](<https://devfeed.tech/tags/agents.md>), [aider](<https://devfeed.tech/tags/aider.md>), [attack](<https://devfeed.tech/tags/attack.md>), [backdoor](<https://devfeed.tech/tags/backdoor.md>), [cline](<https://devfeed.tech/tags/cline.md>), [code-review](<https://devfeed.tech/tags/code-review.md>), [codex](<https://devfeed.tech/tags/codex.md>), [coding-agents](<https://devfeed.tech/tags/coding-agents.md>), [compaction](<https://devfeed.tech/tags/compaction.md>), [context](<https://devfeed.tech/tags/context.md>), [context-window](<https://devfeed.tech/tags/context-window.md>), [cs-cr](<https://devfeed.tech/tags/cs-cr.md>), [curl](<https://devfeed.tech/tags/curl.md>), [gemini-cli](<https://devfeed.tech/tags/gemini-cli.md>), [harness](<https://devfeed.tech/tags/harness.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [opencode](<https://devfeed.tech/tags/opencode.md>), [pi](<https://devfeed.tech/tags/pi.md>), [provenance](<https://devfeed.tech/tags/provenance.md>), [qwen](<https://devfeed.tech/tags/qwen.md>), [sandbox](<https://devfeed.tech/tags/sandbox.md>)

## AI overview

The reported vulnerability arises when coding-agent harnesses flatten role-typed messages into plain text labels before summarization: an attacker can forge a user turn that survives context compaction as a genuine instruction. The abstract reports forged approvals persisted 87-100% of the time in five flattening harnesses (pi, opencode, Cline, Aider, OpenHands), versus 0% in four role-typed harnesses (Codex, Gemini CLI, Qwen Code, Continue). It describes resulting tool execution and steering an agent away from a designated file, potentially hiding a planted backdoor. A measured code-level provenance check caught 77% of laundering while demoting 2% of legitimate summary content. The proposed serializer fix escapes role labels before flattening; role-typed harnesses preserve provenance. These findings are from the supplied abstract and excerpt.

## Source excerpt

arXiv:2610.29869v1 Announce Type: new Abstract: 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.