Repository navigation
fix(dsh): apply the shared prompt-privacy rule to explicit writes - #2643
Conversation
Explicit writes from the MCP tools and slash commands rejected content
with substring markers ('sk-', 'api_key', 'BEGIN PRIVATE'). Ordinary text
such as "risk-based", "task-specific" or "disk-space" was rejected with
secret_rejected, while password and token assignments, Authorization
headers, bearer and GitHub tokens, and the configured Server token passed.
Explicit writes now use the rule that automatic capture already follows,
from "Automatic prompt privacy" in the integrations guide
(tests/fixtures/automatic_prompt_privacy.json), including the configured
Server token. A write whose content contains a recognized credential is
still rejected, not redacted.
hidb4ai
left a comment
There was a problem hiding this comment.
Reviewed ef1cd68. No blocking findings. Reusing the established prompt-privacy rule fixes ordinary-word false rejections and adds recognized-credential/configured-token checks before explicit write dispatch. No new database tables, endpoints, commands, configuration keys, persisted formats, or package exports. The internal client field and helper parameters do not expand the published package API.
The installed bundle was also exercised in real DSH with a local PowerContext Server and a scripted model: ordinary prose reached the existing approval gate, while password, configured-token, and nested Handoff token inputs produced secret_rejected with no MCP write dispatch. This does not claim live-provider acceptance.
Possible capability gap (non-blocking): Pi and OpenCode explicit-write guards still call containsSecret(value) without the configured authorization (integrations/pi/plugins/powercontext/src/invoke.ts and integrations/opencode/plugins/powercontext/src/invoke.ts). Consider a follow-up under #2250 for opaque configured-token matching there; this is pre-existing and does not block this DSH fix.
Which issue or RFC does this PR close?
Part of #2250. Follows #2625, which applied the shared prompt-privacy rule to DSH's automatic path and left explicit writes as a follow-up.
Rationale for this change
DSH rejects an explicit write whose content looks like a secret, with
secret_rejected, before approval or dispatch. It decided this with three substring markers:sk-,api_key, andBEGIN PRIVATE. The markers fail in both directions:sk-. A Memory, Source, Handoff, task outcome, or Scope summary that uses one of these words cannot be written.password=andaccess_token=assignments,AuthorizationandCookieheaders, bearer and GitHub tokens, and the configured Server token are sent and stored.DSH's automatic path already follows the rule from "Automatic prompt privacy" in the integrations guide (
tests/fixtures/automatic_prompt_privacy.json), so one DSH session applied two different definitions of a secret.What changes are included in this PR?
Behavior
sk-orapi_key(task-runner,risk-based)secret_rejectedAuthorization/Cookieheaders, bearer and provider tokens, private keys)secret_rejectedsecret_rejectedpassword: rotate it monthlysecret_rejectedThe operations and fields that are checked are unchanged: Memory, Source, and working-note writes; Work Contract, task outcome, candidate, and Scope fields; and Handoff content, including nested state and Drafts. A rejected write still sends nothing.
Code
src/secrets.ts:hasSecretContentusescontainsSecret, the same function as automatic capture, and takes the configured Authorization value. The substring markers are removed; nothing else used them.src/mcp.ts,src/index.ts: the MCP pre-execute policy receives the configured Authorization value.src/invoke.ts,src/client.ts: slash-command writes read it from the client, whoseauthorizationfield becomes public read-only.lib/index.jsis rebuilt. The DSH pet bundle and the Cindy worker includeclient.tsandsecrets.tsbut nothasSecretContent; their builds do not change.Tests
New
tests/explicit-write-privacy.spec.tsreadsautomatic_prompt_privacy.jsonand adds ordinary prose with "risk-based", "task-specific", and "disk-space". It covers two paths:remember_memory,capture_content_source,handoff_current_work(nested state),finalize_handoff(nested Draft),record_task_outcome, andcreate_scope;invokeOperation.Sensitive cases must be rejected with no request, no Scope resolution, and no synthetic credential in the result. Other cases must not be rejected.
With the old markers restored, 112 of the 175 new cases fail. Without passing the Authorization value, the Server-token cases fail.
tests/invoke.spec.tsuses a provider-shaped token instead ofsk-secret, which is too short for the shared rule.The existing rejection tables in
tests/mcp.spec.tsand the runtime fixture already useapi_key=…assignments and private-key headers, so they pass unchanged.Docs
docs/{en,zh}/docs/integrations/dsh.mdand the plugin README describe the rule, the Server token, and the trade-off below, and link to the policy section.Trade-off
password: …and similar assignments as credentials wherever they appear, including prose.secret_rejected, and the user rephrases. A false rejection is visible and recoverable, while a stored credential is not.Not included
src/handoff/callhasSecretContentwithout the Server token. No runtime path reaches them today; MCP Handoff tools are checked by the MCP policy, which has the token.Overlap with the prompt-privacy refactor
containsSecretout of DSH'ssrc/secrets.tsinto a generatedsrc/prompt-privacy.ts. Whichever of the two merges second addsimport { containsSecret } from './prompt-privacy.ts'tosrc/secrets.ts, rebuilds the DSH bundle, and rerunsmake js-testandmake cindy-test.Are there any user-facing changes?
Yes, for DSH explicit writes:
password: rotate it monthlyis rejected.The error code and message are unchanged. No API or persisted format changes.
How was this change tested?
make js-test: 795 unit tests, the e2e tests, the DSH pet adapter tests, and freshness of the DSH and DSH pet bundles.make cindy-test: 20 tests,worker.cjsfreshness, and packaging.make check, andgit diff --check.uv run pytest tests/test_automatic_prompt_privacy.py tests/test_integration_manifest.py tests/test_dsh*.py.No real DSH host was run.
make dsh-runtime-testdownloads the pinned host and was not run locally. Its secret-write test usesapi_key=…, which the shared rule rejects.Self-review against
REVIEW.md, plus an independent review pass, found nothing blocking. Fixed: an English docs sentence about the MCP catalog had lost its subject.Confirmed:
authorizationpublic changes TypeScript visibility only; the emitted JavaScript is the same and nothing serializes the client;lib/matches a rebuild;Left as design notes:
metadata: {password: "x"}passes, while the same text inside one string is rejected.sk-value with fewer than eight characters after the prefix, ormy api_key is XYZwithout an assignment.secret_rejectedreason does not name the field or the matched shape. A more specific reason would help a model rephrase; that is a separate change.devon a local development Server, makes every explicit write that contains it (development,device) fail withsecret_rejected, where automatic capture would only skip the turn.secrets.token_urlsafe(32)); a short token comes only from manual configuration.AI usage statement
Claude Code (Claude Opus 5.5) wrote the change, the tests, and this description, and ran the checks above.