Repository navigation
[Windows] workspace-write 沙箱捕获原生命令输出:子进程 0xc0000142 弹窗 + 输出静默丢失 #9857
Replies: 1 comment
Confirmed at source — and the code's own comment names the boundary your case falls outsideThis is a careful report and the mechanism holds up. I read the package at the current head ( 1. Your point 4 (misclassification) is real, and the source says why
const DENIAL_SIGNATURES = {
bwrap: ['read-only file system'],
landlock: ['permission denied'],
seatbelt: ['operation not permitted'],
// pwsh/.NET: "Access to the path '...' is denied."; cmd: "Access is denied.";
// Node EACCES: "permission denied"; EPERM: "operation not permitted".
'windows-acl': ['access is denied', 'access to the path', 'permission denied', 'operation not permitted'],The comment above the entry shows the list was assembled from in-sandbox file errors — the 2. The mitigation's stated scope is the place to look
The parenthetical is the whole scope of the fix, and it is a scope rather than a caveat: the merged ACE reaches an object only because the object asked the token for its default DACL. A caller that supplies its own security descriptor — or whose object's DACL comes from another path entirely — is outside it by construction. Your "可能的原因 1" (the pipe's security descriptor differs from the assumed path) is therefore not a guess about a bug; it is the one assumption in the code that could be false while everything else still behaves as documented. The call site also shows what the merged SID is ( 3. Your probe D refutes a claim the shipped tool documentation makes
Two halves of that sentence are contradicted by your measurements, and they are separate defects:
The second one is the one that costs something, because the sentence does not merely describe — it instructs: "That EPERM is the documented boundary: do not retry the command another way — escalate the exact command once or restructure it to avoid capturing output." An agent that follows it will escalate a platform defect as if it were a policy boundary, and a host that reads the console will be told the sandbox worked as designed. Whatever is done about the pipes, that paragraph should stop asserting a behaviour on the strength of a host the reports contradict. 4. One correction to your suggestion 5The 0-byte file is not something the harness can make nonzero. PowerShell opens the redirection target itself, before the child is created, and the child then dies during loader initialization — so the empty file and the absent error are both produced on the PowerShell side of the boundary, as your §B control (13662 bytes vs 0) shows cleanly. What the harness can do is your suggestion 4: recognise the child's 5. This and a same-day report are one storyThere is a second report filed the same day from a different host — the I have not run this on Windows, so every measurement above is yours; what I verified in the tree is the denial-signature list and the comment explaining where it came from, the default-DACL grant's documented scope and the SID it actually names, and the tool-documentation sentence asserting that PowerShell's own pipelines are unaffected. |
Uh oh!
There was an error while loading. Please reload this page.
[Windows] workspace-write 沙箱下捕获原生命令输出:子进程 0xC0000142 弹窗 + 输出静默丢失
2de8917c-256b-462f-b3f2-e6bbba668209session-d625bfea-e717-4fbc-8dd1-f7d26776cfd1E:\deepseek-harness\workspaceHarness home:E:\deepseek-harness\.dsh环境
pwsh工具实际由C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe执行D:\Program Files\nodejs\node.exe)@deepseek-ai/dsh0.2.0-rc.2(registrylatest同为 0.2.0-rc.2,无更新可升级)@deepseek-ai/dsh-sandbox-windows-acl0.2.0-rc.2workspace-write(sandbox: workspace-write,approval: ask)摘要
在
workspace-write沙箱下,只要一个原生命令(.exe)的 stdout/stderr 被 PowerShell 捕获(管道
|、赋值$x = cmd、2>&1、重定向>),就会出现下面两种结果之一:Program '<exe>' failed to run: Access is denied;应用程序无法正常启动(0xc0000142),且 PowerShell 不报任何错,重定向目标变成 0 字节空文件。不接管道、输出直通终端时,同一个命令 100% 正常。关闭沙箱后,两种症状都消失。
今天(2026-10-16)系统日志中此类弹窗 52 条:
node.exe34、git.exe7、cmd.exe4、python.exe3、where.exe3、pnpm.exe1。时间分布 11:57–15:22,全部落在 DSH 执行命令的时段。复现步骤(100% 稳定)
A. 主复现:沙箱内捕获原生命令输出
实际结果:三个文件全部 0 字节;桌面弹出 3 个
cmd.exe - 应用程序错误 / 应用程序无法正常启动(0xc0000142);PowerShell 标准错误没有任何输出(静默失败)。B. 对照组:同一条命令,关闭沙箱
对完全相同的三条命令,以
sandbox: danger-full-access运行一次:workspace-write_r1/_r2/_r3.csv= 0 / 0 / 0 字节cmd.exe … 0xc0000142danger-full-access_u1/_u2/_u3.csv= 13662 / 13658 / 13658 字节(完整进程列表)C. 最小复现:接管道即失败,直通即正常
与 node 无关:
cmd/where/whoami/git/python/pnpm表现完全一致。node 最显眼,是因为 DSH 沙箱 runner 本身就是
node.exe([node, runner.js, --workspace, …])且大量命令经 node。D. 根因最小化:沙箱内建不出匿名管道
匿名管道创建被拒,而具名管道正常——这正是 Windows PowerShell 5.1 为原生命令准备 stdio 时
(.NET
ProcessStartInfo.RedirectStandardOutput)使用的对象。系统日志证据
Channel
System、ProviderApplication Popup、Event ID 26(内核硬错误对话框记录):采集命令:
0xc0000142=STATUS_DLL_INIT_FAILED:进程对象已创建,加载器初始化失败,因此由 CSRSS 代弹对话框。影响
“执行命令时总有 node 弹出错误”。
构建 / 导出 / 抓取类命令可能“看起来成功、实际什么都没做”。
npm(npm.ps1内部有$NPM_PREFIX=(& $NODE_EXE …)捕获)、git … 2>&1、任何… | Out-String都会触发。[sandbox: file access denied under workspace-write mode]并提示“可升级权限”,因为windows-acl的拒绝特征串里包含access is denied(dsh-sandbox-local/lib/index.js的DENIAL_SIGNATURES)。排查方向被带偏。机制分析(推测,附代码位置)
dsh-sandbox-windows-acl用CreateRestrictedToken+ Low 完整性运行命令(
lib/types-Cl_DXjhk.js的AclSandbox.init())。源码注释已经点名了这类故障:为此实现了
setTokenDefaultDaclGrant(...)([types-Cl_DXjhk.js:1293]),把 write SID 的full-access ACE 合入受限令牌的 default DACL。
在本环境中该缓解未覆盖 Windows PowerShell 5.1 的原生命令重定向路径,实测表现为上面 A/B/C/D。
可能的原因(供维护者判断):
ProcessStartInfo+CreatePipe,其管道安全描述符与实现里假设的“拿 token default DACL” 的路径不同;
CreateProcess,于是分别落到ERROR_ACCESS_DENIED(CreateProcess 失败)与
STATUS_DLL_INIT_FAILED(子进程起来但初始化失败)两种表象;dsh-tool-pwsh的说明写着 “PowerShell's own pipelines are unaffected”,与实测不符。建议
命名 restricting SID 的安全描述符,或让持有管道的 shell 侧不被限制),使
setTokenDefaultDaclGrant的意图真正覆盖该路径。CreateProcess/ 管道创建失败应作为 runner 级错误上报,不要渲染成“file access denied under … mode”,也不要给出升级权限的提示。
dsh-tool-pwsh中 “PowerShell's own pipelines are unaffected” 需要修正或加限定条件。0xC0000142退出时给出明确诊断,而不是让操作系统弹对话框、让重定向静默产出空文件。
workspace-write下若无法支持管道,至少应让重定向失败报错并返回非零退出码,避免静默空输出。
附:报告人侧的临时探测均已清理
调查期间在 workspace 创建的
_r*.csv、_u*.csv、_tl.csv等文件已全部删除,工作区为空。本报告由 DSH 会话中的 AI 助手依据可复现证据整理,经用户确认后提交到 Discussions(本仓库 Issues 已关闭)。原始会话:
session-d625bfea-e717-4fbc-8dd1-f7d26776cfd1。All reactions