Preface¶
Under the DSH (DeepSeek Harness) plugin architecture, when a model invokes tools to perform filesystem or terminal operations, it inherits the permissions of the DSH host by default. When operations need to be executed with higher privileges (Administrator, SYSTEM, TrustedInstaller), or when explicit control over privilege boundaries is required, developers often have to manually switch or configure multiple environments. This introduces maintenance overhead and security risks. Below we introduce a plugin that adds an “Execution Privilege” selector to DSH Desktop, enabling file modifications, terminal operations, and other actions initiated by the model to be explicitly executed as a standard user, Administrator, SYSTEM, or TrustedInstaller.
Plugin Overview¶
- Name: hiber2007/dsh-exec-privilege
- Purpose: DSH Desktop execution privilege selector
- Core Capabilities: Adds a privilege-level selector to DSH Desktop, supporting standard user / Administrator / SYSTEM / TrustedInstaller (default: standard user). The model initiates requests via a dedicated tool; elevation occurs only after the user approves in a dedicated confirmation dialog. The executor listens exclusively on the local loopback address and authenticates with a one-time random token.
- Maintainer: HiBer2007
- Category: admin-security
- Repository: https://github.com/HiBer2007/dsh-exec-privilege
Core Features¶
-
Privilege Levels & Default Behavior: By default, operations execute with the current user’s medium-integrity token. Even if the DSH host runs as Administrator, tools will not inherit Administrator privileges; the Administrators group is deny-only in the token. Switching to Administrator / SYSTEM / TrustedInstaller requires explicit user approval via a dedicated confirmation dialog. The model can only initiate requests through the dedicated tool
request_exec_privilegeand cannot approve or elevate on its own. -
Executor Startup & Authentication: If the DSH host lacks sufficient privileges, an independent executor is launched via UAC (Administrator) or UAC + Scheduled Task (SYSTEM) / TrustedInstaller token duplication. The executor listens exclusively on the local loopback address and authenticates with a one-time 256-bit random token.
-
Unreachable Level Indicators: The menu lists all levels; unreachable levels are grayed out with a reason (e.g., non-administrative account, UAC disabled, TrustedInstaller service disabled, no root on the system).
-
Workspace Sandbox Handling: When SYSTEM / TrustedInstaller is selected, the workspace sandbox is directly disabled. Executors at these levels run in Session 0; the Windows ACL sandbox’s restricted-token runner creates processes from the Session 0 system token, which returns Win32 error 740 or
0xC0000142. The plugin forcesworkspace-writetodanger-full-accessand synchronously rewrites the session’ssandbox/modeevent; workspace writes become unavailable, retaining only full-access and read-only modes. The client menu and confirmation dialog display this notice. After switching back to Administrator / standard user, workspace-write becomes available again. -
Persistence & Recovery: The selection is persisted to
~/.dsh/exec-privilege.json. After restart, no non-standard-user level is silently restored: on startup, a dedicated confirmation dialog asks whether to restore; if the user declines or the request times out, the level remains standard user. -
Process-Level Switching: Switching is process-level; newly launched tools use the new level, while already-running commands continue to completion at the old level. When higher privileges are no longer needed, simply switch back to “Standard User”; the executor exits.
Implementation Components¶
| Component | Purpose |
|---|---|
index.js |
Process-level execPrivilege service, level catalog, UAC/Scheduled Task/TI startup, /exec-privilege/* routes |
worker.cjs |
Executor running with the target token: accepts shell and fs requests, callbacks to a random port on the Host |
fs.js |
Extends SandboxedFileSystem, preserves read-only / workspace-write / full-access path policies, forwards read/write to the executor |
shell.js |
Extends SandboxPwshExecutor, preserves sandbox confine/denial logic, passes the final argv to the executor |
native.cjs |
Koffi Win32 bindings: SAFER standard-user token, integrity levels, Scheduled Tasks, TI service token duplication |
client.js |
Composer button, menu, unreachable-reason display, dedicated confirmation dialog |
| Dedicated tool | request_exec_privilege: model only initiates the request; the user decides in the dedicated confirmation dialog |
Privilege Escalation Confirmation Flow¶
- The model calls
request_exec_privilege({ level, reason }); the tool creates a pending request and waits. - The client polls status every 3 seconds; upon seeing
pendingRequest, it displays a dedicated confirmation dialog in the center of the page. The user can also select the target level from the “Execution Privilege” menu, with the same effect. - The user clicks “Allow” or “Deny”;
/exec-privilege/decisionrequires the browser session Cookie. The shell in which the model resides does not have this Cookie and therefore cannot approve on its own. - Only after approval does the Host call
setLevel(..., { approvedRequestId })to start/switch the executor. Rejection or a 5-minute timeout results in no elevation.
Security Boundaries¶
/exec-privilege/state,/request,/decision,/level,/selftestare all validated through DSH’sconnection.requestRejection(), accepting only authenticated browser sessions.- The model can only create requests via
request_exec_privilege;setLevelfor a target level higher than the current one mandates a request ID that has already been approved by the user. - This is a local, user-level boundary: a same-account process capable of reading the browser Cookie database can still bypass it. For a stronger boundary, confirmation should be moved to a separate low-privilege UI process or an OS-level consent mechanism should be used.
- The DSH host does not restart or elevate; only tool execution uses the target token. This ensures sessions, attachments, logs, etc. continue to be handled normally by the DSH host.
Installation & Activation¶
After adding this directory to the desktop profile (link: dependency + bundle), the Host replaces fs-sandbox / pwsh-sandbox with fs-privileged / shell-privileged. The client bundle is automatically loaded via the profile’s dsh.client declaration.
Diagnostic Commands¶
# Status: host identity, current selection, level reachability and reasons (requires browser session Cookie)
Invoke-RestMethod "http://127.0.0.1:<port>/exec-privilege/state"
# Initiate an elevation request; then approve in the on-page confirmation dialog (the model cannot approve)
Invoke-RestMethod -Method Post -Uri "http://127.0.0.1:<port>/exec-privilege/request" `
-ContentType 'application/json' -Body '{"level":"admin","reason":"manual test"}'
# End-to-end self-test: actually invokes ctx.fs / ctx.shell, returns write, read, directory listing, and whoami
Invoke-RestMethod "http://127.0.0.1:<port>/exec-privilege/selftest"
selftest no longer accepts level / consent parameters; level switching must go through the dedicated confirmation flow. You may append sandbox=workspace-write&workspace=<absolute-path> to verify sandbox combinations.
Known Limitations¶
-
SYSTEM / TrustedInstaller do not run the workspace sandbox: The executor currently runs in Session 0; the Windows ACL sandbox’s restricted-token runner creates processes from the Session 0 system token, which returns Win32 error 740 or
0xC0000142. The plugin therefore directly disables the workspace sandbox when these two levels are selected: forcingworkspace-writetodanger-full-accessand synchronizing the session’ssandbox/mode; only full-access / read-only is retained.read-onlyis still constrained by the read-only fence. The NSudo-style approach (“token duplication +SetTokenInformation(TokenSessionId, current interactive session)”) has been validated as feasible with a SYSTEM probe but has not yet been integrated into the plugin; before integration, a one-time SYSTEM test must be explicitly approved by the user. -
Plugin-own subprocesses bypass this selector: Only capabilities routed through
ctx.shellandctx.fsare affected; plugins that directly invokectx.subprocess(e.g., the Document Workshop CLI) continue to run with the DSH host’s permissions. The terminal sidebar also uses a separate terminal seam and is outside the scope of this selector. -
UAC cancellation returns an error quickly; if UAC passes but the elevated launcher subsequently fails, the wait times out at 60–90 seconds with an error message.
-
POSIX: The UI displays root but it is unreachable by default; the current implementation is only fully validated on Windows.
Security Notes¶
- The executor authenticates with a one-time 256-bit random token and is bound to
127.0.0.1only. - The standard-user executor’s configuration is readable by the current user (it holds no higher privileges than the current user); the Administrator / SYSTEM / TrustedInstaller executor’s configuration is restricted via
icaclsto Administrators + SYSTEM read access. - Selecting SYSTEM / TrustedInstaller is a high-risk administrative operation: the confirmation dialog requires checking a risk-acknowledgment checkbox.
- Privileges are constrained by the UAC policy of the account under which the DSH host runs; this feature does not bypass UAC, Group Policy, or service ACLs.
Applicable Scenarios & Cautions¶
Suitable for DSH Desktop agent scenarios requiring fine-grained control over filesystem and terminal execution privileges, such as automated operations, system maintenance, and security auditing. Important notes: the plugin runs with the current DSH process permissions; review the source code and license before installation; SYSTEM / TrustedInstaller are high-risk administrative operations requiring a checked risk-acknowledgment box in the confirmation dialog; the executor is only fully validated on Windows (POSIX UI shows root but it is unreachable by default); plugin-own subprocesses (e.g., the Document Workshop CLI) and the terminal sidebar do not pass through this selector.
Summary¶
dsh-exec-privilege adds explicit execution-privilege selection to DSH Desktop, supporting standard user, Administrator, SYSTEM, and TrustedInstaller (default: standard user). The model can only initiate requests via a dedicated tool; elevation occurs only after user approval in a confirmation dialog. Through process-level switching, persistent configuration, and security boundary design, it enables agents to operate more safely when higher privileges are needed. See details at: https://github.com/HiBer2007/dsh-exec-privilege