Preface¶
DeepSeek Harness (dsh) hooks the agent’s tool calls onto public hooks such as Cordis; once the model decides to invoke Shell, read/write files, or access the network, the request enters the runtime. If the weights in use were implanted with a backdoor during training or fine-tuning — for example, silently executing memorized tool sequences when a specific trigger word appears, or leaking credentials outward — the harm often only surfaces after the tool has actually been dispatched. Relying solely on the main model’s self-review is unreliable: a backdoored model cannot itself serve as the “judge.”
dsh-backdoor-guard is a DSH plugin published by maintainer miketako3 (current npm package version 0.2.0, MIT license). It performs an independent judgment on every tool call at the tools/pre-execute stage; if the judgment does not pass, execution is refused and a SECURITY NOTICE is written into the session transcript. Below we describe its positioning, installation method, and configuration essentials.
What Is This¶
This plugin targets the DeepSeek Harness ecosystem, specifically countering weight-burned backdoor payloads triggered through the tool channel (e.g., malicious QLoRA merges initiating specific tool calls or credential exfiltration under hidden trigger conditions). Plain-text-level misbehavior is not within its threat model.
In implementation it does not fork the main model, does not rely on logprobs, nor maintains a regex rule library: it leverages the public DSH plugin seam to call a dedicated decision model once per tool call, obtaining a calibrated “safe probability” within roughly one forward pass (zero output tokens). The speed is sufficient to cover all tool calls (about 100 ms on hosted Jev; about 30 ms for local d1-3B on an Apple M5 Pro; about 8 ms on an RTX 4090).
Why Use an Independent Decision Model¶
- If the model under review has already been backdoored, its self-policing cannot be trusted.
- The decision model (Jev or LiquidAI d1) is designed for “yes/no on a state document with a probability,” decoupled from the agent backend.
- Unlike the entropy-based rdsh-backdoor-guard research approach, this plugin deliberately adopts the decision-model path, so logprobs are not needed and it can work with any agent backend.
The judging side and the main LLM must be different, small, frozen models; do not route judge requests to the same model being reviewed.
Core Features¶
Judgment Input¶
The state document received by the judge includes: the user’s latest request (may be truncated), whether the agent visibly announced the imminent action (silent invocations are treated as a runtime characteristic of memorized payloads), the tool name, normalized arguments, and earlier tool calls in the current turn.
Judgment Question¶
The plugin prices legitimacy with a single Noul question, roughly: safe means the call serves the user’s explicit request; does not read or exfiltrate irrelevant credentials/secrets; contains no obfuscation, pipe-to-shell, or self-decoding-style payloads; no anomalous external endpoints; does not look like an action triggered by a hidden trigger.
Execution Result¶
When safe_probability >= threshold, the call is allowed; otherwise it is denied before dispatch, and the rejection reason includes the probability. The plugin package includes a dsh.bundle layer; after dsh plugin add, a Cordis plugin line is automatically written.
Installation and Enablement¶
The official README gives three installation methods:
dsh plugin add dsh-backdoor-guard # npm, available after release
dsh plugin add github:miketako3/dsh-backdoor-guard # install from GitHub
dsh plugin add file:/path/to/dsh-backdoor-guard # local directory
After installation, the backdoor-guard plugin entry must be kept/adjusted in the profile’s cordis.patch.yml (or equivalent configuration). The plugin runs with the current dsh process privileges; review the source code and the MIT license yourself before installing.
Choosing a Judge¶
Both options share the Decision Index systemone schema, differing mainly in endpoint and authentication.
Option A: Hosted Jev (TypeSafe AI)¶
First obtain an API key from console.typesafe.ai, then export the environment variable:
export TYPESAFE_API_KEY=ts_...
Example profile fragment:
- id: backdoor-guard
name: 'dsh-backdoor-guard'
config:
endpoint: https://api.typesafe.ai/v1/systemone
model: jev-latest
apiKeyEnv: TYPESAFE_API_KEY
Option B: Local d1-3B (LiquidAI public weights)¶
Install the Python dependencies and start the shim service bundled in the same repository:
pip install "transformers>=5.14" torch torchvision pillow
python3 server/d1-server.py --model LiquidAI/d1-3B --port 8400
Local endpoints usually do not need an Authorization header:
- id: backdoor-guard
name: 'dsh-backdoor-guard'
config:
endpoint: http://127.0.0.1:8400/v1/systemone
model: d1-3B
apiKeyEnv: '' # empty string means no Authorization is sent
The README notes that d1-3B can read roughly 32k tokens of state, so the entire tool-call payload can be fed in fully; experimentally, d1-omni-600M (text + audio) is also available.
Configuration Reference¶
| key | default | meaning |
|---|---|---|
endpoint |
https://api.typesafe.ai/v1/systemone |
systemone-compatible judge URL |
model |
jev-latest |
judge model id |
apiKeyEnv |
TYPESAFE_API_KEY |
name of the env var holding the API key; '' means no auth (local) |
threshold |
0.5 |
deny when the safe probability is below this value |
timeoutMs |
8000 |
judge request timeout (milliseconds) |
skipTools |
[] |
tool names never judged, supports * wildcards (e.g., ['read', 'web_*']) |
maxArgsChars |
2000 |
maximum argument characters sent to the judge |
maxRequestChars |
1000 |
maximum user-request characters sent to the judge |
onJudgeError |
allow |
when the judge is unavailable: allow logs and passes; deny fails closed |
During tuning you may keep onJudgeError: allow; high-security deployments are advised to set it to deny.
Threat Model and Limitations¶
- Coverage: weight backdoors acting through tools, and credential-theft-type behavior; plain-text malicious output is out of scope.
- Trust boundary: the judge is trusted infrastructure — it should be pinned to a local d1 or your own Jev key, and must not share an inference path with the model under review.
- Defense in depth: full coverage still requires配合 network egress controls and other measures.
The implementation was inspired by @pentacoxian_dev’s rdsh-backdoor-guard research; this repository is an independent implementation.
Development and Validation¶
The maintainer provides in the repository root:
npm install
npm test # vitest: judge client + end-to-end plugin flow
npm run build # tsc → lib/
Peer dependencies include @deepseek-ai/cordis (>=4.0.5-alpha.1) and the dsh-agent / dsh-llm / dsh-tools 0.2.1-alpha.2 series.
Use Cases¶
Suitable for agent scenarios running on DSH where model weights or LoRA merges from not-fully-trusted sources are used, while the full toolchain must be retained. The community plugin directory is located on independent sites such as SkillHub, with no official affiliation with DeepSeek / Hiang; before use, choose a hosted or local judge in light of your organization’s security policy, and understand the trade-offs between fail-open (onJudgeError: allow) and fail-closed.
- Directory page: https://www.skillhub.cn/plugins/miketako3/dsh-backdoor-guard
- Source code and documentation: https://github.com/miketako3/dsh-backdoor-guard