boardx / boardx/workspacex

security/devops: 密钥不许走 argv(一次真实泄露的根因)+ 轮换手册

Open
#2,850 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
0
Forks
0
Avg merge
1h 7m
Merged PRs (30d)
969

Description

## 背景(含一次真实泄露)

`deploy.sh` 把 deploy.env 的全部变量**展开在命令行上**传给 compose:

```bash
sudo -u "$RUN_AS" env $(grep -v '^#' "$ENV_FILE" | xargs) ... docker compose ...
```

这个形态本身就让密钥出现在 `ps`、`SUDO_COMMAND`、sudo 审计日志里。2026-09-06 它进一步
变成一次**真实泄露**:有人在续行之间插了一段注释,shell 于是把命令截断,`env` 没拿到
任何命令、退化成"打印当前环境",把 `SUDO_COMMAND=...`(含 DB 口令、S3 密钥、模型
API key、`MODEL_CREDENTIAL_KEY`…)原样打进了公开的 CI 日志。

续行那条已经加了机械门控(`deploy-image-freshness.test.ts`),但**根因是密钥走 argv**。

## 要做什么

1. 改用 `--env-file` / `EnvironmentFile=` 传密钥,删掉 `env K=V cmd` 这种形态;
(compose 原生支持 `--env-file`;`sudo -u` 那层用 `env -i` + 文件加载。)
2. 加一条机械门控:`deploy.sh` / `provision.sh` 里不许出现"把 ENV_FILE 展开进命令行"
的写法(反证:把旧写法加回去必须红);
3. 部署脚本的诊断输出统一过脱敏(`deploy-readiness.sh` 已有 `scrubSecrets` 的先例,
复用它,不要再写一份);
4. 补一份**轮换手册**:哪些键、怎么换、换完要重启什么。
⚠ 必须写明 `MODEL_CREDENTIAL_KEY` 轮换会让已入库的加密模型凭据解不开,需要连带重录。

## 本次泄露的处置(另行跟进,不在本 issue 的代码范围)

run 34031167891 的 deploy job 日志里有明文密钥,需要删除该 run 日志并轮换:
`APP_DB_PASSWORD`、`MIGRATION_DB_PASSWORD`、`S3_ACCESS_KEY_ID`/`S3_SECRET_ACCESS_KEY`、
`EMAIL_VERIFICATION_SECRET`、`CLOUDFLARE_EMAIL_API_TOKEN`、`KERNEL_ASR_API_KEY`、
`KERNEL_MODEL_API_KEY`、`MODEL_CREDENTIAL_KEY`。

## 参考

- `.harness/instructions/deployment-verification-standard.md` 第五节

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading deploy.sh and provision.sh, then review deploy-image-freshness.test.ts and the fifth section of .harness/instructions/deployment-verification-standard.md. Use deploy-readiness.sh as the reference for scrubSecrets and inspect how the scripts currently pass ENV_FILE values. Done means secrets are not expanded into argv, the regression gate fails for the old pattern, diagnostics are scrubbed, and the rotation manual includes MODEL_CREDENTIAL_KEY consequences.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker-compose, shell, typescript
Domain
devops, documentation, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.