dsh-sandbox-better: Fine-Grained Directory-Level Sandbox

Introduction

The default sandbox mode of DSH (DeepSeek Harness), workspace-write, only allows writes to the workspace; all other directories are read-only. If an Agent needs to access other directories, the only option is to switch to danger-full-access, which grants full system access. This introduces unnecessary risk: the Agent gains system-level write permissions it doesn’t actually need.

The dsh-sandbox-better plugin adds a “directory-level authorization” capability on top of the official sandbox. The model can request write access to a specific directory individually. Once the user approves on the approval card, that directory becomes writable by bash and file tools for the remainder of the session, and the grant expires when the session ends.

Plugin Scope

This is a DSH plugin maintained by jiesou, categorized under admin-security. It provides a bundle: a request_write_access tool available to the model, session-scoped writable directories, and lenient sandbox parameter handling.

Installation & Activation

The plugin can be installed via npm or GitHub. A web service restart is required after installation.

Install from npm (pre-built artifact, recommended):

dsh plugin --profile web add dsh-sandbox-better

Or install from GitHub:

dsh plugin --profile web add github:jiesou/dsh-sandbox-better

Restart the web service after installation. DSH version >=0.2.2-rc.2 is required (SandboxPolicyService.registerWritableRoot is available from this version).

Core Capabilities

Directory-Level Write Authorization

The model calls the new request_write_access tool to request a directory. After the user approves on the approval card, that directory becomes writable by both bash and file tools for the rest of the session. The grant expires when the session ends.

The tool signature has a single parameter path:

  • An absolute path
  • Or a path relative to the workspace
  • ~ will be expanded
  • The directory must exist

The approval card is rendered by the official dsh-client-ui-approval. This plugin sends only a single approval.request; the buttons and keyboard shortcuts belong to the host. The approval title is included by this plugin in the request via displayReason (en / zh, selected based on the current UI language).

Approval goes through the official registerWritableRoot, so it is backend-agnostic: bwrap, Landlock, and Seatbelt all honor it. In danger-full-access mode, this tool is not registered at all, so the model won’t see an entry that would be meaningless.

Example flow:

tool: request_write_access { path: "~/Documents/dev/other-repo" }

┌ Waiting for approval
│ Allow this session to write to /var/home/chen/Documents/dev/other-repo?
│                                                     [Allow once]   [Deny]

Context Slimming

By default, DSH’s dsh-sandbox-policy writes additionalWritableRoots into the runtime context of every step (Additional writable directories: [...]). In most cases, the model doesn’t need to know which directories are writable. The host re-renders this line in refreshContext() at every step (overwriting any modification made by system-prompt/assemble). This plugin hooks in here to strip out the list, while preserving the “mode” and “workspace” information.

Missing Directories Don’t Break Writes

A writable directory listed in the configuration but no longer existing causes all writes to fail with Invalid additional writable directory. This plugin removes unreachable directories from the list upon mounting and logs a warning, so writes proceed as normal.

Lenient Permission Parameters

The model often gets confused about which mode it’s in and writes escalation parameters incorrectly. The official configuration is overly strict. This plugin applies lenient handling to sandbox_permissions / justification:

Original error Behavior now
invalid escalation: justification is only valid together with sandbox_permissions Unpaired justification is removed; execution proceeds normally
invalid escalation: sandbox_permissions requires a justification A default Agent did not attach a justification. is supplied
invalid justification: expected a non-empty sentence Blank justification is replaced with the default; approval flow proceeds normally
sandbox escalation to "X" is not strictly wider than this call's current "Y" mode Both fields are removed; execution proceeds in the current mode

Only sandbox_permissions / justification are rewritten. command, path, and content are never modified, so the invocation card and audit log still reflect the model’s original parameters. Errors that the model should genuinely fix are still surfaced: when sandbox_permissions contains a value outside the allowed vocabulary (full, workspace_write, …), it is delegated to the host’s invalid arguments handler.

Use Cases & Caveats

Suitable for DSH agent development scenarios that require “directory-level” rather than “whole-system” write permissions.

Notes:

  • Authorization is runtime-only: it is not persisted to session logs. After a resume or fork, the grant must be re-requested. Already-running processes retain their original permissions.
  • There is no revocation mechanism: end the session, or switch the permission preset.
  • This plugin does not provide a sandbox backend, nor does it manage deployment-level directories — that is the role of sandbox-policy.additionalWritableRoots.

It is recommended to review the source code and license before installing.

In Summary

dsh-sandbox-better adds fine-grained, directory-level authorization on top of DSH’s official sandbox. Through the request_write_access tool and lenient parameter handling, it enables the model to obtain necessary write permissions within a safer boundary.

  • Directory page: https://www.skillhub.cn/plugins/jiesou/dsh-sandbox-better
  • GitHub: https://github.com/jiesou/dsh-sandbox-better
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye