Repository navigation
Replies: 8 comments
|
补充数据:同一根因,但表现为必现,且受限 shell 本身起不来 环境:Windows 10 Pro for Workstations 22H2(build 19045);官方签名的 DeepSeek Harness 桌面版, 现象:经 pwsh 工具执行任意命令(如
四组对照实验(逐个排除嫌疑):
假设 | 结果
-- | --
低完整性(Low IL)本身 | ✅ 正常 —— Sysinternals PsExec 启动 S-1-16-4096 子进程成功跑起 pwsh 7.6.6(exit 0)
shell 版本 | ❌ 无关 —— 本机原未装 PS7(解析到 5.1);安装 7.6.6 并完整重启后,从 DSH 内部确认已解析到 pwsh 7.6.6 / PSEdition Core,仍 0xC0000142
第三方 DLL 注入 | ❌ 无关 —— AppInit_DLLs 空且 LoadAppInit_DLLs=0(64/32 位)、无 AppCertDlls、无 IFEO Debugger;pwsh 进程模块表中无任何第三方 DLL
启动器的控制台继承 | ❌ 无关 —— 改为从已打开的 PowerShell 窗口启动应用(父进程非 explorer),仍失败
另核对:工作区根 SDDL 含沙箱的常驻 capability ACE(形如 指向:该后端 token 模块自己写明「受限子进程必须共享宿主控制台;在受限令牌下自行创建 conhost 会以 关键:修复已经写好了,只是没进发行版。 桌面仓库存在提交 但对已安装的 请求:
最小复现: 代码块 |
|
补充数据 —— 0.2.0-rc.2(桌面版 / Win10 19045)上仍然 100% 必现,且 #1344 的修复已经内置 环境 $PSVersionTable.PSVersion.ToString() → (无输出) [exit code: 3221225794] Error: sandbox mode "workspace-write" is requested but no sandbox backend is usable on this host; 对已发行包做的静态核对(以下是新增部分) 与 DSH 无关的独立 Win32 复现 令牌 完整性 退出码D1 复制令牌,不加 restricting SID 原样(High) 7(成功) 没有任何 restricting-SID 组合能修好它。 我把 whoami /groups 里的全部组 SID 加上 保活对都塞进去试过,仍然是 0xC0000142。这与维护者「S-1-2-1 不是杠杆」的判断一致。 有一个数据点我复现不出:下方评论里 PsExec -l(低完整性)是成功的。那条路径并不在调用者 令牌上走 CreateProcessAsUserW / CreateProcessWithTokenW,而是在新会话里重新登录出一个 新令牌 —— 这能解释差异,而非与本文矛盾。 请求 |
|
A distinct failure point that sits behind the one above: the confined shell starts, then every output-capturing command dies I read the D1–E5 matrix above before posting. It is a solid characterisation of what I'll call failure A, and I'm not disputing any of it — least of all D2 ("no restricting SIDs, Low IL, console-less parent → But that matrix structurally cannot observe what I hit, and the reason is worth stating up front:
The failure below happens later: inside a confined shell that started successfully, at the moment it spawns something and tries to capture the output. It is only reachable on a host that has a console, because A kills the shell first everywhere else. That is why it needs its own report instead of a comment on the matrix.
My host is …and yet, before the fix, that same shell returned empty output for Failure B: minimal reproductionAdd-Type -TypeDefinition @'
using System;
using System.Runtime.InteropServices;
public class Repro {
[DllImport("kernel32.dll", SetLastError=true)]
public static extern bool CreatePipe(out IntPtr r, out IntPtr w, IntPtr sa, uint n);
[DllImport("kernel32.dll")] public static extern bool CloseHandle(IntPtr h);
public static string T() {
IntPtr r, w;
bool ok = CreatePipe(out r, out w, IntPtr.Zero, 0);
int e = Marshal.GetLastWin32Error();
if (ok) { CloseHandle(r); CloseHandle(w); return "OK"; }
return "FAIL err=" + e;
}
}
'@
[Repro]::T() # -> FAIL err=5Note the difference from the matrix above: here the pipe is created by the confined process itself, with
It is a write access check, and it happens before the target executable is opened — which is why a non-existent program also returns So the shell is fine and every output-capturing spawn dies. Root cause:
|
| ACE | pass-1 (normal SIDs) | pass-2 (restricting SIDs) |
|---|---|---|
| capability SID | ❌ not a normal SID — ignored | ✅ recognized |
| Administrators | ❌ absent from the token | ❌ not in the restricting list |
| SYSTEM | ❌ | ❌ |
| logon SID | ✅ but mask 0xA0000000 = GENERIC_READ|GENERIC_EXECUTE — no write |
✅ |
The check dies at pass-1.
setTokenDefaultDaclGrant's own comment describes this bug — but diagnoses it one pass off:
…which names no restricting SID: a new anonymous pipe (child stdio) therefore fails the write pass-2 check at creation (ERROR_ACCESS_DENIED; Node surfaces it as spawn EPERM), breaking every piped-stdio grandchild spawn.
So it deliberately names a restricting SID. A capability SID is invisible to pass-1, and the only dual-membership SID already present (the logon SID) has no write bit.
This also explains why read-only is unaffected: there the expression degrades to worldSid (Everyone). Only workspace-write breaks.
Measurements with a given Default DACL shape, then write-opening the pipe:
D:(A;;GA;;;WD) -> write-open OK
D:(A;;GA;;;S-1-4-...-1) [DSH's pick] -> FAIL err=5
D:(A;;0xA0000000;;;S-1-5-5-0-...) -> FAIL err=5
D:(A;;GA;;;S-1-5-5-0-...) -> write-open OK
exact replica of the live DACL -> FAIL err=5
D:(A;;GW;;;WD) -> FAIL err=5
Note this is untouched by the matrix above: it stays broken with the full restricting list, and it stays broken with no restricting SIDs at all, as long as the Default DACL names only the capability SID.
The fix — one line
- setTokenDefaultDaclGrant(api, restrictedToken, this.tempWriteSidPtr ?? this.writeSidPtr ?? worldSid);
+ setTokenDefaultDaclGrant(api, restrictedToken, worldSid);Everyone is in both the normal SIDs and the restricting list, so both passes succeed.
This does not touch the restricting list. Everyone is already in it — buildRestrictingSids is called with [logonSid, known.world, ...writeSids]. Only the Default DACL changes, and that governs new kernel objects created without an explicit descriptor (anonymous pipes, events, mutexes). File security comes from the parent directory's inheritable ACEs plus the Low mandatory label and never consults the Default DACL — measured after the patch:
inside workspace write => OK (good)
outside write => DENIED (good)
private temp write => OK
workspace SDDL still carries (A;OICI;0x110156;;;S-1-4-763765751-720698234)
Verified
Through the real runner (runner.js --mode workspace-write, caller stdio inherited):
node --version => 'v24.21.0' lastExit=0 <- empty before
cmd /c echo => 'NATIVE-CMD-OK' <- empty before
Process.Start(redirect) => OK exit=7 <- Win32Exception(5) before
CreatePipe(NULL) => OK <- FAIL err=5 before
outside write => DENIED (good)
runner.js is spawned fresh per tool call, so the patch takes effect on the next call — no restart.
Why this still matters after the console fix ships
Console allocation only addresses A. Once a confined shell survives startup on a console-less host, the first output-capturing spawn inside it hits B. A's remedy is the gate before this one, not a substitute.
(Inference, flagged as such: my host has a console, so I could not measure "A fixed ⇒ B exposed" on the desktop app.)
One documentation nit, since it is what sent me down the A path first: "a grandchild that tries to capture output through named-pipe stdio can fail with EPERM… Ordinary PowerShell pipelines use anonymous pipes and are a different path". In my measurements the failing call is the anonymous-pipe path (CreatePipe with NULL attributes), and the failure is a flat ERROR_ACCESS_DENIED, not an EPERM surfaced by Node. Microsoft's Anonymous Pipe Security and Access Rights confirms anonymous pipes take the caller's Default DACL, which is the whole mechanism here.
Environment: Windows x64, single local user, UAC disabled; @deepseek-ai/dsh 0.2.0-rc.2 (also 0.1.5-rc.3); workspace-write; shell host Windows PowerShell 5.1; diagnose-windows-sandbox-acl → VERDICT=NOT_THIS_CLASS.
|
Adding a data point that does not fit the 2x2 in the thread. Windows 10 x64 (19041), DSH desktop 0.2.0-rc.2,
So there is at least one configuration where a non-elevated Electron runner still |
|
Same signature here — and the mode split is what made it isolable. Environment (sensitive identifiers removed): Windows 11 x64, DSH desktopVersion 0.2.0-rc.2 (nightly feed), Node 24.21.0, workspace on local NTFS, %TEMP% exists and is user-writable, no AV/EDR/folder-protection hooks. User is a local administrator running elevated. Repro without a DSH session (the runner lives inside app.asar, so it needs the app's own Electron binary; this is the same invocation dsh.cmd uses): powershell $env:ELECTRON_RUN_AS_NODE = 1 read-only -> exit 0, child prints its line& $exe --expose-internals $runner --workspace $ws --temp $env:TEMP --mode read-only -- cmd /c "echo child-alive" workspace-write -> exit 3221225794 (0xC0000142), NO stdout, NO stderr& $exe --expose-internals $runner --workspace $ws --temp $env:TEMP --mode workspace-write -- cmd /c "echo child-alive" What I could rule out Not the TMP/TEMP rewrite. Running --mode read-only with the runner's own TMP/TEMP pre-pointed at a fresh private directory still exits 0. Probably relevant to your STARTF_USESHOWWINDOW/SW_HIDE finding: the design note states "hidden-console children die with STATUS_DLL_INIT_FAILED; children share the host console". If that interaction is privilege- or token-sensitive, the extra capability SIDs may be what tips it over in workspace-write only. Confirmed still present upstream: master builds the token with DISABLE_MAX_PRIVILEGE | LUA_TOKEN | WRITE_RESTRICTED and the same mode-selected restricting lists (packages/sandbox/sandbox-windows-acl/src/token.ts), and src/spawn.ts still delegates to the same spawnPipedProcess / spawnInheritedJobProcess. Impact: workspace-write — the mode an approval-disabled session defaults to — is unusable here, so "unattended and confined" is not selectable; users must drop to read-only (no writes) or danger-full-access (no confinement). A fail-closed rung should surface a structured runner failure instead of a bare 0xC0000142 with no diagnostics. Unrelated but found in the same rung (worth fixing on its own): in read-only, every confined pwsh call emits two spurious stderr errors because the executor's ENCODING_PREAMBLE uses [System.Text.UTF8Encoding]::new($false), which is a type-creation expression and is rejected under the ConstrainedLanguage that read-only enters. New-Object System.Text.UTF8Encoding($false) is the CLM-safe spelling already used elsewhere in the codebase. This noise is what initially obscured the 0xC0000142 diagnosis. |
|
Following #1847 and #810, adding a data point for a newer OS build: Windows 11 build 26300 (26H2), where this is 100% reproducible. Root cause closed from the shipped sourcesThe mechanism is the documented console requirement, not a build-specific regression. In the installed 0.2.0-rc.2 sources:
The sandbox therefore requires an existing console for the restricted child. The desktop host is a GUI process with no console, so every That fix is not in the shipped So the actionable item is the release, not further OS-version archaeology. Reproduction
# | Condition | Result
-- | -- | --
1 | workspace-write, Write-Output "hello" via the pwsh tool | fails, exit 3221225794 (0xC0000142)
2 | Same command from a sub-session (subagent) | fails identically → not per-session state
3 | Same command with one-shot full access | succeeds immediately
4 | Session switched to full access, all commands retested | all succeed; failure gone
Request
Not a request for fail-open, and I am not suggesting adding
|
|
补充数据:把 0xC0000142 收敛到唯一变量——TokenDefaultDacl 的 trustee SID 方法:用 Electron-as-node 直接加载已发行 app.asar 中的 AclSandbox(manageDacls:false,零 ACL 写入),
结论:触发条件唯一 = Default DACL 的授权 SID 是 S-1-4-x-y(SECURITY_NON_UNIQUE_AUTHORITY,pass-1 不可见)。 已发行版核对:0.2.1-rc.2 的 app.asar 中仍为 建议:
复现附件:sandbox-bisect.mjs(只读 ACL,Electron-as-node 加载 app.asar)+ 预期输出矩阵。 |
Uh oh!
There was an error while loading. Please reload this page.
DSH Windows ACL 沙箱在 Windows 10 上受限令牌进程启动失败(0xC0000142)
环境
操作系统:Windows 10(build 19041,PowerShell 5.1.19041.4170)
DSH:web 模式(127.0.0.1:3080),会话沙箱模式 workspace-write
安全软件:Windows Defender 实时保护已关闭(用户确认一直关闭);360 仅存 ELAM 驱动 360elam64.sys(无完整 360 安全卫士组件)
工作区:D:\DSH(ACL 干净:9 条 ACE,仅 1 条工作区写 SID S-1-4-…)
现象
workspace-write 模式下,从受限 pwsh 会话内启动外部程序间歇性失败:
where.exe、cmd.exe、python/py、node、tesseract、powershell.exe(子进程)启动即失败
部分进程弹出 "应用程序无法正常启动 (0xC0000142)" 对话框;部分静默无输出
Start-Process cmd.exe -Wait 观察到退出码 -1073741502(= 0xC0000142,STATUS_DLL_INIT_FAILED)
PowerShell 内置受限令牌不可用的命令也被拒:Get-NetTCPConnection(拒绝访问)、Get-CimInstance(静默失败)——与 README 记录的"Authenticated Users 不在 restricting 列表,故 CIM 不可用"一致
时序:会话早期大量 py 调用全部成功(数十次),随后持续失败;重启 dsh web 服务无效;切换 danger-full-access 后全部恢复正常;切回 workspace-write 再次失败
D:\DSH ACL 无累积(排除授权条目膨胀损坏 DACL)
怀疑根因
WRITE_RESTRICTED 受限令牌的 restricting-SID 列表(登录 SID + Everyone + 工作区写 SID)在 Windows 10 上与 Windows 11 26200 行为不一致:
README 明确"verified on Windows 11 build 26200",且将 0xC0000142 记录为受限令牌的已知边界("控制台隔离不可用……子进程在 DLL 初始化期间以 STATUS_DLL_INIT_FAILED 死亡")

受限令牌缺少控制台登录 SID(S-1-2-1)/INTERACTIVE/Authenticated Users;README 记录了 S-1-2-1 在 Win11 26200 上的无效实验,但 Win10 加载器对控制台/DLL 初始化检查可能不同
间歇性(早期可用、后期失败)表明存在令牌构造或加载器状态相关的竞态,在 Win10 上更敏感
复现
会话沙箱模式 = workspace-write(Windows 10,19041)
执行 py --version 或 where.exe cmd(从 DSH pwsh 工具)
观察:进程无输出/弹出 0xC0000142 对话框,Start-Process 变体返回 -1073741502
期望
workspace-write 模式下外部进程(where/cmd/python 等)可稳定启动,或
提供关闭受限令牌执行的配置项(fail-open 开关),或
提供 Win10 专用的 keep-alive restricting-SID 组合(如加入 S-1-2-1)验证是否消除 0xC0000142
备注
WER HKCU...\Windows Error Reporting\DontShowUI=1 已设置,无效(0xC0000142 为加载器对话框,非 WER 路径)
danger-full-access 模式无此问题(不走受限令牌)
All reactions