Skip to content

audit 凭证脱敏: JWT/bearer/AWS sigv4 写入 audit JSONL 前遮蔽 (item 22) #95

Closed

Description

@dahai80

背景

enhance-0819.md item 22 (CC 2.1.224 沙箱凭证脱敏) — "sensitiveFiles.ts + 审计加 JWT/token 家族感知脱敏"。

审计 (iter #15)

  • sensitiveFiles.ts 仅 拦截读取 (路径 pattern), 无 内容脱敏 — 已读出/命令里的 token 字面量无遮蔽
  • auditLog.ts createAuditEntry 持久化 target (含 Bash command slice 200 chars) + detail + error 到 ~/.fusion-code/audit/*.jsonl (mode 0o600)。命令嵌入 token (如 curl -H "Authorization: Bearer eyJ...") 会明文落盘审计日志
  • 无现成 redaction helper (relay.ts 是 proxy 构建, 非 redact)

真实 gap

审计日志 target/detail/error 字符串里 JWT/bearer/AWS sigv4/token 家族明文落盘 → 本地凭证泄露面 (虽 mode 0o600, 审计日志供 /audit 查看/轮转/30 文件留存)。

范围 (surgical, 单文件)

src/services/audit/auditLog.ts 新增 redactSecrets(s) helper:

  • JWT (eyJ...eyJ.signature 3-segment base64url)
  • Bearer token (Bearer <token>)
  • AWS sigv4 (X-Amz-Signature=<hex>)
  • generic api-key header (x-api-key: <val>, Authorization: <val>)
    遮蔽保留前 4 + … + 后 4 (可辨识格式, 不可还原)。在 createAuditEntry 内对 target/detail/error 应用。默认 on, 不改 audit schema。

验证

typecheck 0 + 单测 (JWT/Bearer/AWS/api-key 各遮蔽 + 非 token 不误伤) + build + bun run lint auditLog scope + git diff -w zero churn。

不动

  • sensitiveFiles.ts (拦截读路径已生效, 非内容脱敏范围)
  • toolExecution.ts audit callers (透明 — 脱敏在 createAuditEntry 内部)
  • 审计 schema (字段不变, 仅值遮蔽)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions