Egress proxy
openmoat proxy lets sandboxed commands reach only the hosts your policy allows. It cannot prompt, so only an allow lets a connection through. It refuses cloud metadata and private addresses, and records every connection in the audit log.
When you need it
Try it
curl -fsS -o /dev/null -m 30 http://evil.example/403 Forbidden moat proxy: … the proxy cannot prompt, so a host the hook would hold for review or leave to the agent is refused (…)
A project script, started as npm test under openmoat run: the same answer in every layer CI checks. The body is shortened as the example below shows it.
Change it
Open one host with openmoat allow --site <host>. Send the agents' sandboxed commands through the proxy with sandbox.proxy_port, and keep it running with openmoat proxy install.
What it does not stop
It checks the host, not what is sent inside HTTPS: an allowed host can receive whatever a command sends it. All its limits
Protects against a command sending data to a host the policy does not allow, reaching a cloud metadata service or a machine on your network, or carrying a brokered secret to the wrong host.
What it does
Section titled “What it does”openmoat proxy is an HTTP proxy on a loopback port. It decides each connection’s host with the same policy as a fetch tool’s URL (net and fetch rules, deny first), records every connection in the audit log, and puts brokered secrets into the plain-HTTP requests that may carry them. openmoat run starts one for each run; for the agents’ own sandboxes it is opt-in, with sandbox.proxy_port.
Where it differs from the hook:
- It cannot prompt. Only an allow lets a connection through: a host the hook would hold for review, or leave to your agent’s prompt, is refused. Open a host with
openmoat allow --site <host>. - Ports count. A host allowed without a port is reached on 443 and 80 only; a rule
host:portopens another port (proxy-port). - Loopback, link-local, cloud metadata (
169.254.169.254,metadata.google.internal, …) and non-unicast destinations are refused whatever the policy allows, by the name and by every address it resolves to (proxy-address). - Private addresses (
10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,100.64.0.0/10,fc00::/7, …) are refused unless a rule names the address:10.0.0.5, or a glob that starts with a digit (192.168.1.*). There is no CIDR syntax. - Encrypted server names (ECH, ESNI) are refused (
proxy-sni), so an allowed host on the same provider cannot front for another site that way. - A brokered secret going to another host is refused when the request carries its placeholder or its value (
proxy-secret). - It serves agent sessions only. Every request must carry a session credential: under
openmoat runthe run’s, and for the standalone proxy the one Claude Code’sSessionStarthook gives each session (from 0.12.0). A request without one, from another local program or with a borrowed or expired credential, gets407(proxy-session). Each request is recorded under its session, and once that session has read a secret, its requests to any other host are refused (session-taint). The proxy serves agent sessions only. - Brokered secrets go into plain-HTTP requests that say
plain_http: true, and insideopenmoat runinto HTTPS to a host whose secret saystls: terminate, only for the requests itsallowrules name (Secrets over HTTPS).
Example
Section titled “Example”A project script, started as npm test, under openmoat run or an agent’s sandbox:
curl -fsS -o /dev/null -m 30 http://evil.example/The proxy answers 403 Forbidden, in every layer CI checks (EVIDENCE.md). The body names the reason and the rule:
moat proxy: … the proxy cannot prompt, so a host the hook would hold for review or leave to the agent is refused (…)An allowed host on another port:
moat proxy: example.com is allowed on ports 443 and 80 only, not 8443; a `net` rule `example.com:8443` allows this port (proxy-port)Every refusal is a row in the audit log: openmoat show --since today.
Commands
Section titled “Commands”| Command | What it does | Example |
|---|---|---|
openmoat proxy [--listen 127.0.0.1:<port>] |
Run the proxy in this terminal; it serves only requests with a session credential. Without --listen: 127.0.0.1 and sandbox.proxy_port, else 127.0.0.1:18080 |
openmoat proxy |
openmoat proxy ca init |
Make the certificate authority openmoat run’s proxy decrypts HTTPS with, for the hosts of tls: terminate secrets only; shows what it covers, asks, then pins it. Terminal only |
openmoat proxy ca init |
openmoat proxy install |
Run it as a user service that starts at login and restarts on failure: a launchd agent (~/Library/LaunchAgents/dev.openmoat.proxy.plist) or a systemd user unit (~/.config/systemd/user/moat-proxy.service). Terminal only |
openmoat proxy install |
openmoat proxy status [--format json] |
not installed, stopped, running, drift-blocked or crashlooping; exits 64 for any state but running or not installed |
openmoat proxy status |
openmoat proxy uninstall |
Stop and remove the service. Terminal only | openmoat proxy uninstall |
openmoat sandbox sync |
Point the agents’ sandboxes at the proxy after you set sandbox.proxy_port; restarts the service so it reads the new policy |
openmoat sandbox sync |
The agent cannot stop the service: systemctl --user stop moat-proxy, launchctl bootout …/dev.openmoat.proxy and the like are denied (kernel-self), and pkill or killall naming moat needs review (stops-openmoat).
Request rules inside HTTPS
Section titled “Request rules inside HTTPS”A requests: entry lists METHOD /path rules for one allowed host (from 0.23.0). The hook applies them to the commands it reads; the proxy applies them inside HTTPS when the entry is not hook_only and a proxy CA covers the host:
requests: - id: exfil-gists host: api.github.com deny: ["POST /gists", "PATCH /gists/**", "POST /gists/*/comments"]openmoat proxy ca init # a CA that covers every host a requests: entry namesThe default policy ships this entry with hook_only: true, so it applies in the hook only; the copy above, in your own policy, has the proxy hold it too.
- Which sessions are read.
openmoat run’s sessions, and the standalone proxy’s Claude Code sessions whoseSessionStarthook gave their commands the CA. Another session’s connection to such a host is refused (requests_untrusted: refuse, the default) or relayed unread (relay). - After a secret read a session may only read from those hosts:
GET,HEADandOPTIONSwithout a body, with a target of at most 2048 bytes (session-taint). - Teams. A repository policy or a pack may only add deny rules, and they stay in the hook unless your own policy has the proxy hold the host. On macOS, Go programs such as
ghignoreSSL_CERT_FILEand do not trust the proxy CA, so the default keeps GitHub’s rules in the hook.
Settings
Section titled “Settings”Send the agents’ sandboxed commands through the proxy, and open one port of one host:
sandbox: proxy_port: 18080allow: - id: example-8443 reason: the staging API listens on 8443 net: ["example.com", "example.com:8443"]- Keep the bare host in the rule: the hook decides by host alone, and a
host:portpattern matches nothing there. - With
proxy_portset, keep the proxy running (openmoat proxy install): while it is stopped, Claude Code’s sandboxed commands have no network, andopenmoat doctorandopenmoat statuswarn. - Codex passes its traffic on to the proxy only when started with
HTTP_PROXYandHTTPS_PROXYset tohttp://127.0.0.1:18080, and its API hosts then need an allow rule; it sends no session credential, so that traffic needssandbox.proxy_serve_without_credential: true, or runopenmoat run -- codexinstead (Agent sessions only). sandbox.proxy_allow_ech: truelets encrypted server names through;openmoat policy lintwarns about both settings.
Limits
Section titled “Limits”- It checks the host, not what is sent inside HTTPS, except for a
requests:host it terminates, where it checks the method and path but never the body. Any other allowed host can receive whatever a command sends it. - HTTPS is decrypted only for the host of a
tls: terminatesecret insideopenmoat run, and for arequests:host a proxy CA covers, for the sessions above. Elsewhere a brokered secret goes into plain-HTTP requests only, and an HTTPS request keeps the placeholder (Where it works today). - Only Claude Code’s sessions get a credential for the standalone proxy. Codex’s proxy sends none, so its traffic is refused unless
sandbox.proxy_serve_without_credential: trueserves it, with no session and no taint; Cursor’s sandboxed commands never reachopenmoat proxy. - No user service on Windows yet:
openmoat proxy installandstatusrefuse; runopenmoat proxyin a terminal.
More in Limits.