Repository navigation
feat(windows): 检查工作区能否授予沙箱权限并提供修复 - #139
Merged
freedomkk-qfeng merged 2 commits intoOct 13, 2026
Merged
Conversation
DSH 的 Windows 沙箱在受限执行前要改写工作区根的 DACL 与完整性标签,需要 WRITE_DAC 和 WRITE_OWNER。直接建在 C:\ 根目录下的文件夹只继承“修改”,默认 沙箱中的命令全部以 SetNamedSecurityInfoW (Win32 5) 失败。 Windows Electron 版的 Host 在启动和登记新工作区时,以这两项权限打开工作区根 目录来检查(不做修改)。缺少权限时经原生桥请桌面端询问用户,同意后运行 DSH 随包的 diagnose-windows-sandbox-acl 脚本,仅限该工作区根,不提权,改动有备份 和恢复命令。同一路径每次运行只询问一次,对话框依次弹出。
freedomkk-qfeng
added a commit
that referenced
this pull request
Oct 13, 2026
fix(windows): 按实际失败修复工作区沙箱权限,取消启动时强制改 ACL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Windows 上若工作区位于
C:\根目录下自建的文件夹(如C:\Projects\demo),默认沙箱中的 pwsh 命令全部失败:SetNamedSecurityInfoW failed (Win32 5): grantWrite(...)。#119 精简验证中发现,0.4.2 原包同样复现;#132 处理的是 Electron 运行文件的 AppContainer 权限,与此无关。原因
DSH 0.2.0-rc.2 的
@deepseek-ai/dsh-sandbox-windows-acl在受限执行前为工作区根写入能力 ACE 和 Low 完整性标签,需要WRITE_DAC与WRITE_OWNER;该包 README 写明缺少时直接失败,而不是跳过隔离。C:\根目录默认只给 Authenticated Users“修改”,Administrators 的完全控制在非提权令牌中仅用于拒绝。用户在其下新建的文件夹归用户所有(隐含WRITE_DAC),但没有WRITE_OWNER。用户配置文件下的文件夹继承用户的“完全控制”,不受影响。改动
desktop-services/lib/workspace-access.js,仅在 Windows Electron 配置中插入:Host 启动及登记新工作区时,用 DSH 共享的 Win32 绑定以WRITE_DAC | WRITE_OWNER打开工作区根目录检查,不做修改;拒绝访问时经原生桥请求桌面端处理。同一路径每次运行只询问一次,对话框依次弹出;路径不存在等其他情况不提示。dsh-electron/src/workspace-access.mjs与原生桥/v1/desktop/workspace-access:显示原生确认框,用户同意后用系统 Windows PowerShell 运行 DSH 随包的diagnose-windows-sandbox-acl.ps1。-Path与-AllowRoot都是该工作区根,备份和恢复命令写到日志目录的workspace-access/;失败时提示记录位置。修复逻辑完全复用 DSH 脚本,不提权。build-shell.mjs的 Electron 源码清单;docs/USER_GUIDE.md补充说明;新测试接入validate-pinned-dsh-source(Windows 与 macOS,使用固定 Runtime)。验证
Windows 11 ARM64(Parallels,x64 仿真),非提权的管理员账户。使用 0.4.2 Windows 包中的 Node 与 DSH 0.2.0-rc.2 模块,运行本分支的 Host 插件
apply()、原生桥和桌面端修复模块;只有原生对话框是桩,按路径选择调整或不调整:AclWriteGrantC:\<新建目录>\workspaceC:\<另一新建目录>\workspace%USERPROFILE%\<新建目录>\workspace另单独确认:不存在的路径返回 unavailable(Win32 2),不提示;DSH 脚本在 Windows PowerShell 5.1 下判定缺少
WRITE_OWNER,补上权限并复核通过(GRANTED=1)。dsh-electron、dsh-host、desktop-services与根目录测试在 macOS 上的失败项与 main 相同(5 项既有的/var路径问题)。--verify-receipt。未测:真实 Electron 窗口中的对话框显示与启动时机;完整桌面包在 Windows 上的安装运行;原生 Windows x64;其他 NTFS 卷(如
D:\)根目录下的文件夹。