Preface¶
DSH’s workspace-write sandbox enforces a Low integrity label on the workspace root directory and its entire subtree on Windows. These labels persist on the file system after the session ends. Programs launched from that directory run with Low integrity, which can cause configuration directory write failures, missing tray icons, SmartScreen prompts, Electron application startup crashes, and denied workspace file deletion. xia-sc/dsh-workspace-integrity is a Windows-only DSH plugin package that remediates these residual Low integrity labels and provides a Chinese-language integrity panel, a workspace_integrity agent tool, rollback records, and automatic cleanup.
Plugin Overview¶
Developed by the maintainer xia-sc, this plugin is categorized under admin-security. Its plugin registration name is @xia-sc/dsh-workspace-integrity, and its npm package name is @xia-sc/dsh-workspace-integrity. It supports only the Windows platform, and the panel body is fixed to Chinese. The plugin provides three remediation entry points: automatic cleanup, the UI panel, and the agent tool. All three share the same host implementation to ensure consistent behavior.
Core Features¶
- Automatic cleanup: When a session switches to
danger-full-accessmode, the plugin performs a one-time label restoration on the current workspace. If the root directory is already Medium, it idempotently skips—no scanning, no record writing, no tree traversal. - Integrity panel: Select “Integrity” from the session header tab row to view the current workspace status. The panel supports scanning (read-only view of Low objects,
S-1-4sandbox ACEs, and Everyone delete-denial ACEs), remediation (requires a second confirmation; a third confirmation is needed if the session is still inworkspace-writemode), verification, and rollback. The panel also displays the timestamp and source of the last cleanup for this workspace. - Agent tool: Provides the
workspace_integritycommand with actions includingscan,fix,verify,rollback, andrecords. Parameters includepath(absolute path; defaults to the current session workspace if omitted),removeAces(removes non-inheritedS-1-4-*ACEs and Everyone delete-denial ACEs),allFiles(scans all files),excludeDirs(an array of directory names or relative path prefixes to skip for this run),fast(skips pre-scan, only recursively resets the root label, does not remove ACEs),force(forces remediation while the session is still inworkspace-write), andwhatIf(returns a plan only; no records written, no ACL changes). - Rollback records: Before remediation, the DACL of the root directory and the DACL of each affected object are saved. Records include the source (automatic/manual/tool) and whether a pre-scan was performed. Rollback restores the root DACL and Low labels from the record.
- Security gate and concurrency protection: If the calling session is in
workspace-writemode andforceis not explicitly passed, the remediation is rejected. Only one remediation is allowed per workspace, both in-process and cross-process, enforced via a lock file for exclusivity. - Status visibility and cooldown persistence: The panel displays the “last cleanup” timestamp and source for the workspace; the automatic cleanup cooldown state is written to
%DSH_HOME%\dsh-workspace-integrity\workspace-integrity.state.json, preventing re-triggering after plugin reload. - Dry run and dangerous path protection: Using
whatIf: trueor the script-WhatIfflag returns a plan without modifying ACLs. Dangerous paths such as drive roots,%SystemRoot%,%ProgramFiles%,%ProgramData%, and the user profile root are rejected by default. - Scan scope exclusion and plugin detail page settings:
.git,.hg, and.svndirectories are skipped by default; exclusions can be configured by directory name or relative path prefix. On the plugin detail page, you can toggle automatic cleanup, scan all files, remove sandbox ACEs during remediation, and edit excluded directories. Saved settings are written to%DSH_HOME%\dsh-workspace-integrity\config.jsonand take effect immediately.
Installation and Activation¶
Install from npm (recommended):
plugin_manager({ action: 'install_bundle', target: '@xia-sc/dsh-workspace-integrity' })
You can also enter the same package name under Plugins → Add Plugin.
Install from a local directory (development):
plugin_manager({ action: 'install_bundle', target: 'E:\\path\\to\\dsh-workspace-integrity' })
Local directory installation links the entire directory. After making changes, you must restart dsh (or let the plugin manager reload) to load the new host module and browser bundle. The plugin is enabled by default after installation.
Typical Usage¶
Integrity panel workflow:
- Open any session and select “Integrity” from the header tab row (Conversation / Trace / …).
- The panel opens with the current session’s workspace by default (follows
working_directoryswitches). - Click “Scan” (read-only) to view Low objects,
S-1-4sandbox ACEs, and Everyone delete-denial ACEs. - Click “Fix”—this requires a second confirmation (click again within 4 seconds). If the session is still in
workspace-writemode, the button changes to “Fix Anyway (will interrupt this session’s writes)” and requires a third confirmation. - Use the rollback records to restore the root DACL and Low labels per record.
Agent tool examples:
workspace_integrity action=scan path=E:\my-workspace
workspace_integrity action=fix path=E:\my-workspace
workspace_integrity action=verify path=E:\my-workspace
workspace_integrity action=records
workspace_integrity action=rollback backupDir=C:\Users\me\AppData\Local\dsh-workspace-integrity\backup-...
Configuration¶
The plugin configuration file is located at %DSH_HOME%\dsh-workspace-integrity\config.json and is auto-generated on first mount:
{
"autoClean": true,
"removeAces": false,
"scanAllFiles": false,
"excludeDirs": [".git", ".hg", ".svn"]
}
Configuration precedence (lowest to highest): built-in defaults → plugin config in the profile’s cordis.patch.yml → config.json in the data directory. Normally, modify settings on the plugin detail page or edit config.json directly. cordis.patch.yml is only responsible for inserting the plugin into the loader tree and no longer writes config, avoiding mutual overrides between the two locations. Changes saved on the detail page take effect immediately; manual file edits require restarting DSH (or reloading the plugin) to take effect.
Configuration options:
autoClean: Defaults totrue. Automatically cleans the current workspace when a session switches todanger-full-access.removeAces: Defaults tofalse. During remediation, also removes non-inheritedS-1-4-*ACEs and Everyone delete-denial ACEs.scanAllFiles: Defaults tofalse. Scans all files rather than only common executable extensions.excludeDirs: Defaults to['.git', '.hg', '.svn']. Skips these directories (matched by directory name at any level, or by relative path prefix from the root); the root directory itself is always checked.
The panel uses these values as initial checkbox states. A single operation can override them, but changes are not written back to the configuration. The panel footer displays the currently active configuration file path.
Behavioral Design Notes¶
- Automatic cleanup listens for the
sandbox/modeevent; it idempotently skips if the root label is already Medium. - Automatic cleanup, the panel, and the tool all resolve the directory through the same
sessionWorkspace()function (working_directorytakes priority, falling back to the session launch directory). - Manual remediation returns “no changes” directly when not removing ACEs and the root is not Low.
fastandremoveAcescannot be combined (fast does not pre-scan); the script rejects this combination, and the host explicitly downgradesremoveAceson the fast path with a warning. fixis rejected by the host when the calling session is inworkspace-writeandforceis not passed.fix,rollback, and automatic cleanup share a per-workspace lock (in-process Map + cross-process lock file); running the script directly uses a separate.lockmutex.- If label restoration fails or the root remains Low, ACE removal is not proceeded with, and
acesSkippedis written into the result and record. - Non-fast remediation reports success only if a re-scan shows
low,sandboxSid, andeveryoneDenyall at 0; scan truncation also counts as incomplete. - Rollback records include
requestedRemoveAces/removeAces/fast/trigger/truncated/removedAces/acesSkipped/ok. Each affected object’s DACL is saved before removal. excludeDirstakes effect before entering subtrees. Excluded directories are not counted, not reported as hits, and not removed; the root directory itself is always checked.- The panel renders at most 500 entries in the hit list; beyond that, it shows “Showing first N entries only.”
Known Limitations¶
- Windows only: Modifying mandatory integrity labels requires
WRITE_OWNERorSeRelabelPrivilege; drive roots owned by Administrators will return Access denied and require an elevated shell. - Do not remediate while a
workspace-writesession is still writing to the workspace: Low tokens inside the sandbox require Low labels to write; changing to Medium prematurely will cause that session to lose write permission. Automatic cleanup only triggers after switching todanger-full-access. - DSH does not re-label: Workspace authorization is cached per provider lifecycle. Sessions continuing to use
workspace-writeafter remediation will keep failing to write until DSH is restarted or a different workspace is used. - Idempotent skip: Manual remediation scans the subtree first and only skips if no Low objects exist in the entire tree. If the root is Medium but child objects still have Low labels, remediation proceeds.
fastautomatic cleanup does not pre-scan and only checks the root; residual child object labels require manual remediation. removeAcesmodifies DACLs: Only explicit ACEs matching the DSH sandbox shape are removed (S-1-4-x-y/S-1-4-x-y-1allow,GRANT_MASK, OI|CI; Everyone’sFILE_DELETE_CHILDdeny, CI). Inherited entries are left to the parent. Object DACLs are saved before removal and can be restored via rollback. This may still restore a restricted process’s ability to delete files outside the workspace—use only when you genuinely intend to hand over the directory.- Rollback records: The root DACL is saved, and each affected object’s DACL is saved before ACE removal;
rollbackrestores both and re-scansremainingLow. Records from before 0.4.0 lack object DACLs, and those removals cannot be rolled back. - Automatic cleanup does not remove ACEs: Even if
removeAcesis enabled in configuration, the fast path will not remove them, and the log will note this. - Excluded directories are not cleaned: Directories in
excludeDirsare neither scanned nor removed; results and records mark them asexcluded. Do not interpret “skipped” as “remediated.” - Truncation and failure: When
MaxObjectstruncation occurs, the result is markedtruncatedwithok=false, and only scanned objects are remediated. Label restoration failure, root still being Low, or unreadable DACLs all prevent the remediation from reporting success. - Dangerous paths: Drive roots,
%SystemRoot%,%ProgramFiles%,%ProgramData%, and the user profile root are rejected by default; on the script side, only an explicit-AllowDangerousRootflag can bypass this. - Encoding: Scripts are saved as UTF-8 with BOM, and Chinese text matching that depends on the local code page has been removed;
icaclsfailures are judged solely by exit code. - Privileges: The plugin itself does not elevate privileges and does not disable the sandbox.
Applicable Scenarios and Cautions¶
This plugin is suitable for developers using DSH on Windows to build intelligent agents or debug workspace-related features. Before use, review the source code and license to confirm compliance with your security and compliance requirements. The plugin runs with the current DSH process privileges; modifying mandatory integrity labels requires WRITE_OWNER or SeRelabelPrivilege. Drive roots owned by Administrators will return Access denied and require an elevated shell. Do not remediate while a workspace-write session is still writing to the workspace, as this will cause that session to lose write permission.
Summary¶
xia-sc/dsh-workspace-integrity provides a complete set of remediation and monitoring capabilities for handling residual Low integrity labels left by DSH’s workspace-write sandbox on Windows, including automatic cleanup, a UI panel, an agent tool, and rollback records. It ensures consistent behavior through a shared host implementation and provides configuration and dry-run capabilities for controlled use. See the plugin detail page and GitHub repository: https://www.skillhub.cn/plugins/xia-sc/dsh-workspace-integrity and https://github.com/xia-sc/dsh-workspace-integrity.