Skip to content

fix: replace hardcoded DB passwords and session secret with placeholders#2402

Open
saaa99999999 wants to merge 1 commit into
songquanpeng:mainfrom
saaa99999999:fix/hardcoded-defaults
Open

fix: replace hardcoded DB passwords and session secret with placeholders#2402
saaa99999999 wants to merge 1 commit into
songquanpeng:mainfrom
saaa99999999:fix/hardcoded-defaults

Conversation

@saaa99999999

Copy link
Copy Markdown

问题

docker-compose.yml 中提交了 4 个硬编码凭据:

# Line 15: 数据库连接密码
SQL_DSN=oneapi:123456@tcp(db:3306)/one-api

# Line 17: session 加密密钥
SESSION_SECRET=random_string

# Line 46: MySQL root 密码
MYSQL_ROOT_PASSWORD: 'OneAPI@justsong'

# Line 48: MySQL 用户密码
MYSQL_PASSWORD: '123456'

其中 SESSION_SECRET=random_string 的值正是 common/init.go:41 检测到会发出警告的示例值。DB 密码 123456OneAPI@justsong 可直接用于连接数据库。

修复

4 个硬编码值替换为 change-me 占位符,同时更新 common/init.go 中的检测逻辑。

Copilot AI review requested due to automatic review settings May 24, 2026 11:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates default docker-compose and runtime validation to avoid shipping real/default secrets by switching to explicit placeholder values that must be changed before deployment.

Changes:

  • Replaces default MySQL/DSN credentials and session secret in docker-compose.yml with change-me placeholders.
  • Updates startup check in common/init.go to warn when SESSION_SECRET is still set to the placeholder value.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
docker-compose.yml Replaces bundled default passwords/secrets with placeholders to reduce accidental insecure deployments.
common/init.go Aligns the example-value warning check with the new SESSION_SECRET placeholder.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docker-compose.yml
Comment on lines +15 to +17
- SQL_DSN=oneapi:change-me@tcp(db:3306)/one-api # 修改此行,或注释掉以使用 SQLite 作为数据库
- REDIS_CONN_STRING=redis://redis
- SESSION_SECRET=random_string # 修改为随机字符串
- SESSION_SECRET=change-me # 修改为随机字符串
Comment thread docker-compose.yml
Comment on lines +46 to +48
MYSQL_ROOT_PASSWORD: 'change-me' # 设置 root 用户的密码
MYSQL_USER: oneapi # 创建专用用户
MYSQL_PASSWORD: '123456' # 设置专用用户密码
MYSQL_PASSWORD: 'change-me' # 设置专用用户密码
Comment thread common/init.go
Comment on lines 40 to 44
if os.Getenv("SESSION_SECRET") != "" {
if os.Getenv("SESSION_SECRET") == "random_string" {
if os.Getenv("SESSION_SECRET") == "change-me" {
logger.SysError("SESSION_SECRET is set to an example value, please change it to a random string.")
} else {
config.SessionSecret = os.Getenv("SESSION_SECRET")
Comment thread common/init.go
Comment on lines +41 to 42
if os.Getenv("SESSION_SECRET") == "change-me" {
logger.SysError("SESSION_SECRET is set to an example value, please change it to a random string.")
@saaa99999999

Copy link
Copy Markdown
Author

CVE Request

This PR fixes CWE-798 (Use of Hard-coded Credentials) vulnerabilities:

  1. Hardcoded DB credentials: oneapi:123456 in docker-compose.yml
  2. Hardcoded session secret: SESSION_SECRET=random_string in docker-compose.yml
  3. Hardcoded MySQL root password: MYSQL_ROOT_PASSWORD: 'OneAPI@justsong' in docker-compose.yml

These hardcoded credentials are present in the repository's default Docker Compose configuration and affect all deployments that use the default config.

Request: After merging this PR, please create a GitHub Security Advisory on the official repository to request a CVE ID through GitHub's CNA program.

For reference:

  • CWE-798: Hardcoded database and session credentials
  • CVSS 3.1: 9.8 (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)
  • Impact: Default database credentials allow direct database access. Default session secret allows session forging and authentication bypass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants