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

[Security] Empty Admin Credentials Still Allow Forged Admin JWTs

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

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
领域
backend, security

调研方向

Start at server/admin/src/server/middleware/auth.ts: read the key derivation (SECRET || "tailchat" plus md5 of adminAuth) and the JWT verify/platform check at lines 37-55, and compare with the login guard in server/admin/src/server/router/api.ts lines 31-35. The fix is to reject protected requests when ADMIN_PASS/SECRET are empty or default, and mirror it in server/admin-next/src/server/middleware/auth.ts (platform 'admin-next'). Done when the issue's proof-of-concept fetch to an admin endpoint returns 401 under the shipped docker-compose.env defaults, while a login with configured credentials still works.

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

描述

Empty Admin Credentials Still Allow Forged Admin JWTs

Hello Tailchat maintainers, could you review a conditional authentication bypass in the optional admin service?

Summary

With the repository's docker-compose.env defaults, SECRET and ADMIN_PASS are empty and ADMIN_USER is tailchat. The admin signing key is therefore the publicly derivable value tailchat545497b05dba745043d8f287871bfa91. The login route rejects requests because the password is empty, but protected admin routes still accept a JWT signed with this key and containing platform: "admin".

Details

Reviewed revision: 89ab8bba033603415f46fc228b5771d99daa6a21.

Image

auth.ts derives the signing key from SECRET || "tailchat" plus md5(JSON.stringify(adminAuth)). The shipped docker-compose.env sets SECRET=, ADMIN_USER=tailchat, and ADMIN_PASS=. These values produce the key above.

Image

The inline comment says this MD5-derived suffix is intended to prevent token forgery when SECRET is unset and the admin credentials are changed. That protection relies on at least one credential being private. With the shipped defaults, both inputs are public; MD5 deterministically produces a public suffix and adds no secret entropy. This finding does not claim that every deployment with an unset SECRET is affected: deployments using non-public admin credentials derive a different key.

The login route refuses authentication when the admin password is empty (api.ts). However, the middleware only verifies the JWT and checks payload.platform === "admin"; it does not reject requests when admin credentials are unset (auth.ts). Protected endpoints include /callAction and user-management routes (api.ts). The admin service is optional and is exposed through the repository's docker/admin.yml.

The parallel admin-next middleware uses the same key derivation and accepts platform: "admin-next" (admin-next/auth.ts).

The admin service is optional and is not part of the base docker-compose.yml. Its deployment guide tells operators to set an independent ADMIN_PASS. Tailchat also documents that the default SECRET is public and must be replaced in production (environment documentation). Therefore, this finding applies when an operator enables the optional admin service but leaves both the shipped admin credentials and public fallback SECRET unchanged. The admin process does start in this configuration: startup validates MONGO_URL, not ADMIN_USER or ADMIN_PASS (index.ts). The login route is disabled, but protected API middleware still accepts the publicly forgeable admin JWT.

Proof of concept

For a deployment that enables the optional admin service and leaves the tracked docker-compose.env values unchanged, sign and send a token to a protected admin endpoint:

import jwt from 'jsonwebtoken';
import md5 from 'md5';

const authSecret =
  'tailchat' +
  md5(JSON.stringify({ username: 'tailchat', password: '' }));

const token = jwt.sign({ platform: 'admin' }, authSecret);
const response = await fetch(
  'http://localhost:11000/admin/api/user/count/summary',
  { headers: { authorization: `Bearer ${token}` } },
);
console.log(response.status, await response.text());

The request is authorized without using the admin login route or knowing an admin password.

Impact

An unauthenticated network attacker who can reach an enabled admin service under these unchanged values can impersonate an administrator and access or modify data through protected admin APIs. This is a conditional default-key issue (CWE-1394: Use of Default Cryptographic Key). It requires enabling the optional admin service while ignoring the documented requirements to set an independent admin password and replace the public production SECRET; deployments following those instructions are not affected by this specific path.

Related Works

This report is part of my ongoing security research. If you have any questions, please feel free to mention me. I would be glad to make even a small contribution to improving Tailchat's security.

主要语言
TypeScript
星标
3.6k
派生
397
平均合并
2 分钟
30 天内合并 PR
1

环境准备

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

从这里开始

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

msgbyte/tailchat 的其他 Issue

查看 msgbyte/tailchat 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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