dsh-sandboxie-redirect: Adding Copy-on-Write Permission Presets for DSH on Windows

Preface

When running agents in DSH, the shell is often the entry point with the highest potential for modification: a single command can alter configurations outside the workspace, create temporary files, or touch system directories. DSH comes with three permission presets: “Read-only,” “Workspace-write,” and “Danger-full-access.” The first two directly reject writes outside the workspace, while the third imposes almost no restrictions. If you want writes outside the workspace to report success on the command side without polluting the real disk, while keeping workspace writes persisted to disk and maintaining the existing rule for DSH file tools (“writable inside, rejected outside”), you need an additional isolation layer.

The following introduces the community bundle dsh-sandboxie-redirect (maintained by lone-wolf-akela, categorized as admin-security on SkillHub). Without modifying the DSH application core, it adds a fourth permission preset: Copy-on-write. Shell commands are executed inside a per-workspace Sandboxie sandbox.

What is this

@lone-wolf-akela/dsh-sandboxie-redirect is a DSH bundle published on npm (current package version 0.3.4, MIT license). Upon installation, it automatically mounts the configuration layer, requiring no manual edits to profile files. The platform requirement is Windows 10/11, with Sandboxie-Plus pre-installed and its sandbox service running.

The plugin is positioned as a permission preset, not a patch to the DSH application. Its design goals are to prevent accidental writes, facilitate undoing mistakes, and reduce system directories being dirtied by agent commands. The README explicitly states that it cannot be treated as a security boundary against malicious programs—Sandboxie itself makes no such promise, and the plugin possesses the same privileges as the DSH process hosting it.

Core Features

Behavior of the Copy-on-write Preset

Location Behavior of Shell Commands (Inside Box)
Write, Modify, Delete Inside Workspace Acts directly on the real disk
Write, Modify Outside Workspace Command reports success, but changes land in a copy within that workspace’s sandbox; the real disk remains unchanged
Delete Outside Workspace Real files are preserved; only a deletion marker is recorded in the copy

DSH’s native read/write/edit file tools run outside the box, following rules consistent with “Workspace-write”: writable inside the workspace, rejected outside. Consequently, a read divergence may occur for the same path—the in-box shell reads the merged Sandboxie view (including copy overrides), while the out-of-box file tools read the real disk. To verify “what the command wrote outside the workspace,” use the shell to read; to verify “whether the real disk was modified,” use DSH file tools or the file explorer.

Interface and In-Session Tools

  • A ❐ Copy-on-write 写时复制 preset appears in the permission dropdown and bottom buttons (with a copy/double-rectangle icon; the ❐ before the name ensures visibility under the default icon mapping).
  • Once Copy-on-write is enabled and a sandbox is created for the workspace, the title bar displays the sandbox name (e.g., dsh_able_willow). This only appears after the first shell command and disappears when switching presets or clearing the sandbox.
  • The session provides a sandbox_clear tool: mode: "inspect" views the copy footprint, mode: "clear" deletes the copy and related configurations; there is also a diagnostic mode: "status" (available since 0.3.3) to check if the sandbox name isn’t showing in the title bar.
  • In Copy-on-write mode, a note is appended to the session policy text to inform the model of this mode’s behavior, reducing the need for the model to infer it.

The original three presets (read-only, workspace-write, danger-full-access) remain unchanged.

Installation and Activation

Prerequisites: Install Sandboxie-Plus and ensure the service is available. The plugin locates SbieDll.dll via the registry (SbieSvc ImagePath, etc.), standard installation paths, PATH, and fallback scans. If all fail, set the environment variable DSH_SBIE_DIR to point to the installation directory (the folder containing SbieDll.dll). The DSH installation location is also auto-detected; for non-standard layouts, refer to the README for optional variables like DSH_SBIE_NODE and DSH_SBIE_KOFFI.

The bundle installation command is as follows (replace <profile> with your profile name):

