toby-bridges/api-relay-audit
toby-bridges/api-relay-audit从 DeepSeek Harness 对 AI API 中转站和 LLM 代理运行本地安全审计,生成 Markdown 报告,覆盖提示词注入、模型替换信号、工具调用改写、错误泄漏、流完整性和按 profile 启用的 Web3 风险。
DeepSeek Harness 的上下文防火墙:成功的纯文本工具结果中的凭据在进入模型之前先变成不透明的 ⟦cloak:category:n⟧ 占位符,原值只保存在进程内存的 agent 级保险库中。36 类内置签名(与 cloakpack git pre-push 守卫共享同一引擎)、针对未知格式的键名规则、自定义正则、dry-run 模式、审计日志与 /cloak 命令。
A context firewall for DeepSeek Harness: credentials in tool results are replaced with opaque placeholders before they reach the model. The secret never enters context — the task keeps going.
$ cat .env ← the agent reads a config file
DEEPSEEK_API_KEY=sk-0123…cdef
→ what the model actually sees:
DEEPSEEK_API_KEY=⟦cloak:deepseek-api-key:1⟧
Your agent reads .env files, config dumps, cloud CLI output, and log tails. Every credential in those results flows into the conversation — and from there into every request sent to your model provider. Export-time redaction (sharing, handoff) is too late: the secret already left your machine while the agent was working.
dsh-cloak guards the boundary where tool results enter model context:
Authorization: Bearer …), plus key-name rules (password/secret/api_key/…) that catch unknown formats in .env, JSON, and YAML shapes. Custom regex rules via a JSON file.⟦cloak:<category>:<n>⟧. The original values live only in a process-memory, agent-scoped vault. They never enter session logs, audit events, or model requests.Pagination cursors (next_token, page_token, …) and placeholder values (${VAR}, changeme, …) are deliberately excluded, so paging and templates keep working.
# GitHub channel (latest main):
dsh plugin --profile web add "github:zhangmiao03/dsh-cloak#main"
# GitHub channel (pinned release, recommended for stability):
dsh plugin --profile web add "github:zhangmiao03/dsh-cloak#v0.1.0"
# npm channel (after npm publish):
dsh plugin --profile web add dsh-cloak
# local development:
dsh plugin --profile web add /path/to/dsh-cloak
Uninstall: dsh plugin --profile web remove cloak.
Verify the mount, then restart dsh:
dsh --profile web --dump-config | grep -A2 'id: cloak'
Per-row config in the profile cordis.patch.yml:
- id: cloak
config:
enabled: true
dryRun: false # audit-only mode: report what would be redacted
builtins:
enabled: true
rulesFile: ~/.dsh/cloak-rules.json
note: true # attach the placeholder-semantics note for the model
audit:
maxEntries: 200
logFile: # optional JSONL audit trail
Custom rules file format:
[
{ "id": "internal-prefix", "pattern": "mycorp-[a-z0-9]{32}", "flags": "g" }
]
| Surface | Kind | Notes |
|---|---|---|
tools/post-execute | listener | Redacts successful plain-text tool results (content projection) |
systemPrompt context | injection | Placeholder semantics for the model, before it ever sees one |
/cloak | command | /cloak stats · /cloak scan <text> dry-scan |
/cloak/api/* | HTTP | GET stats · GET recent · POST test {text} |
Honest scope, same spirit as the host's own spill-policy:
PreToolDecision excludes input rewriting). When a task needs a real value, the model is instructed to ask the user. An approval-gated reveal (riding the host's ask/authorization seams) is planned.dryRun audits without replacing; it is the recommended first rollout step.Built and verified against DeepSeek Harness 0.1.2-rc.1 (developer-preview host; expect to re-pin on breaking host changes). Node ^22.19 || >=24.
npm install --legacy-peer-deps
npm test # 51 unit tests
npm run build # links @deepseek-ai/* peers from the global dsh install, then tsc