DEV Community

Discussion on: Stop the action, not the injection

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.