Repository navigation
Conversation
Draft RFC for keeping registered credentials out of model upstreams while agents can still use them: seal values into privacy references on the wire (gateway), unseal only at the tool execution boundary (harness runner).
The hook gives no permission decision unless secretExecApproval is ask, and never returns allow.
Lead with a one-minute summary and a running example, explain terms on first use, and replace the mermaid sketch with five SVG figures. Move the RFC next to the existing one under bot/docs/zh/design.
…ew findings Wrapping a command in the runner hides it from Claude Code's permission rules, so the hook now prepends never-executed guard lines that expose each original segment to rule matching (verified on Claude Code 2.1.321). Also corrects overstated claims found by cold readers, defines gateway terms on first use, and redraws the figures accordingly.
…ttled Gateway: its own additions (recall, tool results) are sealed before they are stored, with the egress sweep as the second line; unsealing needs a tools-bearing request, the canonical spelling and a value of 6+ characters; exemptions and JSON spellings as implemented; server 0.5.2. Plugin: the hook also asks when a command names the runner itself, the runner line is written so a rule for it is easy, and the guard lines were verified end to end on Claude Code 2.1.321 (scenario table in section 11).
Lead with goals, non-goals, the three switches and the behaviour changes they bring. Gateway and plugin internals follow as detailed design, and the Claude Code guard line, the harness hook comparison and the acceptance notes move to appendices. Settle the open questions: privacy_resolve stays as is on the server with a recommendation to stop exposing it, new profiles keep seal_secrets off, and the skill category stays out of sealing with the consequence listed under known limitations. The two laws become invariants I1 and I2, in the text and in the architecture figure.
Add secret exec, the plugin layer of the agent-secret-use RFC (section 7). It is off unless secretExec is set, and no workspace file can set it. A separate PreToolUse hook wraps a Bash command that carries a credential reference as '<node>' '<secret-run.mjs>' '<command>', keeping every other input field. It never reaches the network or a value, gives no permission decision unless secretExecApproval is ask, never allows, and denies privacy_resolve. The runner resolves every reference through /api/v1/privacy-configs/resolve and runs nothing unless all of them resolve. It hands the values over as OV_SECRET_<n>, expanded for the quoting each reference sat in so no value becomes shell code, and masks them back to their references on stdout and stderr. Session start tells the model how to write references. The logic lives in memory-plugin-shared/lib/secret-exec.mjs as pure functions, so another host needs only an envelope. The URI guard no longer takes the viking:// URI inside a privacy reference for a path.
The hook skipped a command that already named the runner before it looked at secretExecApproval, so under `ask` a command the model wrapped itself, or one that assembled its reference at run time, ran without confirmation. A command that starts a runner is still never wrapped again, but `ask` now confirms it. The runner also resolves nothing while secretExec is off, whoever starts it. A value the environment cannot carry (a NUL byte) made spawn() throw with the value in its message, past the masker. The spawn error now reports only its code, and the resolver refuses such a value, and any non-text one, with a reason that says so instead of "no value is stored". The scanner read the `<<` of `$((1<<4))` as a here-document, so every later line counted as its body and got an unquoted expansion that split a value holding blanks past the masker. `$(( ))` and `(( ))` are now arithmetic, and a here-document body is a frame of its own, so `$( )` and backticks inside one get a quoted expansion too. Smaller fixes: a value saved under two fields masks to the smaller reference, as the Gateway seals it; enum settings match in any case, so `ASK` no longer falls back to `inherit`; the runner uses the shell Claude Code's Bash tool picks (CLAUDE_CODE_SHELL or SHELL when bash or zsh, else zsh or bash from PATH) instead of dash for SHELL=/bin/sh; and session start adds the usage note even when memory is off. The docs fix the hook count, a duplicate README anchor, and claims that went past what masking and `ask` do.
Claude Code matches permission rules against the rewritten command, where the original sits inside a quoted string. A Bash(rm:*) deny rule did not see it, and allowing the runner allowed every command with a reference. The hook now puts one `false && <pipeline>` line per top-level pipeline in front of the runner. The line never runs, but Claude Code checks it like the original, so the rewritten command needs what the original needs plus the runner. Checked end to end on Claude Code 2.1.321, default and bypass modes: allowed runs unprompted, a deny rule on any part denies, an unlisted part or runner goes to approval. The hook asks instead when it cannot vouch for guard lines (here-document, $( ), subshell, compound command) and when the command names the runner itself. The runner's node and script paths go unquoted where they can, so a rule for the runner is easy to write.
# Conflicts: # examples/magpie-memory-plugin/package.json
There was a problem hiding this comment.
🟡 Changes recommended
Critical shell-parsing flaws allow premature command execution and permission-guard bypasses, while an exhausted session-start budget can permit uncapped archive injection.
3 open issues
2 files not reviewed
examples/dsh-memory-plugin/package-lock.json: Generated fileexamples/pi-coding-agent-extension/package-lock.json: Generated file
What changed in this PR
Adds opt-in secret execution to the Claude Code memory plugin, using shared infrastructure to resolve saved credential references at execution time and mask matching values in command output.
Changes:
- Adds command rewriting, permission guards, credential resolution, and streaming output masking.
- Integrates Claude Code hooks, session guidance, configuration controls, and regression tests.
- Updates English and Chinese documentation, architecture diagrams, generated modules, and plugin versions.
| File | Description |
|---|---|
examples/pi-coding-agent-extension/package.json |
Bumps extension version. |
examples/pi-coding-agent-extension/package-lock.json |
Synchronizes lockfile version. |
examples/opencode-plugin/package.json |
Bumps plugin version. |
examples/memory-plugin-shared/uri-guard.test.mjs |
Tests credential-reference exclusions. |
examples/memory-plugin-shared/secret-exec.test.mjs |
Tests rewriting, guards, masking, and execution. |
examples/memory-plugin-shared/README.md |
Documents shared secret-exec APIs. |
examples/memory-plugin-shared/plugin-known-keys.test.mjs |
Tests workspace restrictions on secret settings. |
examples/memory-plugin-shared/plugin-config.test.mjs |
Tests secret-exec configuration sources. |
examples/memory-plugin-shared/lib/uri-guard.mjs |
Excludes privacy references from URI notices. |
examples/memory-plugin-shared/lib/secret-exec.mjs |
Implements shared secret-exec functionality. |
examples/memory-plugin-shared/lib/config-schema.mjs |
Adds secret settings and case-insensitive enums. |
examples/magpie-memory-plugin/package.json |
Bumps plugin version. |
examples/dsh-memory-plugin/package.json |
Bumps plugin version. |
examples/dsh-memory-plugin/package-lock.json |
Synchronizes lockfile version. |
examples/codex-memory-plugin/scripts/shared/config-schema.mjs |
Synchronizes shared configuration schema. |
examples/codex-memory-plugin/.codex-plugin/plugin.json |
Bumps plugin manifest version. |
examples/claude-code-memory-plugin/scripts/shared/uri-guard.mjs |
Synchronizes privacy-reference exclusions. |
examples/claude-code-memory-plugin/scripts/shared/secret-exec.mjs |
Vendors the shared secret-exec implementation. |
examples/claude-code-memory-plugin/scripts/shared/config-schema.mjs |
Synchronizes shared configuration schema. |
examples/claude-code-memory-plugin/scripts/session-start.mjs |
Adds secret-exec guidance to startup context. |
examples/claude-code-memory-plugin/scripts/secret-run.mjs |
Connects the runner to configuration and transport. |
examples/claude-code-memory-plugin/scripts/secret-exec.test.mjs |
Tests hook and runner integration. |
examples/claude-code-memory-plugin/scripts/secret-exec.mjs |
Adds the PreToolUse adapter. |
examples/claude-code-memory-plugin/scripts/marketplace.test.mjs |
Verifies hook registration and entrypoints. |
examples/claude-code-memory-plugin/README.md |
Documents setup, permissions, and limitations. |
examples/claude-code-memory-plugin/README_CN.md |
Adds Chinese setup and limitation guidance. |
examples/claude-code-memory-plugin/package.json |
Bumps plugin package version. |
examples/claude-code-memory-plugin/hooks/hooks.json |
Registers the secret-exec hook. |
examples/claude-code-memory-plugin/.claude-plugin/plugin.json |
Bumps marketplace plugin version. |
examples/agent-hook-plugin/plugin.json |
Bumps shared host-plugin version. |
examples/agent-hook-plugin/hosts/zcode/openviking.integration.json |
Synchronizes ZCode integration version. |
examples/agent-hook-plugin/hosts/trae/openviking.integration.json |
Synchronizes TRAE integration version. |
examples/agent-hook-plugin/hosts/kimicode/openviking.integration.json |
Synchronizes Kimi integration version. |
examples/agent-hook-plugin/hosts/kimicode/kimi.plugin.json |
Synchronizes Kimi plugin version. |
examples/agent-hook-plugin/hosts/cursor/openviking.integration.json |
Synchronizes Cursor integration version. |
examples/agent-hook-plugin/hosts/codebuddy/plugin.json |
Synchronizes CodeBuddy plugin version. |
docs/zh/guides/06-mcp-integration.md |
Explains reference-based credential use in Chinese. |
docs/zh/agent-integrations/18-plugin-development.md |
Documents adapter responsibilities in Chinese. |
docs/zh/agent-integrations/16-capability-reference.md |
Updates Chinese capability and hook listings. |
docs/zh/agent-integrations/02-claude-code.md |
Adds Chinese secret-exec integration guidance. |
docs/en/guides/06-mcp-integration.md |
Explains reference-based credential use. |
docs/en/agent-integrations/18-plugin-development.md |
Documents adapter responsibilities. |
docs/en/agent-integrations/16-capability-reference.md |
Updates capability and hook listings. |
docs/en/agent-integrations/02-claude-code.md |
Adds secret-exec integration guidance. |
bot/docs/zh/design/images/secret-use-plugin.zh.svg |
Illustrates hook and runner execution. |
bot/docs/zh/design/images/secret-use-gateway.zh.svg |
Illustrates gateway credential handling. |
bot/docs/zh/design/images/secret-use-deployments.zh.svg |
Compares deployment protection boundaries. |
bot/docs/zh/design/images/secret-use-before-after.zh.svg |
Compares plaintext and reference-based workflows. |
bot/docs/zh/design/images/secret-use-architecture.zh.svg |
Illustrates plugin and gateway responsibilities. |
Review effort: Balanced
…rchive cap - A `#` right after a backslash escape is part of a word, not a comment, in both the splitter and the rewriter, so `a\;#x; rm target` still guards `rm target`. - Continue a pipeline across a newline only after a real `|` operator, not an escaped `\|`. - Never pass 0 (no cap) to the archive section when sessionStartMaxBytes is set and the secret-exec note has used the budget.
|
Superseded by #8384. The hook that rewrote commands into a runner is no longer needed: |