dsh plugin --profile <profile> add @lone-wolf-akela/dsh-sandboxie-redirect

After installation, use --dump-config to verify the configuration layer marker appears, then start DSH:

dsh --profile <profile> --dump-config      # Should see "# == @lone-wolf-akela/dsh-sandboxie-redirect"
dsh --profile <profile>

Local checkouts or offline packages can also be added (examples from the official README):

dsh plugin --profile <profile> add C:\path\to\dsh-sandboxie-redirect
dsh plugin --profile <profile> add .\lone-wolf-akela-dsh-sandboxie-redirect-0.3.1.tgz

Profile Note: If the profile is exclusively locked by a running desktop app (e.g., desktop), the CLI will refuse modifications. In this case, you should Settings → Plugins → Add bundle inside DSH and enter the package name @lone-wolf-akela/dsh-sandboxie-redirect.

After the steps above, restart the client and select ❐ Copy-on-write 写时复制 in the permission dropdown to use it.

If you previously manually copied the plugin to ~/.dsh/plugins/ and added loader lines in cordis.patch.yml, you must delete those lines before switching to the bundle channel. Otherwise, a “resolves from multiple active Loader sources” error will cause startup failure.

Typical Usage

  1. Install Sandboxie-Plus and DSH on Windows, install the bundle as described above, and restart.
  2. Open the target workspace, switch the permission preset to Copy-on-write, and let the agent execute commands via the shell that might touch outside the workspace (e.g., writing to temp directories or modifying files under user configuration paths).
  3. Use DSH file tools to view paths outside the workspace and confirm the real disk is unchanged; use the shell to read the same path under the same preset to see the in-box merged view (if a command previously wrote there).
  4. When needing to release copy disk usage, call sandbox_clear with clear mode in the session, or use the management CLI provided with the package outside the box:
node bin\dsh-sbie-run.mjs --manage list
node bin\dsh-sbie-run.mjs --manage clean "<workspace>"
node bin\dsh-sbie-run.mjs --manage delete-box <sandbox_name>

Both --manage and the SandMan GUI must be operated from outside the sandbox. Uninstalling the bundle only removes the preset and config lines; sandboxes and copies remain on disk. Space should be reclaimed manually before uninstallation.

Use Cases and Notes

Suitable for: Agent development or daily automation on Windows using DSH, where you want shell mistakes writing outside the workspace to be discardable with one click, while workspace changes persist normally, and you don’t want to choose between “full access” and “reject all outside” every time.

Not suitable or things to know:

  • Cannot be used in non-Windows environments (os is win32 in package.json).
  • Copies are not automatically reclaimed; long sessions may consume disk space. Writing back to the real disk requires recovery via SandMan; sandbox_clear only deletes without writing back.
  • Concurrent shell commands in the same workspace share a single sandbox and are visible to each other.
  • Under Copy-on-write, if a command escalates privileges, that specific call runs entirely outside the box, and the next command returns to the box. This is distinct from “writing a copy file back to the real disk.”
  • The generic parameter descriptions for sandbox_permissions apply to all presets. Under Copy-on-write, writes outside the workspace are not rejected. Privilege escalation is a proactive way to make a single call act on the real disk, not a remedy for failure.
  • The plugin runs with current DSH process privileges. Please read the GitHub repository source code and MIT license before installing to evaluate if it meets your security requirements. The community catalog SkillHub plugin page has no official affiliation with DeepSeek or 幻方 (High-Flyer); it is an independent inclusion in the DSH “everything is a plugin” ecosystem.

dsh-sandboxie-redirect connects Sandboxie’s per-workspace sandboxing to the DSH permission system, using Copy-on-write to compromise between “commands can explore outside” and “keeping the real disk clean.” For further implementation and environment variable details, see GitHub README (includes Chinese version); to search and favorite on the catalog site, see SkillHub.

羽毛球分组比赛记分
小程序二维码

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

Xiaoye