CI jobs, AI coding agents, and sandboxed containers can make arbitrary outbound requests. A compromised dependency, a prompt injection, or a malicious build step can exfiltrate secrets, phone home, or open a reverse shell. Most teams have zero visibility into what's leaving their workloads, let alone any way to stop it.
iron-proxy is a MITM egress proxy with a built-in DNS server that sits between your untrusted workload and the internet. It enforces default-deny at the network boundary, so the workload can only reach domains you explicitly allow. Real secrets never enter the sandbox. Workloads use proxy tokens, and iron-proxy swaps in real credentials at egress, meaning a compromised workload can exfiltrate a token that's worthless outside the proxy.
Single binary. Single YAML config.
- Default-deny egress. Every outbound request is blocked unless the destination matches your allowlist. List your domains and CIDRs, everything else gets a 403.
- Upstream IP deny list. Even when a host is allowed, the proxy refuses
to dial it if its resolved address falls inside a denied CIDR — closing
the SSRF/DNS-rebinding gap where an allowlisted hostname points at IMDS
or loopback. Cloud metadata endpoints (
169.254.169.254,fd00:ec2::254, andfd20:ce::254) and loopback are denied by default; override viaproxy.upstream_deny_cidrsorIRON_PROXY_UPSTREAM_DENY_CIDRS. - Boundary-level secret injection. Workloads send proxy tokens; iron-proxy replaces them with real secrets before the request leaves. If the sandbox is compromised, the attacker gets tokens that are useless outside the proxy.
- Per-request audit trail. Every request logged as structured JSON with the full transform pipeline result: which secrets were swapped, which rules matched, what got blocked and why.
- Streaming-aware. WebSocket upgrades and Server-Sent Events are proxied natively. No special configuration for agent workloads that hold long-lived connections.
- Explicit proxy support. Optional tunnel listener for tools that natively
support proxy configuration via
HTTP_PROXY,HTTPS_PROXY, or SOCKS5 settings. - PostgreSQL MITM proxy. Optional listener that authenticates clients
against proxy-managed credentials, injects
SET ROLEon the upstream session, and rejects client attempts to mutate the role (SET ROLE, anyset_configcall, XML mapping and text-search functions that may run SQL outside the inspected statement,tablefunc,dblink,pg_background, andpg_cronSQL entry points, DO blocks, unsafe function definitions, definitions that bind functions as callbacks such asCREATE AGGREGATE, etc.) via a SQL AST walk. SQL and PL/pgSQL routine bodies are inspected recursively; dynamic PL/pgSQL and unsupported routine languages are rejected. As defense in depth, revokeEXECUTEonpg_catalog.set_configand unneededTEMPORARY/CREATEprivileges from the injected role (e.g. fromPUBLIC), grantingset_configback only to the login user that the proxy uses for session setup. The proxy always pinsstandard_conforming_strings=onandclient_encoding=UTF8on the upstream session and rejects client attempts to change them, so its SQL parser and the server agree on how statements are tokenized. Statements the bundled parser (PostgreSQL 17 grammar) cannot parse are rejected, so the upstream server's major version must not be newer than PostgreSQL 17. Pairs with PostgreSQL row-level security to give per-tenant data isolation when the application connects as a shared service-account user. Requires PgBouncer (if used) to run inpool_mode = session— transaction or statement pool modes silently rebind backends between queries and would defeat the policy. See docs.iron.sh for details.
Built for CI pipelines, GitHub Actions, AI agents (Claude Code, Cursor, Codex), and any environment where you run code you don't fully trust.
Docker images are available on Docker Hub and pre-built binaries for Linux/macOS (amd64/arm64) are on GitHub Releases.
Or build from source:
go build -o iron-proxy ./cmd/iron-proxycd examples/docker-compose
docker compose upThis starts iron-proxy and a demo client that fires five requests through the proxy. Check the logs to see allowed, blocked, and secret-rewritten requests:
docker compose logs proxyEvery request produces a structured JSON audit entry:
{
"host": "httpbin.org",
"method": "GET",
"path": "/headers",
"action": "allow",
"status_code": 200,
"duration_ms": 142,
"request_transforms": [
{ "name": "allowlist", "action": "continue" },
{
"name": "secrets",
"action": "continue",
"annotations": { "swapped": [{ "secret": "OPENAI_API_KEY", "locations": ["header:Authorization"] }] }
}
]
}Rejected requests include a rejected_by field and log at WARN level. See
Audit log format for the full schema.
iron-proxy terminates TLS by generating leaf certificates on the fly, signed by a CA you provide. Client containers must trust this CA.
mkdir -p certs
openssl genrsa -out certs/ca.key 4096
openssl req -x509 -new -nodes \
-key certs/ca.key \
-sha256 -days 3650 \
-subj "/CN=iron-proxy CA" \
-addext "basicConstraints=critical,CA:TRUE" \
-addext "keyUsage=critical,keyCertSign" \
-out certs/ca.crtiron-proxy needs a fixed IP so containers can point their DNS at it:
docker network create --subnet=172.20.0.0/24 iron-proxyCreate an env file with your secrets (keep this out of version control):
echo "OPENAI_API_KEY=sk-real-key" > .envdocker run -d --name iron-proxy \
--network iron-proxy --ip 172.20.0.2 \
-v $(pwd)/proxy.yaml:/etc/iron-proxy/proxy.yaml:ro \
-v $(pwd)/certs/ca.crt:/etc/iron-proxy/ca.crt:ro \
-v $(pwd)/certs/ca.key:/etc/iron-proxy/ca.key:ro \
--env-file .env \
ironsh/iron-proxy:latest -config /etc/iron-proxy/proxy.yamlThe simplest approach is DNS-based routing: point the container's DNS at iron-proxy and all hostname lookups resolve to the proxy IP, routing traffic through it automatically:
docker run --rm \
--network iron-proxy \
--dns 172.20.0.2 \
-v $(pwd)/certs/ca.crt:/certs/ca.crt:ro \
curlimages/curl --cacert /certs/ca.crt https://httpbin.org/getFor stronger enforcement, layer nftables rules to block non-proxy egress, or use TPROXY for kernel-level interception. See Routing traffic to the proxy for details on each approach.
| iron-proxy | Squid | mitmproxy | Envoy | |
|---|---|---|---|---|
| Default-deny egress | Built-in | Requires complex ACL config | Requires custom scripting | Requires RBAC/filter configuration |
| Secret injection | Built-in | No | No | No |
| Structured audit logging | Built-in, per-transform traces | Basic access logs | Plugin-based | Configurable access logs |
| Setup complexity | Single binary + YAML | Extensive config language | Python scripting | Complex YAML or control plane |
iron-proxy is purpose-built for one job: controlling and auditing egress from untrusted workloads. Squid can do default-deny but requires significant ACL configuration and has no concept of secret injection. mitmproxy is a great debugging tool but isn't designed for production enforcement. Envoy is a general-purpose proxy that can be configured to do parts of this, but it's far more complexity than the problem requires.
iron-proxy runs a DNS server and an HTTP/HTTPS proxy. Point your container's DNS at iron-proxy and all hostname lookups resolve to the proxy IP, routing traffic through it automatically. The proxy terminates TLS (generating leaf certs on the fly from a CA you provide), runs the request through an ordered transform pipeline, forwards it upstream, and runs the response back through the pipeline.
Container → DNS lookup → iron-proxy IP → TLS termination → transforms → upstream
Transforms run in order. Built-in transforms:
| Transform | What it does |
|---|---|
allowlist |
Permits requests to matching domains/CIDRs; rejects everything else (403). |
secrets |
Scans headers (and optionally query, path, or body) for proxy tokens and swaps in real secrets from environment variables. |
body_capture |
Records decoded request bodies of matching hosts as request_body audit fields. Observation-only; never rejects. |
iron-proxy takes a single flag: -config path/to/config.yaml. Here's the
full shape (see iron-proxy.example.yaml for a
copy-pasteable starting point):
dns:
listen: ":53"
proxy_ip: "10.16.0.1" # IP where iron-proxy is running (required)
passthrough: # Domains forwarded to OS resolver
- "*.internal.corp"
- "metadata.google.internal"
records: # Static DNS records (highest precedence)
- name: "internal.example.com"
type: A
value: "10.0.0.5"
proxy:
http_listen: ":80"
https_listen: ":443"
tunnel_listen: ":8080" # Optional CONNECT/SOCKS5 listener
max_request_body_bytes: 1048576 # 1 MiB (default)
max_response_body_bytes: 0 # uncapped (default)
tls:
ca_cert: "/etc/iron-proxy/ca.crt" # Required
ca_key: "/etc/iron-proxy/ca.key" # Required
cert_cache_size: 1000 # LRU cache for generated leaf certs
leaf_cert_expiry_hours: 72
transforms:
- name: allowlist
config:
domains:
- "api.openai.com"
- "*.anthropic.com"
cidrs:
- "10.0.0.0/8"
- name: secrets
config:
secrets:
- source:
type: env
var: OPENAI_API_KEY # Env var holding the real secret
proxy_value: "proxy-token-123" # Token the sandbox sends
match_headers: ["Authorization"]
match_body: false
require: true # Reject requests without the proxy token
rules:
- host: "api.openai.com"
log:
level: "info" # debug, info, warn, errorEverything resolves to proxy_ip by default, which is what routes traffic
through the proxy. Exceptions:
passthrough: glob patterns forwarded to the OS resolver (e.g.,*.internal.corp). Traffic to these hosts bypasses the proxy entirely.records: static A or CNAME records. Highest precedence.
Set IRON_RESPONSE_RETRY_HANDLER_URL,
IRON_RESPONSE_RETRY_COMPLETE_URL, IRON_RESPONSE_RETRY_HANDLER_TOKEN,
IRON_RESPONSE_RETRY_HANDLER_SANDBOX_ID, and a comma-separated
IRON_RESPONSE_RETRY_STATUSES list to enable externally authorized response
retries. The authorization handler receives the exact upstream scheme, authority, method,
path/query, replayability, response status and headers, trace context, and
sandbox identity. It may return request headers plus an attempt ID for one
exact replay. The completion handler then receives the replay status and
response headers selected by IRON_RESPONSE_RETRY_COMPLETION_HEADERS, which
defaults to Payment-Receipt.
Response bodies are never sent to either handler, destinations cannot change,
and connection/framing headers are rejected. Requests over
proxy.max_request_body_bytes proceed normally but are marked non-replayable;
if challenged, their original response is returned. Handler failures also
preserve the original response. Handler URLs must use HTTPS unless loopback or
IRON_RESPONSE_RETRY_HANDLER_ALLOW_HTTP=true is explicitly configured for a
trusted internal network. Redirects are rejected, and the response retry token
must be configured independently from the control-plane token. WebSocket,
gRPC, and unknown-length streaming requests bypass response retry handling.
When a trusted handler resolves inside proxy.upstream_deny_cidrs, set
IRON_RESPONSE_RETRY_HANDLER_ALLOW_CIDRS to a comma-separated list of the
narrow private CIDRs it may use. This exception applies only to the exact
configured authorize and complete endpoints; ordinary proxied traffic remains
subject to the full upstream deny list. Public, loopback, link-local, and cloud
metadata ranges cannot be added through this setting.
Default-deny. Requests must match at least one domain glob or CIDR to proceed.
Unmatched requests get a 403 Forbidden.
Domain patterns use glob matching: *.example.com matches any subdomain and
example.com itself. Matching is ASCII case-insensitive; write
internationalized domains in their punycode (xn--) form. Requests whose host
is not plain ASCII or carries an IPv6 zone identifier, whose path contains .
or .. segments (including ..; and ..\ forms), or whose request target is
not origin-form or absolute-form are rejected with 400 Bad Request before any
transform runs.
Warn mode: Set warn: true to observe what the allowlist would block without
actually enforcing it. Requests that would be rejected are allowed through but
annotated with "action": "warn" in the transform trace. This is useful for
rolling out new allowlist rules or auditing existing traffic before switching
to enforcement.
Captures HTTP request headers into audit log annotations based on host/method/path rules. This is useful for enriching audit logs with request-specific context like request IDs without modifying the proxy core.
Each annotation group specifies rules to match and headers to capture. When a
request matches any rule in a group, the specified header values are written as
header:<Name> entries in the transform trace annotations. Requests that don't
match are passed through unchanged. This transform never rejects requests.
Warning: Header values are emitted in plain text in the audit log. Only log headers that are safe to expose, such as request IDs or headers containing proxy secret tokens. Do not log headers that contain raw secrets.
transforms:
- name: annotate
config:
annotations:
- rules:
- host: "api.openai.com"
methods: ["POST"]
paths: ["/v1/*"]
headers: ["x-request-id"]
- rules:
- host: "*.anthropic.com"
headers: ["x-request-id"]Default-deny request header filter. Any request header whose canonical name is
not in the configured headers list is stripped before the request goes
upstream. Useful for blocking tracking, fingerprinting, or accidental leakage
headers (cookies, internal correlation IDs, X-Forwarded-*, etc.) that the
sandbox might attach.
Entries are matched case-insensitively against the canonical header name.
Patterns delimited by /.../ (e.g. /^X-Trace-.*$/) are case-insensitive
regular expressions, mirroring the secrets transform's match_headers
syntax.
Optional rules limit the allowlist to specific hosts/methods/paths. When
omitted, the allowlist applies to every request that reaches this transform.
When at least one header is stripped, the trace is annotated with
stripped_headers listing the removed names.
Placement: put
header_allowlistaftersecrets(so injected credentials are not stripped if not in the allowlist, you can list them) and afterannotate(so annotation reads the original headers).
transforms:
- name: header_allowlist
config:
headers:
- "Authorization"
- "Content-Type"
- "User-Agent"
- "Accept"
- "/^X-Trace-.*$/"
rules:
- host: "api.openai.com"Records the decoded request body of matching requests and surfaces it on the
audit log record in a body_capture group holding request_body and
request_body_truncated. Useful for auditing the payloads passing through the
proxy, such as the prompts a sandbox sends to an LLM provider, without
modifying the upstream traffic.
Hosts, methods, and paths are matched with the same rules syntax as
allowlist and secrets. max_request_body_bytes caps how much of each body
is captured; bodies larger than the cap are truncated to the prefix and
request_body_truncated is set to true. The cap defaults to 16 KiB and is
independent of the global proxy.max_request_body_bytes limit. This transform
is observation-only: it never rejects a request, and body read errors are
annotated on the trace rather than failing the request.
On a successful capture, the transform's entry in request_transforms is
annotated with captured_bytes and truncated so the trace records that a
body was captured without duplicating the body itself.
Response bodies are not captured. Streaming responses (SSE) would have to be buffered end-to-end before forwarding, which would stall the client.
Warning: Captured bodies are written to the audit log in plain text. When
secretsruns withmatch_body: true, placebody_capturebeforesecretsso the audit log records the sandbox's proxy tokens rather than the real credentialssecretsswaps into the body.
transforms:
- name: body_capture
config:
max_request_body_bytes: 16384
rules:
- host: "api.anthropic.com"
methods: ["POST"]
paths: ["/v1/messages"]
- host: "api.openai.com"
methods: ["POST"]
paths: ["/v1/chat/completions"]The sandbox never holds real credentials. Instead:
- Configure iron-proxy with the real secret source: environment variables, a file on disk, AWS Secrets Manager, AWS Systems Manager Parameter Store, Vault KV, 1Password (service account), or 1Password Connect.
- Give the sandbox a proxy token (e.g.,
proxy-openai-abc123). - Configure the
secretstransform to map proxy tokens to those sources.
iron-proxy scans outbound requests and replaces proxy tokens with the real values before forwarding upstream. You control where it looks:
match_headers: list of header names to scan. Empty list = all headers. Literal names are matched case-insensitively, but the casing you write is preserved when the header is forwarded upstream. Entries delimited by/.../are compiled as case-insensitive regular expressions matched against canonical header names (e.g./^x-.*-key$/).match_body: scan the request body (buffered up tomax_request_body_bytes).match_query: scan the URL query string. Defaults tofalse; opt in for upstreams that expect the secret in a query parameter. Query strings often appear in access logs on either side of the proxy, so this is off by default.match_path: scan the URL path. Defaults tofalse; opt in for upstreams like Telegram that embed the secret in the path (e.g./bot<TOKEN>/sendMessage). URL paths often appear in access logs on either side of the proxy, so this is off by default.require: whentrue, requests to a matching host that do not contain the proxy token are rejected with 403. This prevents a compromised workload from bypassing the secret-swap mechanism with alternative credentials. Default:false.hosts: restrict swapping to specific domains or CIDRs.
Query parameters are always scanned.
Keeping secrets off plain HTTP. Plain HTTP can reach a transform: the HTTP
listener always starts, and the tunnel listener accepts absolute-form
http:// requests. Without a guard, a matching plain-HTTP request gets the
real secret and sends it upstream in clear text. Set require_tls: true on a
rule to make it match only requests that arrived inside TLS (MITM'd or direct
HTTPS). A plain-HTTP request then keeps its proxy token:
- name: secrets
config:
secrets:
- source: {type: env, var: OPENAI_API_KEY}
replace:
proxy_value: proxy-openai-abc123
match_headers: [Authorization]
rules:
- host: api.openai.com
require_tls: truerequire_tls defaults to false. It is accepted only by the credential
injectors, where a rule not matching means no credential is added: secrets,
aws_auth, gcp_auth, gcp_id_token, oauth_token, and hmac_sign.
gcp_auth with no rules applies to every request, so it has no rule to set
require_tls on.
require_tls does not combine with require: true. A plain-HTTP request does
not match the rule, so require does not apply to it either: the request is
forwarded even without the proxy token.
Everywhere else it is a config error. On a rule that enforces a policy
(judge, header_allowlist, grpc, body_capture, annotate, MCP policy),
plain-HTTP requests would stop matching and skip the policy. On allowlist,
the tunnel's CONNECT preflight is not TLS either, so the host would become
unreachable through the tunnel listener. On MCP gateway routes, a request that
does not match is sent to its original host instead of the route upstream.
Secret sources:
env: readsvarfrom the proxy process environment. Fixed at process start — usefileinstead if you need to rotate the value on a running proxy.file: reads the secret frompathon disk. The file is re-read on every config reload (boot and eachPOST /v1/reload) and, whenttlis set, on cache expiry — so you can rotate a running proxy's secret by rewriting the file (atomically: write-temp + rename) and reloading, without a restart. The value is the exact file contents (no trimming), so the writer controls trailing whitespace. Optionalttlandfailure_ttlare supported.aws_sm: readssecret_idfrom AWS Secrets Manager. Optionalregion,ttl, andfailure_ttlare supported.aws_ssm: readsnamefrom AWS Systems Manager Parameter Store. Optionalregion,with_decryption,ttl, andfailure_ttlare supported.with_decryptiondefaults totrue, which is the expected setting forSecureStringparameters.vault_kv: reads the secret map atpathfrom the Vault KV engine mounted atmount.kv_versionmay be1or2and defaults to2. The map is returned as JSON; setjson_keyto select one top-level string field. The official Vault client reads its address, token, namespace, TLS, and proxy settings from standardVAULT_*environment variables such asVAULT_ADDR,VAULT_TOKEN,VAULT_NAMESPACE, andVAULT_CACERT. Optionalttlandfailure_ttlare supported. This source handles static KV data only; dynamic secrets with renewable leases are not supported.1password: resolvessecret_ref(anop://vault/item/[section/]fieldreference) using a 1Password service account token. The token is read fromOP_SERVICE_ACCOUNT_TOKEN. Optionalttlandfailure_ttlare supported.1password_connect: resolves the sameop://vault/item/[section/]fieldsecret_refagainst a self-hosted 1Password Connect server. The server URL is read fromOP_CONNECT_HOSTand the API token fromOP_CONNECT_TOKEN. Optionalttlandfailure_ttlare supported.tenant_token: returns the verified tenant token attached to the current request in tenancy mode. It is only meaningful in tenancy mode: outside it, or on a request that carries no token, the source is unavailable, sorequire: truerejects andrequire: falseskips. The value is never cached because each request presents its own token.json_keyis not supported.
Region values in aws_sm, aws_ssm, and the aws_auth transform's
credentials_provider must be valid AWS region names such as us-east-1;
this validation applies in all modes.
Every source except tenant_token also accepts an optional json_key. When
set, the resolved value is parsed as a JSON object and the single top-level
string field at that key is extracted. Use it to pull one field out of a JSON
secret.
ttl controls how long a successfully fetched value is cached before refresh
(empty caches forever). failure_ttl controls how long a fetch error is
cached before retrying; it defaults to 1m and is independent of ttl, so a
long success TTL does not delay recovery from a transient backend outage.
For example, to select api_key from a KV v2 secret stored at
secret/services/openai:
source:
type: vault_kv
mount: secret
path: services/openai
json_key: api_key
ttl: 5m
failure_ttl: 15sFor production machine authentication, run Vault Agent or Vault Proxy with auto-auth and point the Vault client environment at its local listener. This keeps AppRole, Kubernetes, or cloud authentication and token renewal outside iron-proxy.
Note: a bug in
onepassword-sdk-gobreaks builds withCGO_ENABLED=0, so iron-proxy pins a fork via areplacedirective ingo.moduntil the fix lands upstream.
The judge transform calls an LLM to produce an allow/deny decision for
requests that match its URL rules. Each entry under transforms: is an
independent judge instance with its own natural-language policy, LLM backend,
timeout, semaphore, and circuit breaker. Operators can deploy zero, one, or
many judges with different prompts scoped to different rules.
- name: judge
config:
name: "github-write-guard" # required; identifies the instance in audit logs
fallback: "deny" # deny (default) | skip. No "allow" fallback ships in v1.
timeout: "8s" # per-call LLM timeout
max_concurrent: 100 # semaphore capacity; additional calls wait
circuit_breaker:
consecutive_failures: 5
cooldown: "10s"
rules: # uses the same matcher as allowlist/secrets
- host: "api.github.com"
methods: ["POST", "PATCH", "DELETE", "PUT"]
provider:
type: "anthropic" # "anthropic" or "openai"
model: "claude-haiku-4-5-20251001"
api_key_env: "ANTHROPIC_API_KEY"
max_tokens: 256
prompt: |
Natural-language policy describing what is allowed for requests that
match the rules above. Kept short and specific.Invariants:
- The judge can only reject. It never approves a request the static allowlist would have denied. Static deny always wins.
- Non-matching requests are ignored: no LLM call, no audit annotations.
- On LLM error, timeout, circuit-breaker-open, or malformed model output, the
configured
fallbackapplies.denyblocks the request (the recommended default for production).skipdefers to the rest of the pipeline; since iron-proxy is default-deny, unmatched requests are still blocked.
Pipeline ordering with the secrets transform:
- Recommended: place the judge before the secrets transform. The LLM provider sees proxy tokens, never the real credentials the workload has access to.
- Alternatively, placing the judge after secrets lets it evaluate the exact wire form that will egress, at the cost of sending real credentials to the LLM provider. Only choose this if your threat model accepts that trade.
Supported providers:
anthropic(Messages API). Usesapi_key_env,model, optionalbase_urlandmax_tokens.openai(Chat Completions API). Same fields as above; settype: openai, pointapi_key_envat the env var holding your OpenAI key, and pick a model likegpt-5.4-nano.
Audit output: every matched request adds structured fields under the transform
trace, including judge.instance, judge.decision, judge.reason,
judge.duration_ms, judge.input_tokens, judge.output_tokens,
judge.fallback_applied (when a fallback fires), and
judge.circuit_breaker_tripped (when the breaker is open).
Credits: thanks to Brex for their CrabTrap project (MIT-licensed), which informed this design.
iron-proxy can speak MCP's Streamable HTTP transport. When a request matches a configured MCP server, the proxy parses the JSON-RPC body, applies a default-deny tool allowlist, and filters tools/list responses so denied tools never reach the agent. SSE responses are filtered per event so long-lived MCP streams stay live.
This is a first-class proxy capability rather than a transform: MCP responses can be open-ended SSE streams carrying arbitrary server-initiated messages, which does not fit the request/response transform contract.
mcp:
# JSON-RPC error envelope returned to the agent on policy denial.
# Defaults: code -32001, message "blocked by iron-proxy policy".
error:
code: -32001
message: "blocked by iron-proxy policy"
servers:
- name: github # appears in audit as mcp.server
rules: # standard host/method/path rules
- host: "mcp.github.com"
paths: ["/mcp", "/mcp/*"]
tools:
- name: "search_repositories" # always allowed
- name: "create_issue"
when: # all clauses must hold; otherwise deny
- path: "owner" # dotted path against arguments
equals: "ironsh"
- path: "repo"
in: ["iron-proxy", "tunis-v2"]
# Anything not listed is denied (default-deny).Behavior:
tools/callenforcement. Calls to tools that are not in the server'stoolslist, or whoseargumentsfail anywhenclause, are rejected without reaching upstream. The proxy returns a JSON-RPC error response with the configured code and message and the request's originalid, so the MCP client sees a normal protocol error rather than an HTTP failure.tools/listfiltering. Responses totools/listhave any tool not on the allowlist removed before reaching the agent. Works for bothapplication/jsonandtext/event-streamresponses; SSE filtering operates per event so heartbeats and other messages on the stream pass through untouched.- Argument matching. Each
whenclause has a dottedpath(e.g.arguments.repo,labels.0) and one ofequals(any JSON scalar),in(a list of scalars), ormatches(a regex on string values). Clauses AND together. Omittingwhenallows the tool unconditionally. - Audit. Every observed JSON-RPC message is recorded under a new
mcpsection in the audit log entry: server name, direction (requestorresponse), method, tool, decision (allow,deny, orfiltered), reason on denials, and the count of tools removed on filter events.
Pipeline ordering: the MCP interceptor runs after the transform pipeline, so allowlist still gates which hosts can be reached and secrets has already swapped proxy tokens by the time the interceptor evaluates the body.
mcp_gateway routes client-facing MCP hosts to concrete upstream servers after the MCP policy accepts the request. This lets agents call stable internal hosts while iron-proxy forwards to the real upstream and injects credentials that never enter the sandbox.
Gateway routes only apply to requests that matched an MCP server. The MCP policy still enforces the tool allowlist first. If policy denies a tools/call, the gateway route is not applied and upstream is not reached.
mcp:
servers:
- name: github
rules:
- host: "github.mcp.local"
paths: ["/mcp", "/mcp/*"]
tools:
- name: "search_repositories"
mcp_gateway:
routes:
- name: github
rules:
- host: "github.mcp.local"
paths: ["/mcp", "/mcp/*"]
upstream: "https://mcp.github.com/v1"
credentials:
- source:
type: env
var: GITHUB_MCP_TOKEN
inject:
header: Authorization
formatter: "Bearer {{ .Value }}"Credentials use the same secret sources as the secrets transform. They are required by default. Set require: false on a credential to skip it when unavailable. Audit logs record the route, upstream URL, and credential injection locations, but never the injected credential values.
Limitations in v1:
- Only Streamable HTTP transport is supported. The legacy HTTP+SSE transport (separate
/messagesand/sseendpoints) is not. - A JSON-RPC batch with any denied entry is rejected as a whole batch; partial-batch forwarding is not supported.
- Resources and prompts are not enforced. Agents can still call
resources/list,resources/read, etc. without policy filtering.
Transforms that inspect or forward request/response bodies (secrets body matching, gRPC transforms) operate on buffered bodies. Two global settings control the maximum buffer sizes:
max_request_body_bytes(default:1048576/ 1 MiB): caps how much of the request body is buffered for transforms. Data beyond this limit is truncated from the transform's perspective but still forwarded to upstream.max_response_body_bytes(default:0/ uncapped): caps how much of the response body is buffered. Set to0to buffer the full response, which is the right default for most workloads (e.g., npm packages, model weights).
Bodies are buffered incrementally as transforms read them, and automatically rewound between pipeline stages. If a transform doesn't read the body, no buffering occurs and the body streams through untouched.
The tunnel listener accepts absolute-form HTTP proxy requests, HTTP CONNECT,
and SOCKS5 connections on a dedicated port. This is useful for tools that
natively support proxy configuration via HTTP_PROXY/HTTPS_PROXY/ALL_PROXY
environment variables or SOCKS5 settings, rather than relying on DNS-based
routing.
To enable it, set tunnel_listen under proxy:
proxy:
tunnel_listen: ":8080"When omitted, the tunnel listener is disabled.
All protocols go through the same transform pipeline as regular HTTP/HTTPS requests. Absolute-form HTTP requests are handled by the normal HTTP proxy path. For CONNECT and SOCKS5, the proxy evaluates a synthetic CONNECT request against your allowlist and secrets transforms, so tunnel connections are subject to the same default-deny policy.
After the CONNECT or SOCKS5 handshake, the proxy peeks at the first byte to detect the inner protocol:
- TLS (0x16): performs MITM the same way as the HTTPS listener, generating a leaf cert on the fly so transforms can inspect and rewrite the request.
- Plain HTTP: serves the request directly through the transform pipeline.
HTTP CONNECT example:
curl -x http://172.20.0.2:8080 \
--cacert /certs/ca.crt \
https://httpbin.org/getPlain HTTP proxy example:
curl -x http://172.20.0.2:8080 \
http://httpbin.org/getSOCKS5 example:
curl --socks5-hostname 172.20.0.2:8080 \
--cacert /certs/ca.crt \
https://httpbin.org/getYou can also set the standard environment variables so all tools route through the tunnel automatically:
export HTTP_PROXY=http://172.20.0.2:8080
export HTTPS_PROXY=http://172.20.0.2:8080
export ALL_PROXY=socks5h://172.20.0.2:8080The SOCKS5 implementation supports no-auth only and accepts IPv4, IPv6, and domain name address types.
iron-proxy generates leaf certificates on the fly, signed by the CA you provide.
The client container must trust this CA (add it to the system trust store or pass
it via --cacert). Certs are cached in an LRU cache keyed by SNI hostname.
There are three approaches, with increasing enforcement.
Point the container's DNS at iron-proxy. All lookups resolve to the proxy IP, so HTTP/HTTPS traffic flows through it naturally. This is what the Docker Compose example uses:
services:
client:
dns:
- 172.20.0.2 # iron-proxy IPEasy to set up but easy to bypass: the workload can hardcode IPs or use its own DNS resolver to skip the proxy entirely.
Layer an nftables firewall on top of DNS routing. DNS still steers traffic to the proxy, but nftables ensures the workload can't talk to anything else, even with hardcoded IPs.
The examples/nftables directory has a working setup.
The client container loads firewall rules on startup before running any
application traffic:
nftables.conf allows traffic to the proxy, drops everything else:
table ip iron {
chain output {
type filter hook output priority 0; policy drop;
# allow loopback
oif lo accept
# allow traffic to the proxy itself (DNS + HTTP/HTTPS)
ip daddr 172.20.0.2 tcp dport { 80, 443 } accept
ip daddr 172.20.0.2 udp dport 53 accept
# allow established/related (return traffic)
ct state established,related accept
# log and drop everything else
log prefix "iron-proxy-drop: " drop
}
}
docker-compose.yml: the client image is built with nftables
pre-installed. The entrypoint loads the rules, then runs the demo.
CAP_NET_ADMIN is required to load the rules:
services:
proxy:
# ... same as DNS example ...
networks:
demo:
ipv4_address: 172.20.0.2
client:
build:
context: .
dockerfile: Dockerfile.client # alpine + curl + nftables
dns:
- 172.20.0.2
cap_add:
- NET_ADMIN
volumes:
- ./nftables.conf:/etc/nftables.conf:ro
- certs:/certs:ro
networks:
demo:
ipv4_address: 172.20.0.4In a production setup you'd load the rules in an entrypoint wrapper and then
exec your actual process as a non-root user without CAP_NET_ADMIN.
For environments where you can't control the workload's DNS at all, nftables TPROXY can redirect traffic at the kernel level without any cooperation from the workload. This intercepts packets in the PREROUTING chain and hands them directly to iron-proxy:
table ip iron {
chain prerouting {
type filter hook prerouting priority mangle; policy accept;
# redirect HTTP/HTTPS to iron-proxy via TPROXY
tcp dport 80 tproxy to 172.20.0.2:80 meta mark set 1 accept
tcp dport 443 tproxy to 172.20.0.2:443 meta mark set 1 accept
}
chain output {
type route hook output priority mangle; policy accept;
# mark locally-originated packets for policy routing
tcp dport { 80, 443 } meta mark set 1
}
}
This requires ip rule and ip route setup to route marked packets to a
local socket, plus iron-proxy must bind with IP_TRANSPARENT. This is more
complex to set up but provides the strongest guarantee that traffic can't
bypass the proxy. TPROXY operates below DNS, so it catches hardcoded IPs,
custom resolvers, and anything else the workload might try.
The examples/docker-compose directory contains a
working setup. The key pieces:
docker-compose.yml: proxy and client on a shared bridge network. Real secrets are set as env vars on the proxy container only:
services:
proxy:
build:
context: ../..
dockerfile: examples/docker-compose/Dockerfile
environment:
- OPENAI_API_KEY=sk-real-openai-key-do-not-share
- INTERNAL_TOKEN=real-internal-secret-value
volumes:
- certs:/certs
networks:
demo:
ipv4_address: 172.20.0.2
client:
image: alpine:latest
dns:
- 172.20.0.2 # Point DNS at the proxy
volumes:
- certs:/certs:ro
networks:
demo:
ipv4_address: 172.20.0.4proxy.yaml allowlists httpbin.org and icanhazip.com, swaps two
secrets:
transforms:
- name: allowlist
config:
domains:
- "httpbin.org"
- "icanhazip.com"
cidrs:
- "172.20.0.0/24"
- name: secrets
config:
secrets:
- source:
type: env
var: OPENAI_API_KEY
replace:
proxy_value: "proxy-openai-abc123"
match_headers: ["Authorization"]
match_query: true # scan the query string
rules:
- host: "httpbin.org"
- source:
type: env
var: INTERNAL_TOKEN
proxy_value: "proxy-internal-tok"
match_headers: [] # scan all headers
rules:
- host: "httpbin.org"The client script sends five requests to demonstrate each behavior:
# 1. Allowed request
curl https://httpbin.org/get
# 2. Blocked request (not in allowlist)
curl https://example.com/
# 3. Secret swap: proxy token replaced with real key in Authorization header
curl -H "Authorization: Bearer proxy-openai-abc123" https://httpbin.org/headers
# 4. Secret swap: proxy token in custom header
curl -H "X-Internal: proxy-internal-tok" https://httpbin.org/headers
# 5. Secret swap: proxy token in query parameter
curl "https://httpbin.org/get?token=proxy-openai-abc123&q=hello"Every proxied request produces a structured JSON log entry:
{
"host": "httpbin.org",
"method": "GET",
"path": "/headers",
"action": "allow",
"status_code": 200,
"duration_ms": 142,
"request_transforms": [
{
"name": "allowlist",
"action": "continue"
},
{
"name": "secrets",
"action": "continue",
"annotations": {
"swapped": [{ "secret": "OPENAI_API_KEY", "locations": ["header:Authorization"] }]
}
}
],
"response_transforms": []
}Rejected requests include a rejected_by field and log at WARN level.
Audit events can be exported as OpenTelemetry structured log records for
offline analysis in backends like Axiom, ClickHouse, or Logfire. Set
OTEL_EXPORTER_OTLP_ENDPOINT to enable:
docker run -d --name iron-proxy \
-e OTEL_EXPORTER_OTLP_ENDPOINT=https://logfire-us.pydantic.dev \
-e OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf \
-e OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer <token>" \
-e OTEL_SERVICE_NAME=iron-proxy \
-e OTEL_RESOURCE_ATTRIBUTES="deployment.environment=staging" \
# ... other flags ...
ironsh/iron-proxy:latest -config /etc/iron-proxy/proxy.yamlAll configuration uses standard OTEL environment variables:
| Variable | Description | Default |
|---|---|---|
OTEL_EXPORTER_OTLP_ENDPOINT |
OTLP collector URL. OTEL export is disabled when unset. | (disabled) |
OTEL_EXPORTER_OTLP_PROTOCOL |
http/protobuf or grpc. |
http/protobuf |
OTEL_EXPORTER_OTLP_HEADERS |
Comma-separated key=value pairs for auth headers. |
(none) |
OTEL_SERVICE_NAME |
Service name attached to all log records. | iron-proxy |
OTEL_RESOURCE_ATTRIBUTES |
Comma-separated key=value resource attributes. |
(none) |
When enabled, every audit event is emitted as an OTEL log record alongside the
existing JSON stderr logs. The log record carries the same schema as the JSON
audit entry: host, method, path, action, status_code, duration_ms,
and the full request_transforms/response_transforms arrays with annotations.
iron-proxy can optionally expose an authenticated HTTP API for operational
tasks. Currently it serves a single endpoint, POST /v1/reload, which re-reads
the YAML config from disk and atomically swaps in a freshly built transform
pipeline. The running pipeline is preserved if the new config is invalid.
The management server is disabled by default. To enable, add a management
block to your config:
management:
# Bind on loopback unless you front this with a private network or auth proxy:
# /v1/reload can rebuild the entire transform pipeline.
listen: "127.0.0.1:9092"
# Env var that holds the bearer token. Defaults to IRON_MANAGEMENT_API_KEY.
api_key_env: "IRON_MANAGEMENT_API_KEY"Standalone mode only — incompatible with control-plane managed mode.
Reload a running proxy:
curl -X POST http://127.0.0.1:9092/v1/reload \
-H "Authorization: Bearer $IRON_MANAGEMENT_API_KEY"Tenancy mode runs one proxy for many tenants. Each tenant presents a tenant token minted by the control plane's API, and iron-proxy runs its traffic through the config the control plane returns for that token. The proxy does not decide what a tenant may do; it verifies the token and applies the config the control plane supplies for it.
Tenancy requires the tunnel listener and MITM TLS. It refuses to start if the
Postgres or SSH listener is configured, or alongside control-plane managed mode
(IRON_PROXY_TOKEN). Enable it in the config:
tenancy:
enabled: true
token:
issuer: "https://api.iron.sh" # Required `iss` claim
audience: "iron-proxy" # Required `aud` claim
config:
url: "https://control-plane.example/tenant-config" # Required
fresh_for: 1m # Default: 1m
stale_for: 10m # Default: 10m; must be at least fresh_fortenancy.config.url may use http for an in-cluster control plane. Both the
proxy's control-plane token and the tenant token travel on that hop, so prefer
https or a private network; over plain http they are sent in cleartext.
The Ed25519 public keys that verify tenant tokens come from
IRON_TENANT_PUBLIC_KEYS, never the config file. The value is one or more
SPKI PEM PUBLIC KEY blocks; more than one key allows rotation.
IRON_TENANCY_ENABLED, IRON_TENANCY_TOKEN_ISSUER,
IRON_TENANCY_TOKEN_AUDIENCE, and IRON_TENANCY_CONFIG_URL override the
corresponding config fields. The proxy authenticates to the config endpoint
with the credential in IRON_TENANCY_CONTROL_PLANE_TOKEN, which is required
when tenancy is enabled.
A tenant's pipeline runs the YAML transforms first, then the tenant's own
config, so proxy-wide transforms apply to every tenant.
A tenant opens a tunnel through the tunnel listener with
Proxy-Authorization: Bearer <tenant token> on the CONNECT:
curl -x http://172.20.0.2:8080 \
-H "Proxy-Authorization: Bearer $TENANT_TOKEN" \
--cacert /certs/ca.crt \
https://httpbin.org/getA token is an EdDSA/Ed25519 JWT. It must carry the configured iss and aud,
a non-empty sub, and an exp; nbf and iat are checked when present.
Claims are checked with 30 seconds of clock-skew leeway. The token must expire
no more than 24 hours ahead (plus that leeway), and any exp, nbf, or iat
that is negative, non-finite, or beyond the proxy's accepted range is refused.
The token establishes the tunnel. Every request inside it resolves its tenant
again, so a refresh after fresh_for and a control-plane refusal both take
effect on the tunnel's next request. Token expiry is checked on each request
as well. Long-lived streams already in progress (WebSocket, SSE) are not cut.
Absolute-form http:// requests on the tunnel listener are authenticated
individually, and Proxy-Authorization is removed before any transform sees
the request in both cases. SOCKS5 is refused during method negotiation because
it has no place for a bearer token, and that refusal is audited. The plain
HTTP and HTTPS listeners refuse every request because it did not arrive
through a tenant's tunnel.
Refusals carry X-Iron-Proxy-Error:
| Status | X-Iron-Proxy-Error |
Meaning |
|---|---|---|
| 407 | tenant_token_required |
No Bearer tenant token was presented. |
| 407 | tenant_token_invalid |
The token failed signature or claim checks. |
| 403 | tenant_refused |
The control plane answered with 403 or 404 for this tenant. |
| 503 | tenant_config_unavailable |
No usable config, and the control plane could not supply one. |
| 401 | tenant_token_expired |
The tunnel's token expired; later inner requests are refused. |
407 responses include Proxy-Authenticate: Bearer realm="iron-proxy". Requests
refused before a tenant is bound, including those on the plain listeners, are
audited as tenancy rejections without a tenant subject.
The proxy fetches a tenant's config by calling tenancy.config.url
authenticated as the proxy, with the tenant token in X-Iron-Tenant-Token
selecting whose config to return. The body is the same as a managed proxy's
sync request:
POST <tenancy.config.url>
Authorization: Bearer <IRON_TENANCY_CONTROL_PLANE_TOKEN>
X-Iron-Tenant-Token: <tenant token>
Content-Type: application/json
{"config_hash": "<last known hash, or empty on the first fetch>"}A tenant token alone must never fetch a config, because it is held by less-trusted components. The proxy credential proves the caller is the tenancy proxy; the tenant token only selects whose config comes back.
A 200 response carries the current config_hash and either the full config or
only the hash when nothing changed:
{
"config_hash": "sha256:...",
"rules": [],
"secrets": [],
"transforms": []
}rules, secrets, and transforms have the same shape as the control plane's
/api/v1/proxy/sync response. A hash-only response is accepted only for a
config_hash that token was already served; any other hash-only answer is
treated as a failure.
- 401: the control plane refused the proxy's credential. This is an
availability failure, not a statement about the tenant: keep serving the
last good config while it is younger than
stale_for, otherwise answer 503. - 403 or 404: the tenant is refused and its cached config is evicted.
- Any other failure (other status, timeout, invalid body, or a pipeline
that fails to build): keep serving the last good config while it is younger
than
stale_for; otherwise answer 503.
Refusals (403/404) and failures that leave a token with no usable config are
remembered for the negative-cache window and then retried. A pipeline that
fails to build is logged with its config_hash but not the error text, which
can quote config values.
Configs are cached per token, and pipelines are keyed by a digest the proxy
computes over the rules, secrets, and transforms it received, so every
token served byte-identical config shares one pipeline. The control plane's
config_hash is used only for conditional refreshes; it never selects a
pipeline. The first request for a token fetches its config; requests within
fresh_for reuse it. After that, the next request refreshes it conditionally
with config_hash while concurrent requests continue using the current
pipeline. Only one fetch runs per token at a time.
Idle tokens and unused pipelines are evicted after 15 minutes, expired tokens are pruned, and the cache holds at most 10,000 tokens. When a fetch fails and the token has no usable config to fall back on, the failure — including a control-plane refusal or a pipeline that fails to build — is remembered for five seconds so a failing control plane is not hammered. Control-plane responses are capped at 16 MiB.
Tenant configs are restricted before their pipeline is built. Only the
credential transforms — oauth_token, gcp_auth, gcp_id_token, aws_auth,
and hmac_sign — may appear in transforms; every other transform is dropped
with a logged reason, so a tenant's allowlist comes only from its rules. A
secrets entry's source type, and any type anywhere in a kept transform's
config, must be one of control_plane, tenant_token, 1password,
1password_connect, aws_sm, or aws_ssm; the only credentials provider
tenants may use is workload_identity. Any other type — env, file,
vault_kv, judge providers, or a type added later — is dropped, as is any
transform config with a GCP keyfile_path. For oauth_token, only the
offending token entries are dropped. Checks read exact keys, and kept entries
are re-encoded from what was checked, so duplicate or case-variant keys cannot
slip a different source past the check.
In tenancy mode the guarded outbound dialer is installed for transforms and
secret sources, because tenant configs choose those destinations. Their own
calls — OAuth and GCP token endpoints, AWS STS, Secrets Manager and SSM, Vault,
1Password Connect, judge LLM providers, and the gRPC transform — dial directly
through the same proxy.upstream_deny_cidrs guard as upstream requests. These
dialer-backed calls do not use environment proxies, since a proxy would hide
the real destination from the guard. The default deny list includes the cloud
instance metadata addresses, so EC2 IMDS credentials are unavailable to a
tenant workload_identity provider, and aws_sm/aws_ssm (which use the same
default credential chain) cannot fall back to them. IRSA still works because
its STS call is an ordinary public endpoint through the guard. EKS Pod Identity
still works because the AWS SDK fetches its local agent credentials with its
own client, which the guard does not cover. GKE's metadata path likewise uses
ADC's own metadata client, which the guard does not cover. The 1Password
service-account SDK cannot be guarded either. Other modes keep their existing
direct dialers.
The tenant_token secret source returns the verified token attached to the
current request. It is only available in tenancy mode on a request that
carries a token, and its value is never cached; json_key is not supported.
Requests served in tenancy mode add a tenant group to the JSON and OTEL
audit records with the token's sub and, when present, jti. The raw token is
never logged.
Need dynamic Vault secret engines, KMS backends, a Kubernetes operator, or centralized policy management? iron.sh builds on iron-proxy with enterprise features for teams running this at scale.
Release artifacts include a signed checksum manifest:
checksums.txtchecksums.txt.asc(ASCII-armored detached signature)
Use the included public key at public-key.asc to verify:
# 1) Download release artifacts for a tag
TAG=vX.Y.Z
gh release download "$TAG" --pattern "checksums.txt" --pattern "checksums.txt.asc"
# 2) Import the project signing key
gpg --import public-key.asc
# 3) Verify the signature over checksums.txt
gpg --verify checksums.txt.asc checksums.txtIf verification succeeds, GPG will report a good signature from Matthew Slipper <matt@iron.sh>.
You can optionally inspect the imported key fingerprint and confirm it matches your trusted source before verification.
To verify a specific binary against the signed checksum list (example: iron-proxy-linux-amd64):
shasum -a 256 iron-proxy-linux-amd64 | grep -F "$(grep -F 'iron-proxy-linux-amd64' checksums.txt | awk '{print $1}')"The opt-in SSH listener maps a sandbox's disposable identity onto a separately held upstream key. It supports non-interactive exec, SFTP, and wstunnel v11 WSS endpoints, with pinned SSH host identities and renewable authorization leases. HTTP and SSH share one executable and process.