Description
Lets Claude Code use a credential saved in OpenViking Privacy without the value entering the conversation, as designed in the RFC at #7335 (section 7 and appendix A).
Today the model has to call
privacy_resolve, read the plaintext, and write it into a command. WithsecretExecon, the model writes the privacy reference straight into a Bash command. A PreToolUse hook hands that command to a runner, which resolves the reference, passes the value to the child process through an environment variable, and replaces any echo of the value in the output with the reference again. The transcript, the permission prompt and OpenViking's capture only ever contain the reference.The switch is off by default. Commands without a reference are not touched.
Human Involvement
Related Issue
RFC: #7335. Related: #7213, which proposes
ov privacy run. That command does the same job as the runner here, so the hook can call it instead once it exists.Type of Change
Changes Made
examples/memory-plugin-shared/lib/secret-exec.mjs: the shared logic, so other harnesses only need a thin adapter later.$'...', unquoted heredoc). A reference inside a quoted-delimiter heredoc is refused. Because values are never spliced into shell text, a scanner mistake cannot become an injection.privacy_resolvewith a reason that tells the model to write the reference into the command, and adds a usage note at session start.scripts/secret-run.mjs): resolves each reference with the user's own key, runs the rewritten script in the shell Claude Code's Bash tool would pick, and masks stdout and stderr. If any reference cannot be resolved it exits non-zero without running the command.Bash(rm:*)would stop applying and allowing the runner once would allow everything. The hook therefore prepends onefalse && <segment>line per top-level segment of the original command. Those lines never run, but Claude Code checks them like any other, so the permission needed is that of the original command plus that of the runner.$( ), backticks, subshells, compound statements) getaskinstead of a guess.ask.allow.secretExecApproval: askasks on every use.secretExeccan be turned on in the user's own config (ovcli.confplugin section orOPENVIKING_SECRET_EXEC), not from a file committed to a repository.bot/docs/zh/design/.Testing
I have added tests that prove my fix is effective or that my feature works
New and existing unit tests pass locally with my changes
I have tested this on the following platforms:
Memory plugin suite, run the way
pr.ymlruns it, on macOS: 1618 tests, 1600 passed, 9 failed, 9 skipped. The same 9 fail on the base branch without these changes: 5 ininstall-tui.test.mjsand 4 in the pi extension'stakeover-session-manager.test.mjs.secret-exec.test.mjspasses 29 of 29.Installer tests: 24 passed, 0 failed.
The shared-copy generator leaves the tree clean.
One new test failed on macOS at first: stock macOS bash is 3.2 and cannot parse
|&. The last commit runs the non-POSIX cases only on shells that can parse them.End to end on Linux with bash, on Claude Code 2.1.321 in default and bypass modes, with the real hook and runner and a simulated OpenViking server. The scenario table is in the RFC, appendix A.4. In short: allowed commands run and the model sees only references; a deny rule on any segment still denies, in bypass mode too; an unallowed segment or an unallowed runner goes to approval;
$( )and a model-written runner call both getask.Not done: an end-to-end run on macOS or with zsh as the tool shell, and auto mode.
Checklist
Screenshots (if applicable)
None.
Additional Notes
bot/docs/zh/design/rfc-agent-secret-use.mdand five figures. The gateway PR carries the same commits.cdover to later commands, and shell aliases and functions are unavailable.