威胁模型

English

摘要

Codex Quota Monitor 是自托管 operator dashboard,会读取敏感的 CLIProxyAPI management 状态,并在配置后读取本地 Codex OAuth auth 文件。最高风险结果是 management key 或 OAuth token 泄露、账号与 quota 运维元数据被不该看到的人看到, 以及把本应本地使用的 dashboard 以无鉴权方式暴露到 LAN 或公网。

范围与假设

纳入范围:

不纳入范围:

假设:

可能改变风险排序的开放问题:

系统模型

主要组件

数据流与信任边界

Diagram

flowchart LR
  Operator["Trusted operator"] --> CLI["Monitor CLI and config"]
  CLI --> Server["Monitor HTTP server"]
  Server --> CPA["CLIProxyAPI management"]
  Server --> Auth["Codex auth files"]
  Server --> Provider["Codex usage API"]
  Server --> DB["SQLite history"]
  Server --> Browser["Browser and agents"]
  Proxy["Authenticated proxy"] --> Server
  Benchmark["Benchmark runner"] --> Results["Benchmark outputs"]

资产

入口

威胁与缓解

威胁 风险 现有控制 缺口与建议
Management key 或 OAuth token 出现在 API、metrics、history、logs 或 support 输出里。 测试覆盖 public endpoint、metrics、doctor JSON、history 和 quota sampling;print-config 清理 URL;redact 生成脱敏副本。 每次新增 public 字段都继续补回归测试。Benchmark/history schema 新字段按 privacy change 复查。
Dashboard 被无鉴权暴露到 LAN/公网。 Python/NixOS 默认 127.0.0.1;NixOS openFirewall 默认 false;doctor 对非 loopback 和 allowed-host 暴露给 warning;文档要求鉴权 proxy/access layer。 不把 Host/Origin check 当成鉴权。后续可考虑对宽 bind address 增加显式确认 flag。
Docker/NixOS mount 过宽导致无关 secret 暴露。 文档要求只挂载具体 management key 文件和 auth directory;除非明确启用 auth live plan sync,否则 auth files 保持只读。NixOS 使用专用用户、systemd hardening 和独立可写同步 unit。 示例不能挂载整个 home 或 config 目录。
SQLite history 或 benchmark 输出泄露运维元数据。 安全文档把这些 artifact 标为敏感;redact 支持 JSON、JSONL、CSV、Markdown/text、SQLite 副本脱敏,以及用于 staging support 目录的 dry-run/apply 批量脱敏。 不共享原始 history DB 或 benchmark 目录。新增 benchmark 文件形态时补脱敏测试。
Reverse proxy path 或 host 配置不匹配削弱边界预期。 Allowed-host check 拒绝非预期 Host/Origin;文档说明 v1 期望专用 hostname 根路径部署。 保持 reverse proxy 示例与根路径和鉴权访问一致。
CI/release artifact 被篡改。 Release image 从 tag source 构建,Docker base image 用 digest pin,Dependabot 更新依赖,GHCR image 带 SBOM/provenance 和 keyless cosign 签名。 发布前验证 workflow、attestation 和 tag 完整性。

人工复查重点

质量检查