Skip to content

fix(safety): O105 redact Moss config on direct read_file execute - #100

Merged
QiaolongLi1201 merged 1 commit into
mainfrom
fix/o105-config-credential-path
Oct 11, 2026
Merged

QiaolongLi1201 merged 1 commit into
mainfrom
fix/o105-config-credential-path

Conversation

@QiaolongLi1201

Copy link
Copy Markdown
Collaborator

Summary

O105(P2 安全)纵深防御:即使绕过 agent 展示层直接调 readFileTool.execute,.moss/config.json(及同类 Moss credential 路径)里的 apiKey 也不能以原文返回。

实现策略(脱敏,非拒绝)

  • 在 readFileTool.execute 末尾:若 isMossCredentialPath(filePath),对结果跑与 agent 相同的 presentToolOutput(字段级 [REDACTED];.apikey-key 仍整文件 Moss credential values withheld)。
  • 非 secret 字段(provider/model 等)仍可见;读本身不拦截。
  • isMossCredentialPath 对项目 .moss/ 增补 devices.json(与 known-secrets 扫描集对齐);config.json / 用户 moss 目录 / .apikey-key 原有覆盖不变。
  • 不回退 test(safety): O97a ln/touch/rm/shred 受保护路径用例 + O97b .moss/config.json 不泄密 #99 O97b(编辑恢复路径仍不 attach credential 内容)。

改动文件

  • src/tools/file-tools.ts — execute 路径脱敏
  • src/safety/read-scope.ts — project .moss/devices.json 纳入 credential 路径
  • test/o105-config-credential-read.spec.mjs — 定向验收(撤修复变红)

验收

项 结果
A. 直接 execute 读含 apiKey 的 .moss/config.json 无原文,有 [REDACTED]
B. agent/model 路径 仍无原文(回归)
不误伤 普通文件 / fixtures 下非 credential config.json / .moss/tasks.jsonl
撤修复 去掉 execute 中 isMossCredentialPath 分支 → O105 定向 5 红 / 4 绿
npm run check 绿
相关测试 o105 9/9、read-scope、partial-read-recovery、o97-followup(含 O97b)全绿

Base

f26ff95a(#98 O93 合后 tip)

Defense in depth: readFileTool.execute now runs presentToolOutput for
isMossCredentialPath targets so apiKey never returns plaintext when
bypassing the agent post-hook. Project .moss/devices.json is treated as
a credential path alongside config.json. Directed tests cover execute
redaction, agent-path regression, and non-credential fixtures.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@QiaolongLi1201
QiaolongLi1201 merged commit 9629e42 into main Oct 11, 2026
6 of 12 checks passed
@QiaolongLi1201
QiaolongLi1201 deleted the fix/o105-config-credential-path branch October 11, 2026 20:23
QiaolongLi1201 added a commit that referenced this pull request Oct 11, 2026
fix(safety): O107 credential path realpath / symlink follow-up (#100 O105)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant