[Bug] Windows 的极简模式运行 Shell 工具时报错,str_replace_editor 工具在 Read Only 的情况下可读写工作区外文件 #2066
Replies: 3 comments
|
Your root-cause chain is correct. One clarification and a patch. Read vs writeReading outside the workspace is by design, not a minimal-preset regression: the confining backend ( Patch (cherry-pick-ready against
|
中文把这个 bug 族做成了可运行的静态审计工具:dsh-sandbox-audit。 它会读
同时覆盖 #951(搜索工具读越权)和 #149(shell 破坏性操作无门禁)。纯社区安全审计工具,非官方背书。 EnglishGeneralized this bug family into a runnable static audit: dsh-sandbox-audit. It reads
It also covers #951 (search-tool read escape) and #149 (unguarded shell destructive ops). Community security audit, not an official endorsement. |
|
I shipped the backend-layer version of this fix today, and the experience is an argument for @zoahdev's tool-layer patch rather than mine. Recording why. What I did, and why it is the weaker layer
That works. It also only helps backends whose authors know to do it. Concretely, I ran @zoahdev's own dsh-sandbox-audit against my two presets expecting one to come back red, because one of them genuinely does not fence. Both came back So the bug family is not "the minimal preset mounts One thing worth stating explicitly in the patch
[policy.workspaceRoot, '/tmp', tmpdir()]I found this the embarrassing way. I wrote a test asserting that a Not asking for a behavior change here, that is a separate argument and this thread is about the bypass. Just worth one line in the patch's docs or the mode description, because after this lands the editor will start enforcing containment and someone will file "why did it allow Scope agreementAgreed on the split. The win32 shell gap is separate and larger. For the record on this half, if the tool-layer patch lands, my 中文我今天把这个洞在后端层修了一遍,结果反而更支持 @zoahdev 的工具层补丁。原因如下。
能用,但只对「作者知道要这么做」的后端有效。 更能说明问题的是,我拿 @zoahdev 自己的 dsh-sandbox-audit 去扫我那两个预设,本来预期有一个会红,结果两个都 所以这个 bug 族不是「minimal 挂了 fs-local」,而是「有副作用的工具把一个后端从没承诺过的策略,交给这个后端去执行」。任何按后端身份来判的修法,无论是我这种换基类还是静态审计的白名单,都是在追名字。在工具层执行的补丁才是关掉整族的那个,而且第三方后端的作者什么都不用做。 另外建议补一句文档。 |
Uh oh!
There was an error while loading. Please reload this page.
代码分析部分完全使用 DeepSeek Harness 完成,本人没有动过一点大脑()我对 Node 的了解比较少,这个 Discussion 也是大晚上写的,估计比较烂,凑合看看,轻喷(
我听到 Linux + Minimal 能发挥几乎全部实力,我就吭哧吭哧跑来了,虽然我是 Windows,搭配的是 PowerShell,但我觉得也可以试一下,结果
subprocess-local盖了我一巴掌(bushi测试环境:Windows 11 23H2 (22631.6199)
DSH 启动参数:
npx @deepseek-ai/dsh web(默认,设置我也没调)Windows 的极简模式下运行命令出错的问题很简单,我觉得大伙也知道:
极简模式没有根据平台区分 Shell 工具,而
subprocess-local因为平台不对直接打回去了,喜提Error: subprocess-local: terminal inspection is unsupported on platform win32。当然用户侧已经有一个解决方案了,比如 #1832 和对应的插件仓库。标准模式倒是有按平台区分,DSH 核心也是这么做的:
deepseek-harness/packages/bundle/base/cordis.patch.yml
Lines 210 to 216 in 47f9438
deepseek-harness/apps/cli/config/agent-presets/standard/agent.cordis.yml
Lines 35 to 50 in 47f9438
接下来是另一个问题:
我在尝试 Minimal 的过程中发现
str_replace_editor可以任意读取工作区外的文件,我个人十分担忧,但大肥鱼跟我说这是工程取舍。我没怎么经常使用 AI 编程,不知道大伙怎么想的()让别人能够读你工作区的密钥和私人文件,就算对面是只大肥鱼心里也会担忧吧(但我让大肥鱼分析源码之后发现这个工具没有读限制,也没有写限制。没错,你在权限为 Read Only 的情况下也能读写,
str_replace_editor使用的文件系统 shadow 了宿主的文件系统沙箱,甚至源码里都写了相应的注释:deepseek-harness/apps/cli/config/agent-presets/minimal/agent.cordis.yml
Lines 46 to 62 in 47f9438
测试我也简单的测了一下:
那么什么所谓的根因链我就引用大肥鱼的报告:
从该报告可以看出,
str_replace_editor寻找fs,发现了fs-local它就用了这个文件系统后端,直接绕开了宿主的文件系统沙盒。另外一个我感觉不算太紧要的事情:
我去测试了一下
str_replace_editor的写,让 AI 写入E:\test.txt(工作区外),我发现如果在根目录创建文件夹会遇到目录创建不出来的问题,我觉得这好像是把盘符当作了目录处理来mkdir但是失败了:All reactions