dsh-keychain-credentials: Put DSH credentials into macOS Keychain

Preface

DeepSeek Harness (DSH) provides adapters and tools with sensitive data such as API keys and session records through ctx.credentials. The default dsh-credentials-local writes content to $DSH_HOME/.credentials.yaml. Although the file permissions are 0600, tool processes (bash, file-reading tools) belong to the same user as DSH, so the model side may still read the plaintext via read, cat, grep, etc. If you include the profile directory in backups, sync, or git, the credentials will also leak along with the files.

Below we introduce the community plugin dsh-keychain-credentials (maintainer nengong-ai): on macOS it uses the system login keychain to host DSH credentials, so no credential files that can be directly cated remain on disk. It is categorized as admin-security and currently has 0 GitHub stars.

What is this

dsh-keychain-credentials is a pure JavaScript credentials Provider for DeepSeek Harness, implementing the complete seam of ctx.credentials: both refs (e.g., API Key references) and records (e.g., structured records such as client-connection/browser-session) are written to the macOS login keychain rather than plaintext YAML.

Compared with Providers that only implement refs and still let session records fall back to plaintext files, this plugin covers both halves of the seam; installation requires no Swift, code signing, or Xcode.

Core Features

Improvements over the default local file

  • Keys no longer exist as files, so they will not enter backup directories, sync drives, or git repositories.
  • The read threshold is raised from “any file-reading primitive” to “a same-user process must call /usr/bin/security“—a substantial improvement, but not absolute isolation.

Honest caveat: what it still cannot do

When the login keychain is unlocked (unlocked by default after login), a same-user process can read entries via /usr/bin/security, and the CLI is trusted by the ACL and usually requires no second prompt; an agent with an unrestricted shell that knows to query the keychain may still exfiltrate them. For a stronger boundary, OS-level isolation is required (e.g., a broker with a private access group, or a separate OS user), possibly combined with sandboxing that restricts tool subprocesses.

Behavior and seam contract

  • Process environment variables take precedence over the keychain (a one-run intent overrides stored values).
  • Empty values are treated as nonexistent; when environment variables provide a read-only shadow, set/unset will be rejected.
  • describe only checks existence and does not read plaintext, avoiding state queries pulling keys into the agent process.
  • When calling security, error information is sanitized (exit codes and stderr, without the command line that may contain keys).
  • Keys are passed to security via stdin, not in argv, avoiding exposure in ps.
  • Values exceeding 128 bytes are written with security -i (the stdin password prompt silently truncates); after writing, confirmation is made by reading back.

Other reasons for choosing it (from the README)

  • No Touch ID / password prompts: reads and writes deliberately do not disturb the user (a different trade-off from keyringseam-style solutions that prompt on every operation).

Environment Requirements

  • Operating system: macOS (depends on /usr/bin/security); in package.json, engines.node is >=20 and os is darwin.
  • DeepSeek Harness: ≥ 0.1.0-rc.6 (peer range covers 0.1.x and 0.2.0-rc.1).
  • DSH 0.2 and newer: The plugin must be mounted as a package—installed into the profile or linked into its node_modules, and referenced by package name in the config; lines pointing to an absolute-path index.js are unavailable on 0.2+ (peer compatibility gating and host resolution restrictions inside asar).

Installation and Activation

The official installation command is as follows (replace <profile> with your profile name):

dsh plugin --profile <profile> add dsh-keychain-credentials
# or from source:
dsh plugin --profile <profile> add github:<you>/dsh-keychain-credentials

After installation, the package’s cordis.patch.yml disables the default dsh-credentials-local and mounts this Provider. If you need to write a patch manually, add the following to ~/.dsh/profiles/<profile>/cordis.patch.yml or --patch <file>:

- id: credentials
  disabled: true
- insert:
    - id: credentials-keychain
      name: dsh-keychain-credentials     # 包名,不是绝对路径;插件须已装/链接进该 profile
      config:
        servicePrefix: dsh-credentials   # keychain service prefix
        account: dsh                     # keychain account name

The plugin version follows the published package (in the materials package.json is 0.2.0); license MIT.

Typical Usage

The credential reference name corresponds to the keychain entry’s account; the service prefix defaults to the servicePrefix in the config (example: dsh-credentials). Write an API Key using the system CLI:

security add-generic-password -U -s dsh-credentials -a DEEPSEEK_API_KEY -w 'sk-…'

The LLM adapter resolves by reference name at request time; after rotating a key there is no need to restart DSH.

Developers can install dependencies in the repo and run tests (these operate on the test prefix dsh-credentials-test under the real login keychain, without writing real keys):

npm install   # or pnpm install — devDependencies supply the seam packages
npm test

Use Cases and Caveats

Suitable for: Developers running DSH long-term on macOS who want both refs and records to move away from plaintext YAML but do not want to introduce a Swift build chain.

Not suitable for: Non-macOS environments; or threat models that require “the model and tools must be completely unable to reach the keys”—this plugin only raises the attack threshold and cannot replace OS-level isolation.

Before installation: The plugin runs as the same user and with the same process privileges as DSH; before enabling it, review the GitHub source and the license yourself. The community plugin directory skillhub.cn is an independent site, with no official affiliation to DeepSeek / High-Flyer, and is not an official app store.

Summary

dsh-keychain-credentials replaces $DSH_HOME/.credentials.yaml with the macOS login keychain, supporting both refs and records, and is pure JavaScript—ready to use upon installation. It cannot eliminate the possibility of same-user reads via security, but it prevents credentials from being swept up by the model’s common read paths as ordinary files.

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

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

Xiaoye