Skip to content

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.

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:port opens 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 run the run’s, and for the standalone proxy the one Claude Code’s SessionStart hook gives each session (from 0.12.0). A request without one, from another local program or with a borrowed or expired credential, gets 407 (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 inside openmoat run into HTTPS to a host whose secret says tls: terminate, only for the requests its allow rules name (Secrets over HTTPS).

A project script, started as npm test, under openmoat run or an agent’s sandbox:

Terminal window
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:

Terminal window
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:

Terminal window
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.

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).

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"]
Terminal window
openmoat proxy ca init # a CA that covers every host a requests: entry names

The 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 whose SessionStart hook 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, HEAD and OPTIONS without 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 gh ignore SSL_CERT_FILE and do not trust the proxy CA, so the default keeps GitHub’s rules in the hook.

Send the agents’ sandboxed commands through the proxy, and open one port of one host:

sandbox:
proxy_port: 18080
allow:
- 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:port pattern matches nothing there.
  • With proxy_port set, keep the proxy running (openmoat proxy install): while it is stopped, Claude Code’s sandboxed commands have no network, and openmoat doctor and openmoat status warn.
  • Codex passes its traffic on to the proxy only when started with HTTP_PROXY and HTTPS_PROXY set to http://127.0.0.1:18080, and its API hosts then need an allow rule; it sends no session credential, so that traffic needs sandbox.proxy_serve_without_credential: true, or run openmoat run -- codex instead (Agent sessions only).
  • sandbox.proxy_allow_ech: true lets encrypted server names through; openmoat policy lint warns about both settings.
  • 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: terminate secret inside openmoat run, and for a requests: 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: true serves it, with no session and no taint; Cursor’s sandboxed commands never reach openmoat proxy.
  • No user service on Windows yet: openmoat proxy install and status refuse; run openmoat proxy in a terminal.

More in Limits.