dsh-tm-guard: A macOS DSH Agent Permission Gating Plugin

Introduction

When DeepSeek Harness (DSH) agents run in a local macOS environment, they often require file read/write access, network connectivity, or system administration permissions. Granting full control directly poses security risks. dsh-tm-guard aims to provide a “zero-intervention” permission gating layer for DSH, limiting the scope of agent operations through policy-based decisions.

What is this

dsh-tm-guard is a permission management plugin designed for DSH agents. It is an npm package (dsh-tm-guard) that belongs to the DSH Cordis ecosystem, rather than a standalone sandbox or CLI tool. The plugin declares dsh.bundle.patch to hook into the DSH tools/pre-execute event stream, classifying and intercepting operations before tool execution.

Core Features

The plugin’s core logic follows the principle: “Reversible operations are allowed to execute; irreversible operations are rejected.”

  1. Zero-intervention Permission Gating: Automatically takes effect when the DSH agent is running, requiring no continuous manual intervention.
  2. Time Machine/APFS-based Automatic Rollback: For local writable directories, the plugin automatically creates a local git baseline or triggers a macOS snapshot. If an operation is reversible (e.g., local git operations), the plugin automatically approves and logs it; if an operation cannot be rolled back (e.g., network requests, process termination), it is rejected directly.
  3. Blocking and Auditing: Network access, package manager installations, and process/system administration operations are blocked by default. Additionally, the plugin includes a built-in list of sensitive paths to block reading of sensitive information such as SSH configurations, AWS credentials, and GPG keys. All decisions are recorded in an audit log.
  4. Tool Whitelist Configuration: Allows extending the list of trusted tools via configuration files.

Installation and Activation

Before installation, ensure the environment meets the following conditions:
* System: macOS with APFS file system.
* Backup: Time Machine is configured, the working directory is on a TM backup volume and not excluded.
* Permissions: The terminal/application running DSH has “Full Disk Access” permissions.
* Tools: git is in the system path.
* DSH Version: Must match the peerDependencies range of the plugin.

Use the official installation command to add the plugin:

dsh plugin --profile <name> add dsh-tm-guard

Typical Usage

After installation, the plugin is loaded into the corresponding DSH Profile. You need to adjust the policy through configuration files.

1. Extend Write Protection Scope

Add protectedPaths to the Profile’s cordis.patch.yml to specify directories the agent can write to. process.cwd() is protected by default.

# cordis.patch.yml
protectedPaths:
  - ./my-project/src
  - ./config

2. Unlock Trusted Tools

By default, tools like web_search and skill are classified as “mixed/unknown” and rejected. Add extraAllowTools to cordis.patch.yml to whitelist these tools:

# cordis.patch.yml
extraAllowTools:
  - web_search
  - skill

Note: Never add subagent, subagent_fork, workflow, or job_output to the whitelist, as this bypasses the classifier and renders security policies ineffective.

3. Verify Installation and Auditing

After starting the Profile, the console log should display loading information. You can use the tools registered by the plugin to check the status:

# View gating status and logs
tm_status

# View audit log
tm_audit

Use Cases and Notes

  • Use Cases: Safely running DSH agents in a local macOS environment, especially scenarios involving code generation, configuration modifications, or network connectivity.
  • Important Notes:
    • The plugin is not a security sandbox; it runs within the permission context of the DSH process and relies on the host system’s permission management.
    • Before using in a production environment, it is recommended to read the source code and confirm license compatibility.
    • Ensure the plugin version is compatible with the main DSH version.

Conclusion

dsh-tm-guard provides a practical permission management solution based on Time Machine and local snapshots, suitable for developers looking to securely deploy DSH agents on macOS. For more configuration details and source code, please refer to the GitHub repository.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye