Repository navigation
DSH Windows sandbox 0xC0000142 — community fix recipe #10046
Replies: 2 comments
|
Your root cause lands on the exact line, and it matches a measurement set we published separately — so here is the confirmation plus the two things the recipe does not say, both of which change how it should be applied. The line, at
|
|
logonSid verified — narrower than I can confirm the diagnosis in the OP and I can close the "logonSid — unverified" gap: What actually failsThe confined child is spawned with The capability/workspace SID (
The logon SID ( Verification matrixReproducer: standalone C# P/Invoke, no DSH involved —
Other controls: Verified live, without touching
|
Uh oh!
There was an error while loading. Please reload this page.
TL;DR (English)
On Windows, with the default
workspace-writesandbox mode, everypwshtool call fails with no output and exit code3221225794=0xC0000142(STATUS_DLL_INIT_FAILED), whileread-onlyanddanger-full-accesswork.Root cause:
AclSandbox.init()merges the capability SID (workspace/temp write SID) into the restricted token's default DACL. Underworkspace-writethat default DACL then names no keep-alive SID, so objects the confined child creates (including the stdio pipe) cannot be accessed by the console host / DLL-init components — the child dies early.Workaround: merge Everyone (
worldSid) instead of the capability SID. One same-length byte replacement:Apply with
patch-asar.js(in this repo), restart DSH, then verify. A better upstream fix is to uselogonSid, which is narrower than Everyone — but it is unverified so far.中文摘要
Windows 上
workspace-write(默认档)下所有pwsh调用零输出、退出码0xC0000142(STATUS_DLL_INIT_FAILED);read-only与danger-full-access正常。根因:
AclSandbox.init()把能力 SID(工作区/临时写 SID)合并进受限令牌的 default DACL。workspace-write下该 default DACL 里没有 keep-alive SID,受限子进程新建的对象(含 stdio 管道)无法被控制台宿主 / DLL 初始化组件访问,子进程在初始化阶段死亡。临时修法:把合并的 SID 改成 Everyone(
worldSid),做一次等长字节替换;重启 DSH 后按 §4 验证。上游正解建议改用logonSid(比 Everyone 窄),但尚未验证。0. 先判断:你是否受影响,是否已经修好
症状(三选一即可复现):
workspace-write下pwsh工具执行echo hi→ 无输出,退出码3221225794;danger-full-access后同一命令正常;read-only模式正常。先别改文件。先做两项只读检查:
若你的设备是 CLI / npm 安装(不是桌面版),受影响文件不是
.asar,而是:用
npm root -g确认路径;下面的脚本对普通.js文件同样适用。1. 修复(两种形态)
1.1 桌面版(
app.asar)前置条件:
patch-asar.js保存到本机任意目录(下文用.\patch-asar.js指代),或用它的完整路径;resources\目录有写权限(装在 Program Files 时需管理员);node --version可用)。1.2 CLI / npm 安装(
node_modules内的lib/index.js)1.3 不用脚本时的等价手工步骤(仅适合能精确编辑二进制的人)
setTokenDefaultDaclGrant(api, restrictedToken, this.tempWriteSidPtr ?? this.writeSidPtr ?? worldSidworldSid+ 39 个空格 覆盖其中的this.tempWriteSidPtr ?? this.writeSidPtr ?? worldSid(保持总字节数不变);2. 脚本的安全约束(
patch-asar.js)<target>.bak-<timestamp>);--check/--dry-run完全不写文件;3. 不要盲目执行:给 AI/自动化代理的停止条件
如果由 AI 读取本文并操作:
--check),再决定是否写;0.2.0-rc.2、0.2.1-rc.2)不同且--check结构不符;4. 验证矩阵(必做)
在
workspace-write会话(DSH_PERMISSION_MODE未设置)中:echo hi$PSVersionTable.PSVersionC:\Windows\Temp\dsh-probe.txtecho ok | Measure-Objectwhoami /groupsLow Mandatory Level,说明受限令牌仍在第 4 项是关键:它证明修复的是沙箱本身,不是绕过沙箱。若第 4 项也能写,说明围栏失效,立即回滚。
5. 回滚
workspace-write的 shell 会重新不可用(故障重现,不是新问题)。6. 风险与限制
app.asar,补丁失效,需重打0.2.0-rc.2/0.2.1-rc.2上验证;其他版本先--check7. 给上游的建议
setTokenDefaultDaclGrant合并的 SID 应选保活组 SID:优先logonSid(登录会话级,比 Everyone 窄);若不可行再退回worldSid并注释权衡;cmd.exe/pwsh必须成功;覆盖Electron 宿主、无控制台宿主、workspace-write + 控制台子系统叶命令;0xC0000142死亡时按沙箱失败上报(附 restricting SID 列表 / 完整性级别 / flags / default DACL 合并 SID),不要只回传裸退出码;danger-full-access。8. 证据与引用
dsh-windows-sandbox-0xC0000142-report.mddsh-windows-sandbox-0xC0000142-fix-plan.mdsetTokenDefaultDaclGrant的 SID 选择,worldSid端到端有效,并建议logonSidCreateProcessAsUserWvsPROC_THREAD_ATTRIBUTE_TOKEN的对照结论如果本文对你有帮助,请回帖报告:Windows 版本、DSH 版本、安装形态(桌面/CLI)、
--check输出、验证矩阵结果。这些信息能帮助上游确定修复范围。9.附件代码
patch-asar.js如下
All reactions