Files
deepseek-harness/packages/bash/pwsh-sandbox/README.md
Huanqi Cao f64ba40f43 feat(sandbox): Windows ACL write-restriction sandbox (restricted-token runner)
Confine Windows command execution through a WRITE_RESTRICTED token whose restricting SIDs carry an orphan-SID write allowlist, ported from https://github.com/huoyaoyuan/windows-acl-restrict-poc (@ 10e4dfb). Every Win32 call is checked and fails closed - the POC silently ran children with the FULL token when CreateRestrictedToken failed.

- @deepseek-ai/dsh-sandbox-windows-acl: koffi primitives verified against the MinGW Windows headers (verify/abi-probe.cpp) plus the confinement runner ([node, runner, --workspace, --temp, --mode, --, argv...]: kill-on-close job, stdio passthrough, exit-code mirroring, windows-acl-run: failure signature, grant revocation). read-only = strict zero grants (NUL device not writable; documented). Windows-only execution: exempted from the Linux coverage lane (windowsOnlyCoverageExclusions).
- @deepseek-ai/dsh-sandbox-local: PLATFORM_CHAINS.win32 filled with the windows-acl runner (full enforcement, ACL denial dialect, runner-failure rules).
- @deepseek-ai/dsh-pwsh-sandbox: sandbox-consuming pwsh executor (call-for-call mirror of dsh-bash-sandbox) over a new argv-level seam in dsh-pwsh-local; per-file coverage complete via the fake-provider spec.
- bundle/base: the Windows platform layer mounts the confined pwsh roster - sandbox/policy/fs-sandbox/permission/approval re-enabled, the POSIX bash stack stays disabled.

Co-authored-by: Huo Yaoyuan <huoyaoyuan@hotmail.com>
2026-08-08 01:24:33 +08:00

2.6 KiB

@deepseek-ai/dsh-pwsh-sandbox

English | 中文

Sandbox-consuming PowerShell implementation of the ctx.bash executor seam: every command runs as pwsh -NoLogo -NoProfile -NonInteractive -Command <command> confined through ctx.sandbox, with the selected mode, enforcement, and denial facts stamped on each settled result. The pwsh twin of @deepseek-ai/dsh-bash-sandbox, a call-for-call mirror per the pwsh executor and tool decision — the confinement substance is platform-neutral: on Windows the sandbox seam resolves to the ACL restricted-token runner chain (@deepseek-ai/dsh-sandbox-windows-acl), on Linux/macOS to bwrap/Landlock/Seatbelt.

The executor inherits @deepseek-ai/dsh-pwsh-local's process mechanics and consumes its argv-level seam (argv() / runArgv() / startArgv() / onProcessDone()) to wrap the exact pwsh invocation through the provider. The sandbox policy (mode + workspace root) is NOT this package's config: it rides each call from ctx.sandboxPolicy (tool calls pass the calling session's resolved policy; direct calls fall back to deployment policy).

Behavior

  • danger-full-access: commands run through the local executor unchanged; results carry sandbox: { mode, denied: false }.
  • Confined modes (read-only, workspace-write): the pwsh argv is wrapped by ctx.sandbox.confine(); runner-launch refusal fails closed with SANDBOX_UNAVAILABLE (foreground throw, background runnerFailed fact), and a denied write classifies against the selected backend's denialSignatures into sandbox.denied.

Model Experience

Confinement works, denial surfaces as command failure

The model sees the confined command's own stderr (e.g. Access to the path '...' is denied. under the Windows ACL runner); the tool layer converts classified denials into the standard permission-denied surface exactly as it does for the bash tool.

Known Limitations and Deferred Work

  • Reads are unrestricted on Windows (the ACL runner restricts writes only); the read boundary is documented in @deepseek-ai/dsh-sandbox-windows-acl.
  • The Windows workspace-write temp area is the real temp directory (GetTempPathW), mirroring Landlock's /tmp grant — a per-run private temp would need an env-block rewrite in the runner and is deferred.
  • Windows read-only is strict zero-grant — not even the NUL device is writable; > $null redirection still works (documented in the backend package).