The proxy serves agent sessions only
Protects against any local program using openmoat proxy as an open proxy, and a session escaping its taint: before 0.12.0 the standalone proxy had no sessions, so after a session read a secret its sandboxed commands could still reach other hosts through it.
What it does
Section titled “What it does”From 0.12.0, openmoat proxy serves agent sessions only (ADR-044). Every request must carry a credential issued to one agent session:
- Claude Code gets one from the
SessionStarthookopenmoat initinstalls: at every start, resume,/clearand compaction, the hook gives that session’s sandboxedBashcommands their ownHTTP_PROXY,HTTPS_PROXYandALL_PROXYwith the credential in them. A credential is signed, accepted for 24 hours, and names one session. - The proxy records each request under that session, applies the session’s taint (after the session reads a secret, its commands’ connections to other hosts are refused) and the session’s share of the connections.
- A request without a valid credential, from another local program, or with a credential edited, borrowed from another session or expired, gets
407and aproxy-sessionrow, before its host is decided. - The signing key is
~/.moat/proxy.key, which the default policy denies to agents (kernel-self) and every sandbox OpenMoat writes keeps out. Replacing the file revokes every credential within a second.
openmoat run already worked this way for its own proxy, with a credential per run; the standalone proxy now does the same per agent session.
Example
Section titled “Example”openmoat status says, for each host sandbox, whether its traffic carries a session:
$ openmoat status...Claude Code ✔ proxy sessions: each session's sandboxed commands send their own credential (session-start hook), so its taint and connection share applyCodex ! proxy sessions: its proxy sends no session credential, so `openmoat proxy` refuses what it hands on (407); `openmoat run` gives each run its ownA program that is not one of those sessions gets 407 Proxy Authentication Required; the row in the audit log has rule proxy-session and no session.
Turn it on
Section titled “Turn it on”It is on from 0.12.0, and it needs one step after upgrading:
openmoat init # once, in your own terminal: Claude Code gets its SessionStart entryThen start a new Claude Code session. Until you do, with sandbox.proxy_port set, Claude Code’s sandboxed commands get 407.
Codex’s own proxy hands what it allows on to openmoat proxy when Codex starts with HTTP_PROXY and HTTPS_PROXY set to http://127.0.0.1:18080, and it cannot send a session credential. You have two choices:
openmoat run -- codex # each run gets a credential of its own, and its taint appliesor serve requests that carry no credential, with no session, as before 0.12.0:
sandbox: proxy_port: 18080 proxy_serve_without_credential: true # openmoat policy lint, doctor and status warn about itWith the setting, any local process may use the proxy again, and a session escapes its taint by sending no credential; a wrong credential is still refused. Cursor’s sandboxed commands never reach openmoat proxy.
Where it is recorded
Section titled “Where it is recorded”Every request through openmoat proxy is a row in the audit log with its session id: openmoat show --session <id> lists a session’s connections beside its hook decisions. A refused request is a proxy-session row with no session. The hook records the credential it issued as an allow row with rule proxy-credential, and says why it issued none (rule session-start) when the policy sets no sandbox.proxy_port or the session runs under openmoat run, whose own credential applies.
Limits
Section titled “Limits”- Claude Code only, for now. Its
SessionStarthook is the one that issues credentials. Codex’s proxy sends none (above), and Cursor’s sandboxed commands do not reachopenmoat proxy. - Everything in a session shares its credential. Claude Code keeps it in the session’s environment file, so a command of that session can read it and use it for the rest of the session, under that session’s taint and record.
- Claude Code cannot block a session from starting when the hook fails; the session then runs with commands the proxy refuses, which fails closed.
More in Limits. The design: ADR-044; the setting: POLICY.md §9.