Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Security] Hardcoded default JWT secret enables full API authentication bypass

未关闭
#336 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript

调研方向

Start with src/backend/utils/appConfig.ts, docs-config.yaml, src/backend/routes/auth.ts, and src/backend/routes/middlewares/token.ts, then trace the /api middleware in src/backend/routes/index.ts. Review the existing configuration and authentication tests, or add regression coverage as suggested, with completion shown by rejecting known default credentials and forged tokens.

由索引模型根据 Issue 内容生成。

描述

Hardcoded default JWT secret enables full API authentication bypass

Hello maintainers,

I found a hardcoded JWT signing key in codex.docs. The default password and secret are public, and the application concatenates them into the key used to sign and verify every authentication token. A deployment that does not override these values can be fully accessed through the protected /api routes by forging an authToken cookie.

Severity

Suggested severity: High, conditional on the deployment retaining the shipped defaults.

Weaknesses: CWE-798 (Use of Hard-coded Credentials), CWE-321 (Use of Hard-coded Cryptographic Key).

Affected reference: package version 2.3.3, current main at commit f0e14c1f143d02e040664216fdf273b6bca0c420.

Root cause

The default configuration contains the following public values (appConfig.ts#L142-L145):

'auth': {
  'secret': 'supersecret',
  'password': 'secretpassword',
},

The same values are also present in the distributed YAML configuration (docs-config.yaml#L28-L30):

auth:
  password: secretpassword
  secret: supersecret

The application uses their concatenation as the JWT key when issuing and validating tokens (auth.ts#L45-L53, token.ts#L13-L31):

const token = jwt.sign({
  iss: 'Codex Team',
  sub: 'auth',
}, appConfig.auth.password + appConfig.auth.secret);

const decodedToken = jwt.verify(
  token,
  appConfig.auth.password + appConfig.auth.secret,
);

Therefore, the effective signing key is:

secretpasswordsupersecret

The default config path is selected automatically and merged with defaultConfig (appConfig.ts#L160-L171). There is no check that rejects these known defaults.

Impact

The /api router applies verifyToken and allowEdit to every API endpoint (routes/index.ts#L13-L17). A forged token therefore passes the only authentication gate for:

The attacker does not need the configured admin password or a valid login session. Knowing the public source is sufficient to create a valid authToken cookie.

Static proof of concept

No live deployment or dynamic environment is required:

const jwt = require('jsonwebtoken');

const forgedToken = jwt.sign(
  { iss: 'Codex Team', sub: 'auth' },
  'secretpasswordsupersecret',
);

console.log(forgedToken);

Send the result as the cookie expected by the middleware:

curl -i \
  --cookie "authToken=<forged-token>" \
  http://127.0.0.1:3000/api/pages

Expected result on a deployment using the defaults: the forged token passes jwt.verify() and the request reaches the API handler. Without a valid cookie, the same request is redirected to /auth by allowEdit.

Recommended remediation

  1. Remove password and secret defaults from the tracked/distributed configuration. Commit only an example file with clearly non-operational placeholders.
  2. Require a dedicated, random JWT_SECRET from the deployment environment and fail closed when it is missing or matches a known default.
  3. Do not derive the JWT key by concatenating the administrator password with another static value.
  4. Rotate the JWT key and administrator password for every deployment that used these defaults.
  5. Add regression tests proving that the default configuration cannot start and that a token signed with secretpasswordsupersecret is rejected.

Related works

This report is part of my ongoing security research. If you have any questions or would like me to clarify any detail, please feel free to @mention me at any time. I would be genuinely pleased to contribute, even in a small way, to improving the security of your product.

主要语言
TypeScript
星标
845
派生
88
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

codex-team/codex.docs 的其他 Issue

查看 codex-team/codex.docs 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。