Описание
9router: Unauthenticated /v1 proxy access via Host-header spoofing → open AI relay + SSRF
Summary
9router's request guard decides a request is "local" (and therefore exempt from API-key auth on the /v1 LLM proxy) by reading the client-controlled Host header. Because 9router binds 0.0.0.0 by default (and the CLI misleadingly prints "localhost"), a remote, unauthenticated attacker who can reach the port can send Host: localhost to be treated as local and obtain /v1 proxy access with no API key, no CLI token, and no dashboard login. In the default configuration (requireApiKey is absent from DEFAULT_SETTINGS, so the handler-side key check is skipped), this yields:
-
Open AI relay — the proxy forwards the attacker's requests to AI providers using the victim's stored paid API keys (cost/quota theft, prompt-based data exfiltration through the victim's accounts).
-
Unauthenticated SSRF —
/v1/searchwith the built-innoAuthsearxngprovider takes its outbound fetch URL from the request body (provider_options.baseUrl), so the attacker drives a server-side fetch to any internal/cloud-metadata host and gets the JSON response reflected back. -
Affected:
9router <= 0.4.80(current),src/dashboardGuard.js(isLocalRequest),src/sse/handlers/{chat,search}.js,src/lib/db/repos/settingsRepo.js,cli/cli.js. -
Distinct from the existing advisories GHSA-fhh6-4qxv-rpqj (MCP-plugin RCE, patched) and GHSA-xrrh-p7f2-27vm (legacy
<0.3.75authz bypass).
Details
The bypass (src/dashboardGuard.js)
isLocalRequest never consults the socket peer address — only the spoofable Host header (and an absent/loopback Origin). The /v1,/v1beta,/api/v1,/api/v1beta prefixes are gated solely by canAccessPublicLlmApi.
Default exposure
cli/cli.js:63const DEFAULT_HOST = "0.0.0.0";andDockerfileENV HOSTNAME=0.0.0.0/EXPOSE 20128→ reachable from the network by default.cli/cli.js:500,541display"localhost"even when bound to0.0.0.0— operators believe it's local-only.src/lib/db/repos/settingsRepo.jsDEFAULT_SETTINGShas norequireApiKey→ the handler key checks (chat.jsif (settings.requireApiKey),search.jssame) are skipped by default.
Relay chain (verbatim trace, 0.4.71)
middleware (src/proxy.js, matcher covers all paths) → canAccessPublicLlmApi true via spoofed Host → next.config.mjs rewrites /v1/:path*→/api/v1/:path* → src/app/api/v1/messages/route.js POST → handleChat (no independent auth) → only gate falsy requireApiKey → getProviderCredentials() loads the victim's stored credentials → handleChatCore outbound fetch → response returned. No downstream key gate.
SSRF chain
search.js (only gate falsy requireApiKey) → searxng noAuth:true ⇒ handleSearchCore({credentials:null}) → coreBody.provider_options = body.provider_options → callers.js:
→ buildSearxngRequest appends /search?q=...&format=json&categories=general → fetch(url) (server-side) → JSON reflected to caller.
PoC
Ground-truth, no network egress: harness/hostspoof.mjs (verbatim guard logic) and harness/ssrf_search.mjs (imports the real handleSearchCore + AI_PROVIDERS.searxng).
Guard bypass (hostspoof.mjs, exit 2):
SSRF (ssrf_search.mjs, real imported code):
Live confirmation against a RUNNING 9router (real HTTP, not just source/harness)
Built & ran 9router@0.4.71 (Next.js 16.2.9, bound 0.0.0.0:20128, default settings, no provider configured, no api key/login). Attacker = a request to the box's non-loopback LAN IP 10.204.111.34 (a genuine remote peer); only the Host header differs between the control and the attack:
Changing only the Host header (401 → reaches the handler), from the same remote peer, is the entire bypass — confirmed live on a default-config running instance. (Full SSRF response reflection requires the upstream to return searxng-shaped JSON; otherwise it is a blind/semi-blind SSRF — the server-side request to the attacker URL is the proven primitive. The relay needs ≥1 configured provider — the normal state — to actually spend the victim's key.) See repro/LIVE-EVIDENCE.txt.
Reproduce (against a network-reachable 9router; VICTIM_IP = the box):
Impact
Any 9router reachable on a network (default 0.0.0.0 bind, plus Docker -p, tunnel, or tailscale — all first-class features) can be:
- used as a free AI relay billed to the victim's provider accounts, exhausting quota and exfiltrating data through their keys; and
- used to reach internal services / cloud metadata (
169.254.169.254) with the response reflected to the attacker. Unauthenticated, no user interaction, default configuration. The only precondition is the normal one (≥1 configured provider).
Recommended fix
- Determine "local" from the socket peer IP, never the
Hostheader — treat as local only if the TCP peer is127.0.0.0/8/::1. - Bind
127.0.0.1by default; require an explicit, warned opt-in for0.0.0.0; fix the CLI to not print "localhost" when bound to all interfaces. - For any non-loopback peer, require a valid API key regardless of
requireApiKey; addrequireApiKey: truetoDEFAULT_SETTINGS(fail-closed). - Validate
provider_options.baseUrlagainst an allowlist (or drop the override) and block requests to private/link-local ranges inresolveBaseUrl. - Remove
Access-Control-Allow-Origin: *from/v1GET metadata routes.
Пакеты
9router
< 0.5.2
0.5.2
EPSS
8.2 High
CVSS3
CVE ID
Дефекты
Связанные уязвимости
9Router is an AI router & token saver. Prior to 0.5.2, 9router determines whether a /v1 LLM proxy request is local by reading the client-controlled Host header, allowing a remote unauthenticated attacker to send Host: localhost and bypass API-key authentication. In the default configuration, this exposes the /v1 proxy to upstream provider calls using stored provider credentials and allows /v1/search with the searxng provider_options.baseUrl parameter to drive server-side requests to internal or cloud-metadata hosts. This issue is fixed in version 0.5.2.
EPSS
8.2 High
CVSS3