[Security] Web minimal preset allows unapproved writes outside workspace-write on Windows #523
Replies: 4 comments 1 reply
|
我这边在 Linux 上也遇到了同类问题 环境OS:Ubuntu 26.04 LTS(x86_64) 现象让dsh把opencode的AGENTS.md和skills搬过来 bash 工具里 / 被挂载为 ro,只有工作区是 rw;touch ~/.dsh/.write_test 返回 Read-only file system。这部分符合 workspace-write 的预期。 |
|
minimal 预设能在 workspace-write 外未批准写入——权限边界的实际缺口,和 #1516(网络独立沙箱)、#523 这类发现都是"沙箱存在≠安全"的例证。 这类审计发现我们第 13 章专门有收集(含审计方法论):https://github.com/Electricitysheep/dsh-handbook/blob/main/docs/13-security.md |
|
这个 permission boundary 仍然应该由 DSH 修,但现在可以先加一道已经跑通的独立执行前防线:Pi 生态的 dsh plugin --profile web add pi2dsh@0.11.0
dsh plugin --profile web add pi-approval-guardian
export PI_APPROVAL_GUARDIAN_MODEL=deepseek-official/deepseek-v4-flash
export PI_APPROVAL_GUARDIAN_POLICY='禁止任何工具在当前 workspace 与显式临时目录之外创建、覆盖、移动或删除文件;Windows Public Documents、用户配置与其他项目目录一律拒绝。'项目:https://github.com/weijiafu14/pi2dsh 因此原帖里的 这是一道纵深防线,不替代原帖要求的修复: |
|
Until this is addressed, start new Web sessions with the Standard preset and Workspace Write, rather than In current rc.7, Standard keeps file edits on the host's sandboxed filesystem path, while |
Uh oh!
There was an error while loading. Please reload this page.
Summary
The Web
minimalagent preset can write outside the selected workspace while the UI and exported session both report:I reproduced this on Windows with the session workspace located on drive
E:. Without requesting or receiving approval,str_replace_editorsuccessfully created a project under:This is outside the selected workspace and on a different drive.
The destination is relevant:
C:\Users\Public\Documentsis the Windows Public Documents location, not a Harness workspace or per-session temporary directory.This violates the documented meaning of
workspace-write, under which mutations should be restricted to the selected workspace and explicitly permitted temporary roots.The underlying problem appears to be that the
minimalpreset mounts the bare@deepseek-ai/dsh-fs-localbackend in an isolated filesystem realm, shadowing the host sandbox-backed filesystem provider. As a result,str_replace_editorcan perform writes throughfs-localwithout enforcing the activesandboxPolicy.This is not merely undesirable model behavior. The permission boundary must remain effective even when the model attempts an out-of-workspace write.
Environment
minimaldeepseek-v4-flashworkspace-writeworkspace-writeaskE:\<REDACTED_WORKSPACE>I could not find a reliable Harness build or commit identifier in the exported session. Please let me know where it can be obtained and I will add it.
Original task
The agent received an ordinary request to create a small local web application.
The user did not ask it to inspect unrelated host directories, change the selected workspace, or write files into Windows Public Documents.
Reproduction
Run DeepSeek Harness Web on Windows.
Select the
minimalagent preset.Select
workspace-writewith approval policyask.Select a workspace on drive
E:.Ask the agent to create a small web application.
In my run, persistent Bash failed with:
The agent then used
str_replace_editorwith absolute paths outside the selected workspace. The following is a privacy-redacted representation of the successful call:{ "command": "create", "path": "C:\\Users\\Public\\Documents\\<AGENT_CREATED_DIRECTORY>\\index.html", "file_text": "<!doctype html><html><body>test</body></html>" }The tool returned:
The agent subsequently created and modified several more files in the same Public Documents subdirectory:
No
approval/requestedevent occurred before any of these writes.Relevant session evidence
The exported JSONL records the following state. Only the private workspace name has been redacted:
{"type":"session","data":{"cwd":"E:\\<REDACTED_WORKSPACE>"}} {"type":"permission/preset","data":{"preset":"workspace-write"}} {"type":"sandbox/mode","data":{"mode":"workspace-write"}} {"type":"approval/policy","data":{"policy":"ask"}}It later records an editor call equivalent to:
{ "type": "tool/call", "data": { "name": "str_replace_editor", "arguments": { "command": "create", "path": "C:\\Users\\Public\\Documents\\<AGENT_CREATED_DIRECTORY>\\index.html", "file_text": "<!doctype html><html><body>test</body></html>" } } }The corresponding tool result confirms successful creation under:
The complete session export contains unrelated host paths and directory listings, so I am not attaching it publicly. I can provide a redacted export or additional event records if needed.
Expected behavior
Under
workspace-write, every mutating tool should reject paths outside:In this case, with the workspace located at:
a write to:
should be rejected.
If an out-of-workspace operation supports escalation, it should execute only after explicit user approval.
Actual behavior
str_replace_editorcreated and modified files under Windows Public Documents, outside the selected workspace and on a different drive.No approval was requested, and the session continued to report
workspace-write.Suspected cause
The Web
minimalpreset contains the following composition:The preset documentation indicates that the bare local filesystem shadows the host sandbox provider.
This matches the observed behavior: the editor resolves absolute paths through
fs-local, while the activeworkspace-writepolicy is not consulted.The standalone minimal-variant documentation warns that absolute editor paths can modify any path available to the runtime process and recommends using the variant only in a disposable checkout or container. That may be acceptable for an explicitly unrestricted standalone composition, but it conflicts with presenting the Web session as
workspace-write.Security impact
A model operating under this preset may write to host-user-writable locations outside the selected workspace, potentially including:
The demonstrated write into:
also shows that the effect is not confined to the selected workspace drive or directory tree.
The exact impact depends on the privileges of the Harness process, but the documented
workspace-writeboundary is not enforced.Directory reads are not the primary issue here, because the current documentation does not promise read confinement under
workspace-write. The confirmed issue is successful out-of-workspace mutation.Suggested fixes
At least one of the following changes appears necessary:
Replace
@deepseek-ai/dsh-fs-localwith the sandbox-enforcing filesystem backend in the Webminimalpreset.Make
str_replace_editorenforcectx.sandboxPolicyindependently of the mounted filesystem provider.If
minimalintentionally requires unrestricted filesystem access, prevent it from running while the UI reportsworkspace-write. Require an explicitdanger-full-accessselection and confirmation.Fail closed during preset composition when a preset advertises
workspace-writewhile exposing a mutating tool backed by a non-enforcing provider.Add Windows and POSIX integration tests verifying that every mutating tool rejects:
These tests should cover both
bashandstr_replace_editor. Restricting only one mutating tool does not preserve the permission boundary.Severity
I consider this a high-severity permission-boundary issue.
The interface communicates a constrained
workspace-writeenvironment, but theminimalpreset permits out-of-workspace writes with the privileges of the Harness host process. This mismatch is silent and requires no approval event.Related discussions
This report is related to, but distinct from:
Two remote-execution-world gaps in dsh-base (tool-fs-search rg path; fs-sandbox modes), with fixes #490, which describes missing
workspace-writesemantics for remoteexecution-world filesystem providers. This report reproduces the issue
locally on Windows in the Web
minimalpreset, where the barefs-localprovider appears to shadow the sandbox-enforcing filesystem provider.
BUG: `fs-sandbox` post-check pathname race 可绕过 `workspace-write` 文件边界 #159, which describes a post-check pathname race in an otherwise active
fs-sandboximplementation. This report does not require a race, symlink,hardlink, background process, or Linux sandbox. A direct absolute-path
str_replace_editorcall deterministically writes outside the selectedworkspace without approval.
Therefore, this appears to be a separate preset-composition and permission-UI
mismatch rather than another reproduction of either issue.
All reactions