docs: add security vulnerability scan report
This commit is contained in:
377
docs/audits/SECURITY_VULNERABILITY_SCAN_2026-05-11.md
Normal file
377
docs/audits/SECURITY_VULNERABILITY_SCAN_2026-05-11.md
Normal file
@@ -0,0 +1,377 @@
|
||||
# 安全漏洞扫描报告 2026-05-11
|
||||
|
||||
## 扫描范围
|
||||
|
||||
- 工作区:`C:/proj/Genarrative/.worktrees/hermes-3337436a`
|
||||
- 分支:`hermes/hermes-3337436a`
|
||||
- Git 基线:扫描时存在一个未跟踪计划文件 `.hermes/plans/2026-05-11_205658-security-vulnerability-scan.md`。
|
||||
- 扫描对象:根 Node/Vite/React 依赖、`server-rs` Rust workspace 依赖入口、仓库已跟踪文件中的敏感配置、JS/TS/Rust 源码安全热点。
|
||||
|
||||
## 扫描命令与工具状态
|
||||
|
||||
已执行:
|
||||
|
||||
```bash
|
||||
pwd
|
||||
git branch --show-current
|
||||
git rev-parse --show-toplevel
|
||||
git status --short
|
||||
node --version
|
||||
npm --version
|
||||
cargo --version
|
||||
rustc --version
|
||||
rg --version
|
||||
npm audit --json
|
||||
npm audit --audit-level=moderate
|
||||
git ls-files -z | xargs -0 grep -nIE "(api[_-]?key|secret|password|passwd|token|private[_-]?key|BEGIN (RSA|OPENSSH|EC|DSA)? ?PRIVATE KEY|AKIA[0-9A-Z]{16}|xox[baprs]-|sk-[A-Za-z0-9_-]{20,})"
|
||||
rg -n "\beval\(|new Function\(|dangerouslySetInnerHTML|innerHTML\s*=|document\.write\(" src apps scripts packages
|
||||
rg -n "exec\(|execSync\(|spawn\(|spawnSync\(|shell:\s*true|child_process" scripts src apps packages
|
||||
rg -n "Command::new|std::process|\.unwrap\(|\.expect\(|fs::|File::open|PathBuf|set_header|cors|CorsLayer" server-rs/crates
|
||||
rg -n "allow_origin|Any|cookie|Authorization|Bearer|refresh|access_token|set_cookie|SameSite|Secure|HttpOnly" server-rs/crates src apps scripts
|
||||
```
|
||||
|
||||
工具版本:
|
||||
|
||||
- Node:`v22.22.2`
|
||||
- npm:`10.9.7`
|
||||
- Cargo:`cargo 1.95.0 (f2d3ce0bd 2026-03-21)`
|
||||
- Rustc:`rustc 1.95.0 (59807616e 2026-04-14)`
|
||||
- ripgrep:`15.1.0`
|
||||
- `gitleaks`:未安装,本次未执行。
|
||||
- `cargo-audit`:未安装,本次未执行;未擅自安装到用户环境。
|
||||
|
||||
原始扫描输出保存于:
|
||||
|
||||
- `.hermes/plans/assets/security-scan-2026-05-11/npm-audit.json`
|
||||
- `.hermes/plans/assets/security-scan-2026-05-11/npm-audit.txt`
|
||||
- `.hermes/plans/assets/security-scan-2026-05-11/secret-grep.txt`
|
||||
- `.hermes/plans/assets/security-scan-2026-05-11/js-xss-dynamic.txt`
|
||||
- `.hermes/plans/assets/security-scan-2026-05-11/node-command-exec.txt`
|
||||
- `.hermes/plans/assets/security-scan-2026-05-11/rust-hotspots.txt`
|
||||
- `.hermes/plans/assets/security-scan-2026-05-11/auth-cors-hotspots.txt`
|
||||
|
||||
注意:`secret-grep.txt` 可能包含敏感片段,提交前应删除或改为脱敏摘要,不建议直接进入 Git。
|
||||
|
||||
## 摘要
|
||||
|
||||
| 等级 | 数量 | 说明 |
|
||||
| --- | ---: | --- |
|
||||
| Critical | 1 | `.env.local` 被 Git 跟踪且含多项非空真实密钥/凭据形态配置。 |
|
||||
| High | 2 | npm 依赖存在 8 个 high advisory 聚合项;Vite dev server 任意文件读取类漏洞需要优先升级。另有 TypeScript ESLint 链路 ReDoS 风险。 |
|
||||
| Medium | 2 | esbuild dev server 请求读取、PostCSS CSS stringify XSS。 |
|
||||
| Low | 3 | jsdom/http-proxy-agent/@tootallnate/once 低危链路。 |
|
||||
| Unknown | 1 | Rust 依赖漏洞未完成扫描,因为本机未安装 `cargo-audit`。 |
|
||||
| Informational | 多项 | 源码热点扫描命中大量测试/脚本/unwrap/expect,需要按入口人工复核。 |
|
||||
|
||||
## Critical
|
||||
|
||||
### C-1:仓库跟踪了 `.env.local`,且包含多项非空真实密钥形态配置
|
||||
|
||||
**证据:**
|
||||
|
||||
`git ls-files --error-unmatch .env.local` 显示 `.env.local` 已被 Git 跟踪。扫描确认该文件包含多项非空密钥/凭据形态变量,包括但不限于:
|
||||
|
||||
- `LLM_API_KEY`
|
||||
- `ARK_API_KEY`
|
||||
- `ARK_CHARACTER_VIDEO_API_KEY`
|
||||
- `DASHSCOPE_API_KEY`
|
||||
- `VOLCENGINE_ACCESS_KEY_ID`
|
||||
- `VOLCENGINE_SECRET_ACCESS_KEY`
|
||||
- `ALIYUN_SMS_ACCESS_KEY_ID`
|
||||
- `ALIYUN_SMS_ACCESS_KEY_SECRET`
|
||||
- `GENARRATIVE_LLM_API_KEY`
|
||||
- `ALIYUN_OSS_ACCESS_KEY_ID`
|
||||
- `ALIYUN_OSS_ACCESS_KEY_SECRET`
|
||||
- `GENARRATIVE_ADMIN_PASSWORD`
|
||||
|
||||
报告中不记录具体值。
|
||||
|
||||
**影响:**
|
||||
|
||||
如果该文件已进入远端仓库或被团队成员拉取,相关外部服务密钥、OSS/SMS/LLM/后台密码均应视为已泄露。即使后续从当前工作树删除,也不能撤销历史泄露风险。
|
||||
|
||||
**建议修复:**
|
||||
|
||||
1. 立即轮换 `.env.local` 中出现过的所有真实密钥、访问密钥、后台密码和 token。
|
||||
2. 从 Git 跟踪中移除 `.env.local`,但不要删除本地私有文件:
|
||||
|
||||
```bash
|
||||
git rm --cached .env.local
|
||||
```
|
||||
|
||||
3. 按项目约束,不要在 `.gitignore` 中新增 `.env.local`;如果仓库已有其他机制管理本地私密 env,应遵循既有约定。若没有,应先补一份安全说明文档,而不是提交真实 `.env.local`。
|
||||
4. 将必要的占位示例保留在 `.env.example` 或 `deploy/env/api-server.env.example`,确保示例值不是可用密钥。
|
||||
5. 如该文件已推送到远端历史,评估是否需要历史清理;无论是否清历史,密钥轮换都是必须步骤。
|
||||
|
||||
**验证:**
|
||||
|
||||
```bash
|
||||
git ls-files --error-unmatch .env.local
|
||||
# 预期:返回非 0,表示不再跟踪
|
||||
|
||||
git diff --cached -- .env.local
|
||||
# 预期:只显示从索引移除,不输出真实值到公开报告
|
||||
```
|
||||
|
||||
## High
|
||||
|
||||
### H-1:Vite 依赖存在高危 dev server 任意文件读取/路径遍历类 advisory
|
||||
|
||||
**证据:**
|
||||
|
||||
`npm audit` 显示:
|
||||
|
||||
- package:`vite`
|
||||
- direct dependency:是
|
||||
- installed vulnerable range:`<=6.4.1`
|
||||
- severity:`high`
|
||||
- 相关 advisory 包括:
|
||||
- `GHSA-p9ff-h696-f583`:Vite dev server WebSocket 任意文件读取,高危。
|
||||
- `GHSA-4w7w-66w2-5vf9`:optimized deps `.map` 处理路径遍历,中危。
|
||||
- 多个 `server.fs` / public directory 相关低中危问题。
|
||||
- `fixAvailable=true`。
|
||||
|
||||
**影响:**
|
||||
|
||||
主要影响开发服务器和预览环境。如果开发机、测试机或内网联调环境将 Vite dev server 暴露给不可信网络,攻击者可能读取工作区文件或旁路 `server.fs` 限制。
|
||||
|
||||
**建议修复:**
|
||||
|
||||
1. 优先将 `vite` 升级到 npm audit 推荐的安全版本范围。
|
||||
2. 升级后执行:
|
||||
|
||||
```bash
|
||||
npm run check:encoding
|
||||
npm run lint:eslint
|
||||
npm run typecheck
|
||||
npm run test
|
||||
npm run build
|
||||
```
|
||||
|
||||
3. 检查 `scripts/vite-cli.mjs`、`scripts/dev-web-rust.mjs`、Vite 配置中的 dev server host 暴露范围,开发环境避免绑定 `0.0.0.0` 或暴露到公网。
|
||||
|
||||
### H-2:`@typescript-eslint/*` 链路经 `minimatch` 存在 ReDoS 高危 advisory
|
||||
|
||||
**证据:**
|
||||
|
||||
`npm audit` 显示:
|
||||
|
||||
- direct packages:
|
||||
- `@typescript-eslint/eslint-plugin`,当前范围 `6.16.0 - 7.5.0`,high。
|
||||
- `@typescript-eslint/parser`,当前范围 `6.16.0 - 7.5.0`,high。
|
||||
- transitive packages:
|
||||
- `@typescript-eslint/type-utils`
|
||||
- `@typescript-eslint/typescript-estree`
|
||||
- `@typescript-eslint/utils`
|
||||
- `minimatch`
|
||||
- `minimatch` advisory:
|
||||
- `GHSA-3ppc-4f35-3m26`
|
||||
- `GHSA-7r86-cg39-jmmj`
|
||||
- `GHSA-23c5-xmqv-rm74`
|
||||
- npm 建议升级到 `@typescript-eslint/* 8.59.3`,属于 SemVer major。
|
||||
|
||||
**影响:**
|
||||
|
||||
主要影响 lint/构建工具链。如果 CI 或开发命令处理不可信 glob pattern,可能造成 ReDoS。生产运行时直接影响较低,但 CI 可用性和供应链安全仍应修复。
|
||||
|
||||
**建议修复:**
|
||||
|
||||
1. 单独开依赖升级分支,将 `@typescript-eslint/eslint-plugin` 与 `@typescript-eslint/parser` 升级到兼容 ESLint 8/TypeScript 5.8 的安全版本。
|
||||
2. 因为是 major 升级,先阅读迁移说明并运行 ESLint 全量检查。
|
||||
3. 验证:
|
||||
|
||||
```bash
|
||||
npm run lint:eslint
|
||||
npm run typecheck
|
||||
npm run test
|
||||
```
|
||||
|
||||
### H-3:`picomatch` ReDoS / glob matching 高危 advisory
|
||||
|
||||
**证据:**
|
||||
|
||||
`npm audit` 显示:
|
||||
|
||||
- package:`picomatch`
|
||||
- severity:`high`
|
||||
- vulnerable range:`4.0.0 - 4.0.3`
|
||||
- advisory:
|
||||
- `GHSA-c2c7-rcm5-vvqj`:extglob quantifiers ReDoS,高危。
|
||||
- `GHSA-3v7f-55p6-f55p`:POSIX character classes method injection,中危。
|
||||
- `fixAvailable=true`。
|
||||
|
||||
**影响:**
|
||||
|
||||
主要影响依赖 picomatch 的构建、测试、文件匹配工具链。生产直接影响取决于是否在服务端运行时用它处理用户输入 glob;当前未在扫描摘要中发现明显业务入口直接使用。
|
||||
|
||||
**建议修复:**
|
||||
|
||||
通过升级引入它的 direct dependency 来消除,不建议手工改 lockfile。
|
||||
|
||||
## Medium
|
||||
|
||||
### M-1:`esbuild <=0.24.2` dev server 允许任意网站请求并读取响应
|
||||
|
||||
**证据:**
|
||||
|
||||
`npm audit` 显示:
|
||||
|
||||
- package:`esbuild`
|
||||
- severity:`moderate`
|
||||
- advisory:`GHSA-67mh-4wv8-2f99`
|
||||
- vulnerable range:`<=0.24.2`
|
||||
- `fixAvailable=true`。
|
||||
|
||||
**影响:**
|
||||
|
||||
主要影响开发服务器场景。若本地开发服务暴露到不可信网络,风险上升。
|
||||
|
||||
**建议修复:**
|
||||
|
||||
随 Vite / 构建链路升级一并修复,升级后跑前端检查与构建。
|
||||
|
||||
### M-2:`postcss <8.5.10` CSS stringify XSS advisory
|
||||
|
||||
**证据:**
|
||||
|
||||
`npm audit` 显示:
|
||||
|
||||
- package:`postcss`
|
||||
- severity:`moderate`
|
||||
- advisory:`GHSA-qx2v-qp2m-jg93`
|
||||
- vulnerable range:`<8.5.10`
|
||||
- `fixAvailable=true`。
|
||||
|
||||
**影响:**
|
||||
|
||||
如果系统把不可信 CSS 内容 stringify 后注入页面,可能触发 XSS。当前项目是否存在这类业务入口需人工复核;从依赖角度建议升级。
|
||||
|
||||
**建议修复:**
|
||||
|
||||
升级 Tailwind/Vite/PostCSS 链路带出的安全版本,并执行前端构建验证。
|
||||
|
||||
## Low
|
||||
|
||||
### L-1:`jsdom` 链路低危 advisory
|
||||
|
||||
**证据:**
|
||||
|
||||
`npm audit` 显示:
|
||||
|
||||
- `jsdom` direct dependency,severity low。
|
||||
- transitive:`http-proxy-agent`、`@tootallnate/once`。
|
||||
- npm 建议升级到 `jsdom 29.1.1`,SemVer major。
|
||||
|
||||
**影响:**
|
||||
|
||||
通常影响测试环境。若测试工具处理不可信 URL/代理输入,风险上升。
|
||||
|
||||
**建议修复:**
|
||||
|
||||
不要和 Vite/TypeScript ESLint 大升级混在一个提交里。单独升级 jsdom 后运行:
|
||||
|
||||
```bash
|
||||
npm run test
|
||||
```
|
||||
|
||||
## Unknown / 未完成项
|
||||
|
||||
### U-1:Rust 依赖漏洞未完成扫描
|
||||
|
||||
**原因:**
|
||||
|
||||
本机没有 `cargo-audit`,本次没有擅自安装用户级 Cargo 工具。
|
||||
|
||||
**建议:**
|
||||
|
||||
如确认允许安装:
|
||||
|
||||
```bash
|
||||
cargo install cargo-audit --locked
|
||||
cargo audit --manifest-path server-rs/Cargo.toml
|
||||
```
|
||||
|
||||
或在 CI/具备工具的环境执行并回填结果。
|
||||
|
||||
## Informational / 源码热点
|
||||
|
||||
### I-1:JS/TS XSS / 动态执行热点
|
||||
|
||||
扫描命中 1 行:
|
||||
|
||||
- `src/routing/RouteImageReadyGate.test.ts` 中测试代码使用 `root.innerHTML`。
|
||||
|
||||
初步判断为测试环境构造 DOM,不是生产漏洞。若后续发现生产代码使用 `dangerouslySetInnerHTML` 或直接 `innerHTML = userInput`,应升级为 High。
|
||||
|
||||
### I-2:Node 脚本命令执行热点
|
||||
|
||||
扫描命中 21 行,主要集中在:
|
||||
|
||||
- `scripts/spacetime-migration-common.mjs`
|
||||
- `scripts/run-bash-script.mjs`
|
||||
- `scripts/generate-spacetime-bindings.mjs`
|
||||
- `scripts/dev-web-rust.mjs`
|
||||
|
||||
初步判断为项目脚本启动 `spacetime`、bash、Vite 等工具的正常行为。后续人工复核重点:
|
||||
|
||||
- 是否使用固定命令和参数数组,而不是拼接 shell 字符串。
|
||||
- 是否把用户输入直接作为命令或 shell 参数。
|
||||
- 是否设置 `shell: true`。
|
||||
|
||||
### I-3:Rust unwrap/expect、文件路径、CORS/Auth 热点较多
|
||||
|
||||
扫描命中:
|
||||
|
||||
- `rust-hotspots.txt`:1348 行。
|
||||
- `auth-cors-hotspots.txt`:1157 行。
|
||||
|
||||
这些是热点,不等于漏洞。建议后续按模块分批人工复核:
|
||||
|
||||
1. `server-rs/crates/api-server/src/admin.rs`
|
||||
2. `server-rs/crates/api-server/src/app.rs`
|
||||
3. `server-rs/crates/platform-auth/src/**`
|
||||
4. `server-rs/crates/platform-oss/src/**`
|
||||
5. `server-rs/crates/platform-llm/src/**`
|
||||
6. `server-rs/crates/spacetime-client/src/**`
|
||||
|
||||
重点看:生产 CORS、Cookie 安全属性、token 日志、路径拼接、外部 URL 下载、Data URL 大小限制、OSS 签名边界。
|
||||
|
||||
## 推荐修复顺序
|
||||
|
||||
1. 立即处理 C-1:轮换 `.env.local` 里所有真实密钥,并从 Git 索引移除 `.env.local`。
|
||||
2. 升级 `vite` 相关依赖,优先消除 dev server 任意文件读取/路径遍历 advisory。
|
||||
3. 升级 `@typescript-eslint/*`,消除 minimatch 链路 ReDoS;因 major 升级,单独提交。
|
||||
4. 升级 `postcss` / `esbuild` / `picomatch` 的来源依赖。
|
||||
5. 单独评估 `jsdom` major 升级。
|
||||
6. 用户确认后安装或使用 CI 执行 `cargo audit`,补齐 Rust 依赖漏洞结论。
|
||||
7. 对 `auth-cors-hotspots.txt` 和 `rust-hotspots.txt` 做模块级人工审计。
|
||||
|
||||
## 修复后的验证命令
|
||||
|
||||
```bash
|
||||
npm run check:encoding
|
||||
npm run lint:eslint
|
||||
npm run typecheck
|
||||
npm run test
|
||||
npm run build
|
||||
```
|
||||
|
||||
如修改后端安全、Auth、Cookie、CORS 或 API:
|
||||
|
||||
```bash
|
||||
cd server-rs && cargo test --workspace
|
||||
npm run api-server
|
||||
# 检查 /healthz,并执行相关 API/auth smoke
|
||||
```
|
||||
|
||||
如补齐 Rust audit:
|
||||
|
||||
```bash
|
||||
cargo audit --manifest-path server-rs/Cargo.toml
|
||||
```
|
||||
|
||||
## 备注
|
||||
|
||||
- 本报告没有输出任何真实密钥值。
|
||||
- `.hermes/plans/assets/security-scan-2026-05-11/secret-grep.txt` 可能包含敏感内容,仅用于本地排查;提交前应删除或替换为脱敏报告。
|
||||
- 由于 `gitleaks` 未安装,本次密钥扫描只是 grep 兜底,不等价于完整 secrets audit。
|
||||
Reference in New Issue
Block a user