Skip to content
Iam Issues 101

Iam Issues 101

github.com • November 29, 2026

本项目是一个开源项目,任何用户都能获取到该项目中的硬编码的JWT Secret。同时,使用JWT Secret默认值启动项目时并没有任何警告提示,所以大多数用户可能不会修改此JWT Secret默认值,这可能导致攻击者伪造任意用户的权限令牌,从而绕过认证与授权机制,访问受保护接口。

iam/configs/iam-apiserver.yaml

该项目存在可静态确定的硬编码 JWT Secret。源码文件 src/config.ts 缺失并处于 .gitignore 中,但仓库中存在示例配置文件 src/config.ts.example ,其中包含默认 secret-key ;同时,已提交至 Git 索引的编译产物 dist/config.js 中包含固定值 asfdlajsdfaf234 。

如果用户在默认部署时直接使用提交的编译产物运行项目,例如 node dist/main.js ,或基于示例文件 src/config.ts.example 创建配置但未修改默认 secret,则上述硬编码密钥可能被用于生产环境 JWT 校验流程。

服务端签发的 JWT Payload 包含以下字段:

上述字段均属于攻击者可获取、可枚举或可伪造的信息。Payload 中不存在服务端生成并在校验阶段强制验证的随机高熵字段,也未绑定服务端会话状态、Token 版本号、 jti 或 nonce 等不可伪造信息。

auth.middleware.ts 从 Authorization Header 中提取 JWT;

调用 jwt.verify 使用硬编码 secret 进行签名校验;

验签通过后,从 decoded.id 中提取用户 ID;

服务端通过该 ID 查询数据库,确认用户是否存在;

如果用户存在,则将数据库中的用户对象赋值给 req.user ;

后续业务逻辑基于 req.user 或 JWT Payload 中的身份字段进行访问控制和数据隔离。

该机制属于半状态 Token 模型。虽然服务端会额外回查数据库确认用户是否存在,但查询条件 decoded.id 完全来自攻击者可控的 JWT Payload。攻击者可以通过注册账号获取有效用户 ID,也可能猜测默认管理员 ID,例如 1 。因此,该数据库回查无法有效防止身份冒充。

auth.middleware.ts 将查询到的数据库用户对象设置为当前用户。与此同时, user.decorator.ts 在部分路由未受认证中间件保护时,也可能直接从 JWT decoded 数据中返回用户字段。

业务代码中, user.controller.ts 通过 @User(email) 和 @User(id) 装饰器消费 JWT Payload 中的身份字段,用于用户信息查询和数据更新,例如 findMe 和 update 。这意味着系统在部分场景下直接基于 JWT Payload 进行身份识别和数据隔离决策。

攻击者一旦获取硬编码 secret,即可构造携带任意有效用户 ID 的 JWT。服务端验签通过后,会将该 ID 对应的数据库用户识别为当前用户,包括管理员用户,从而导致身份冒用、认证绕过和越权访问。

可以将JWT Secret放入系统环境变量中或者禁止使用默认值启动项目。

The full story

This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.

Hardcoded JWT Secrets in Two Open-Source Projects Enable Token Forgery Two GitHub issues, both published 2026-11-29, report that open-source projects (marmotedu/iam and wxiaoqi/Spring-Cloud-Platform) ship hardcoded JWT signing secrets in their repositories. The IAM project reportedly contains the fixed value 'asfdlajsdfaf234' in a committed build artifact (dist/config.js) and a default 'secret-key' in an example config, and the report states that starting the project with these defaults produces no warning. The Spring Cloud Platform report describes a hardcoded RSA key seed ('xx1WET12^%3^(WE45') from which an attacker could reproduce the RSA key pair and forge tokens that pass RS256 verification. Per the reports, an attacker holding the secret could construct JWTs with arbitrary user IDs or identity fields, which the services would accept, enabling impersonation including of administrators. The Spring Cloud report additionally states that the gateway checks only whether a tokenId exists in Redis, not whether it belongs to the token's subject, so a valid tokenId from the attacker's own session can be reused in a forged token. The IAM report notes that the database lookup on decoded.id does not prevent impersonation because the ID comes from the attacker-controlled payload. Both reports recommend moving the secret to environment variables or refusing to start with default values. The articles are issue-tracker entries rather than CVE-assigned advisories, and no exploitation in the wild or affected user counts are reported. 68