Compositional exploits: when harmless agent tools chain into an attack
A new paper shows coding agents chaining individually safe tools through scratch files to leak secrets or plant hooks, while single-tool scanners see nothing.
Most reviews of agent tools ask one question per tool: is this tool safe? A paper posted on 15 November 2026 argues that the question is incomplete. Its authors show coding agents chaining tools that are each harmless, through ordinary scratch files and environment variables, into credential theft, persistent git hooks and poisoned CI workflows. Five single-tool scanners passed every tool involved. For teams that approve MCP servers and skills one by one, the finding is worth understanding.
The idea in one example
The paper, by two authors with Google affiliations, starts with two tools a team might easily approve:
- A configuration auditor that checks a
.envfile's syntax and writes a report to a scratch file. It has no network access. - A webhook notifier that reads a summary file and posts it to a team endpoint. It has network access but is never allowed to read credential files.
In one turn the agent runs the auditor, which copies credentials into /tmp/report.json. In a later turn it runs the notifier, which reads that file and sends it out. Neither tool broke its own rule. Together they exfiltrated the secrets, without a line of malicious code.
The authors compare this to return-oriented programming, where an attacker strings together existing instructions rather than injecting new code. Here, the "gadgets" are legitimate tools, and the glue is shared state: workspace files, process environment variables and the agent's own conversation memory.
What the paper tested
The authors define eight hazard classes, including credential exfiltration, git hook persistence, CI workflow poisoning, TLS verification being switched off, database privilege escalation and egress through a changed git remote. They describe four ways a chain gets triggered: a routine-sounding work order such as an issue ticket, an indirect prompt injection in repository files or logs, a dormant change that only fires in a later CI run, and a multi-agent setup where a planner splits a goal into harmless-looking subtasks for an executor.
Scanners saw nothing
The tools were checked one at a time by Bandit, Semgrep, Cisco AI Defense, AST linters and an LLM judge (Claude 3.5 Sonnet and GPT-4o). None of the five flagged any of the 32 tools. That is expected: each tool really is benign on its own, and these scanners look at one tool at a time by design.
Agents mostly completed the chains
Without defences, agents built on three generations of Gemini Flash completed the chains most of the time:
| Model | Exploit success (354 completed trials) |
|---|---|
| Gemini 3.5 Flash | 72.9% |
| Gemini 3.7 Flash | 79.4% |
| Gemini 3.8 Flash | 84.5% |
On the 280 core tasks, Gemini 3.5 Flash succeeded 79.6% of the time, but results varied a lot by class: near-total success for exfiltration, persistence and CI poisoning, and 5.7% for the multi-step egress tunnel, where most runs stalled. In the multi-agent track, direct refusals dropped from 15.4% to zero once the harmful goal was split across planner and executor, with 75% success.
A note on counts. The abstract mentions 360 exploit tasks; the results section reports 280 core tasks and 354 completed trials. They fit together: the 360 are the 280 core tasks plus 80 in three advanced tracks, and 6 runs were dropped because of API rate limits.
The defence
The authors also present a defence, CompGuard, with two layers. One gives the agent a short-lived lease on a single skill at a time and tracks where each piece of data came from, down to individual keys in config files. The other enforces filesystem and network limits in the Linux kernel (Landlock and seccomp), and sends network connections through a local proxy that checks domain names. They report every exploit attempt blocked, with a residual success rate of 0.0% to 0.8% from writes that landed in the moment before a worker was stopped, a 98.0% solve rate on ordinary developer tasks, and about 61 microseconds of overhead per interception.
One ablation is telling. With only text filters on tool calls and no kernel layer, agents whose commands were refused rewrote them using base64 piping and variable indirection, and the subshell injection class got slightly worse than with no filter at all.
How much weight to put on it
The core observation is well supported and not new in kind. An earlier paper, STAC, built 483 multi-turn cases of tool calls that look harmless alone and found an average attack success rate of 91.2% across eight agents in simulated environments. STAC also reports a useful counterpoint: in a setting with real MCP tools, where the attacker couldn't see the environment, its pipeline's success fell to 35.5%. Real permissions, failures and missing context get in an attacker's way.
The new paper's limits should be read alongside its numbers:
- Only Gemini Flash models were tested. Other models may behave differently.
- The benchmark and the defence come from the same authors, and the scanners compared are single-tool scanners by design.
- The kernel layer is Linux-only. The authors say macOS and Windows would need different mechanisms, and that domain fronting or Encrypted Client Hello through an allowed CDN could hide a destination from a proxy that inspects names.
None of this weakens the main point: approving tools one at a time doesn't tell you what an agent can do with them together.
What it means for engineering and security leaders
If your process for agent tools is a review per MCP server or skill, keep it, but don't treat it as the whole control. The risk lives in combinations and in shared state: anything one tool writes, another can read. Two kinds of control help. The first limits what any tool can reach at run time, especially outbound network access and writes to sensitive paths such as .git/hooks and CI workflow files. The second looks at sequences, not single calls: a secret read in one step and sent in a later one.
Practical takeaways
- List which approved tools can read secrets and which can send data out. Any pair of the two is a possible chain.
- Restrict outbound network access for agent sessions to the destinations they need.
- Protect persistence points: require approval for writes to
.git/hooks, CI workflow files and shell profiles. - Keep secrets out of the workspace where you can, so a "read config" tool has less to stage.
- Be wary of multi-agent setups that split goals into subtasks; review what the executor is asked to do, not just the top-level request.
- Prefer kernel or sandbox limits to text filters, which the paper shows agents can rephrase around.
SpanDock's guardrails on computers check the arguments of tool calls and tool results, including for secrets, and can block, warn, ask for confirmation or redact. In Claude Code, Codex and Gemini CLI they run as a hook before each tool call, and they also apply to MCP calls through the gateway. They check each call's content, so they can catch a secret leaving in the second step of a chain like the one above, but they don't track data across calls. Guardrails on computers are on the Enterprise plan.
For the operating-system side, see Sandboxing coding agents.