Windows: sandboxed PTY shell (minimal preset) still fails at startup on 0.2.0-rc.1 — ACL runner exits 127 with NULL std handles #8158
EuniceAllen
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
现象
Windows 11 (Build 26200) + DSH 0.2.0-rc.1:Agent 预设
minimal(持久 PTY shell)+ 任意沙箱(read-only/workspace-write)时,每条pwsh都返回Error: PTY shell exited during startup,会话不可用;standard预设或danger-full-access正常。0.1.7-rc.2 上已于 2026-09-25 通过应用内反馈提交,0.2.0-rc.1 复测仍 100% 复现。根因(代码定位 + 实测)
沙箱下 PTY 后端把
[DeepSeek Harness.exe, …/dsh-sandbox-windows-acl/lib/runner.js, …]当 ConPTY 子进程,即 GUI 子系统的桌面 exe(ELECTRON_RUN_AS_NODE=1):GetStdHandle(-10/-11/-12)= 0/0/0,GetLastError()=6ERROR_INVALID_HANDLE(而 libuv fd 0/1/2 正常指向 ConPTY)。@deepseek-ai/dsh-win32-processlib/index.js→inheritedStandardHandles()(~L551-566)必须用这些句柄填STARTUPINFO(STARTF_USESTDHANDLES) 再CreateProcessAsUserW(受限路径 ~L693)→ 第一步就失败,exit 127;同包非受限路径targetCarrierHandles()(~L572-582)用uv_get_osfhandle且工作正常 —— 两条路径取句柄方式不一致就是 bug。[process.execPath, runner.js](dsh-sandbox-localwindowsAclRunnerInvocation()~L539-553);app.asar.unpacked内没有该包,也没有配置windowsAclRunnerEntry。dsh-terminal-bash只从confine()取.argv(~L968-971)并抛通用错误(~L501 / ~L989);管道型沙箱(dsh-bash-sandbox/dsh-pwsh-sandbox)会消费runnerFailureRules,PTY 路径不会。PLATFORM_CHAINS.win32 = ["windows-acl"]),不做功能探测,因此不会 fail-closed。实测(2026-09-28,同一台机器,0.2.0-rc.1)
node.exe:504/508/512,type=2)--mode read-only→ cmd--mode workspace-write(seam SID)→ cmdcmd /c echo补充:若 ConPTY 改由控制台子系统的
node.exe创建,GUI 子进程能拿到有效句柄、runner 也能镜像子进程退出码,但受限子进程的 stdout/stderr 仍到不了 PTY(0 字节),那条路同样不可用。最小复现
父进程必须是 GUI exe(否则不复现;控制台
node.exe当父进程时走的是上面那条"无输出"路径):脚本(A 对照 / B read-only / C workspace-write,read-only 不改任何 ACL)我放在下面回复里,避免正文过长。
建议修法
dsh-sandbox-windows-acl(+dsh-win32-process/dsh-subprocess/koffi/@koromix/koffi-win32-x64)落盘到resources/app.asar.unpacked,用自带resources/runtime/primary-runtime/dependencies/node/bin/node.exe启动runner.js。inheritedStandardHandles()加uv_get_osfhandle兜底;注意这只消除 127,GUI 宿主下子进程输出仍到不了 ConPTY,接线也要一起修。runnerFailureRules(或至少透出 runner stderr),不要把沙箱启动失败报成PTY shell exited during startup。windows-acl+ PTY 做探测/fail-closed,或明确标注 Windows 上minimal+ 沙箱暂不支持。其他
diagnose-windows-sandbox-acl技能不覆盖此类问题(只处理 ACL 拒绝访问)。cmd.exepayload 一样 127,失败发生在任何 shell 被拉起之前。standard预设或danger-full-access。EN TL;DR
minimalpreset + any sandbox mode (read-only/workspace-write) fails everypwshcall withError: PTY shell exited during startup;standardordanger-full-accessworks. Reported in-app on 2026-09-25 against 0.1.7-rc.2 — still 100% reproducible on 0.2.0-rc.1.DeepSeek Harness.exe(node mode) as the ConPTY child. In the product's configuration itsGetStdHandle(-10/-11/-12)are NULL (0/0/0,ERROR_INVALID_HANDLE), so the ACL runner dies ininheritedStandardHandles()(dsh-win32-process~L551-566, used byCreateProcessAsUserW) withwindows-acl-run: GetStdHandle failed (Win32 0): null stdin handle→ exit 127. The same file's unrestricted path usesuv_get_osfhandleand works.dsh-terminal-bashonly takes.argvfromconfine()and reports the generic message, swallowing the runner diagnostic that the pipe-based sandboxes do consume.cmd /c echounder the same ConPTY works.dsh-sandbox-windows-aclunderapp.asar.unpackedand launch it with the bundlednode.exe), plus anuv_get_osfhandlefallback and surfacing runner failures on the PTY path.BUG报告.md
GitHub发帖-PTY沙箱-0.2.0-rc.1.md
GitHub发帖-回复1-复现脚本.md
GitHub发帖正文.md
Uploading PTY-启动失败-实测结论.md…
All reactions