Docker deployment discloses the management auth token to unauthenticated clients
TL;DR for anyone running the Docker image right now
The published management port hands its auth token to any client that requests /. That
token grants read and write access to the router configuration, and write access chains to
executing an attacker-supplied routing script. That script sees the full request body — every
prompt and response — plus the entire process.env, and can fetch() it out. So conversation
content leaks regardless of auth method, and any API keys (in the config or in env) leak too.
Until this is fixed, bind the port to loopback:
ports:
- "127.0.0.1:3458:8080" # instead of "3458:8080"The desktop/CLI path is not affected.
Affected
Docker deployment. Verified on v3.1.1 (commit f2e01bf) by static review — I did not run
the code.
The desktop/CLI path is not affected and is, for what it's worth, done well: it binds to
127.0.0.1, uses a 32-byte random token compared with timingSafeEqual, validates the
Host header against DNS rebinding, and keeps the token out of served HTML. The contrast is
the point: the UI and CLI bind to 127.0.0.1, so the token never crosses the network at all,
whereas the Docker path publishes on 0.0.0.0 and hands the token to anyone who reaches
the port.
What happens
docker/entrypoint.sh generates an nginx config that returns the management token to any
client requesting the site root:
# docker/entrypoint.sh:145
location = / {
return 302 /pages/home/index.html?ccr_web_token=${CCR_WEB_AUTH_TOKEN_QUERY};
}
# docker/entrypoint.sh:149-150
if ($arg_ccr_web_token = "") {
return 302 /pages/home/index.html?ccr_web_token=${CCR_WEB_AUTH_TOKEN_QUERY};
}The same config forges the origin headers, so the application-side origin check cannot help in this path:
# docker/entrypoint.sh:158-159
proxy_set_header Origin http://${CCR_WEB_HOST}:${CCR_WEB_PORT};
proxy_set_header Referer http://${CCR_WEB_HOST}:${CCR_WEB_PORT}/;And the shipped compose file publishes the port on all interfaces:
# docker-compose.yml:9
- "3458:8080"Impact
One unauthenticated GET / from anywhere that can reach the port returns the management
token in the Location header. That token authenticates management RPC, which allows both
reading and writing the configuration:
// packages/core/src/web/management-server.ts:318
getConfig: () => loadAppConfig(),I found no redaction in packages/core/src/web/, so any provider credentials stored in the
configuration are returned in cleartext.
To be precise about what this does not cover: providers that authenticate with a local
login — claude-code, codex, grok, kimi — read their OAuth tokens at request time from
the OS credential store (claude-code.ts:224-227, the macOS keychain item at
claude-code.ts:25), not from the router configuration, so getConfig does not return them.
Write access is the larger concern, and it chains to code execution. I traced the full path statically (I did not run it):
saveConfigaccepts the posted object withconfig as AppConfigand does not validate the routing-script contents (management-server.ts:427).- A routing rule carries its script inline as
rule.script.source(config-compiler.ts:213) — no separate file write is needed. - On the next proxied request the gateway executes that script
(
gateway-service.ts:473), with no trust/approval gate in the routing runtime that I could find. - The script runs in a
vmcontext whose bridge exposesenv()— the entireprocess.env, unfiltered (route-script-worker.ts:190) — andfetch().
So an attacker who obtained the token can, with two requests (one saveConfig, one proxied
request), read every value in process.env and POST it anywhere. In a Docker deployment that
passes provider keys via environment variables, those keys are exfiltrated over the network.
The same routing script receives the full request body, not a summary
(route-script-context.ts:39, body: cloneJson(request.body)) — every messages entry and
the system prompt. Combined with fetch(), this exfiltrates the content of every prompt and
response passing through the proxy, on the fly. This part is independent of how a provider
authenticates: conversation content flows through the proxy whether you use an API key or a
subscription login.
Provider API keys are also in scope. Providers configured with a key store it in the
configuration (config.ts:657, provider.api_key), and getConfig returns the configuration
unredacted — so the token from GET / discloses those keys directly, without the scripting
step.
Scope limit I want to be honest about: the local-login providers (claude-code, codex,
grok, kimi) keep their OAuth tokens in a file (~/.claude/.credentials.json) or the
keychain, not in process.env. The routing sandbox has no file read, and the arbitrary-path
readTextFile helper in the routing worker is not reachable over management RPC as far as I
can see, so I did not establish that those file-based credentials can be read through a
request alone. I also make no claim about escaping the vm sandbox — the env()+fetch()
bridge already suffices for the process.env case, so I did not test sandbox escape.
Reproduction
docker compose up -d
curl -sI http://<host>:3458/
# Location: /pages/home/index.html?ccr_web_token=<token>Suggested fix
Roughly in order of value:
For operators who must expose the port to another machine: the loopback bind below is not an option for you, so restrict access at the network layer instead — a host firewall rule allowing only the specific client IP, a private/VPN interface, or a reverse proxy that adds real authentication in front. The management port should never be reachable by the whole LAN. This is mitigation, not a fix; the items below are the fix.
Do not put the token in a redirect. Issue it only after an authenticated action, or set an
HttpOnlycookie scoped to the app. URLs leak into proxy logs, browser history andRefererheaders even on a trusted network.Bind the published port to loopback by default (
127.0.0.1:3458:8080) and let operators opt into wider exposure deliberately.Stop forging
Origin/Refererin the nginx config, so the existing application-side check keeps protecting the Docker path too.Redact secrets in
getConfig. Even with authentication fixed, returning every provider key in cleartext gives one leaked token a very large blast radius.
Thanks for the project, and for the care that clearly went into the desktop/CLI auth path.
Source: musistudio/claude-code-router