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.
Credentials registered in OpenViking Privacy reached model providers as soon as they entered a conversation: pasted by the user, printed by a tool, recalled from memory, or returned by the default privacy_resolve gateway tool. With the new seal_secrets profile switch the gateway replaces every registered value with its owner-bound reference before the kernel reads the request, and again right before each upstream send (main request, compaction summary, hidden tool continuation). Anchors, replay records and capture therefore stay in reference form and the upstream never sees a registered value. unseal_tool_calls also puts the real values back into the tool calls the client runs, on the client's copy only, by routing the reply through the hidden tool loop. secret_guard.py holds the logic: the reference grammar, a per-user catalog read with the caller's own OpenViking key (30 s refresh, only changed targets, 600 s stale fallback, 503 without one), the position-aware seal walk and the client-call unseal. Both switches are read from the live profile and cannot be set by X-OpenViking-Context; privacy_resolve is not offered while sealing. Studio gets a "Seal credentials" section so saves keep the fields, and the gateway docs describe the switches and what providers see. Implements docs/repository/rfcs/agent-secret-use.md sections 5 and 6.
- Exempt only a string that is entirely a data: URI, and nothing a tool read
or wrote (tool_use, tool_result, role=tool, function_call_output,
custom_tool_call_output). Text that merely began with a data URI, tool
results included, went upstream unsealed.
- Seal recall before the kernel records it and gateway tool results before
the loop keeps them, so replay records hold references only. Continuations
start from the body sealed before the first send, so secrets_sealed_egress
no longer counts the same recall once per hidden round.
- Refuse with 400 JSON that only json.loads can read on every path, not only
on protocol paths, and read no credentials for a request without a body.
- Seal the ASCII-only, \/ and Go HTML-safe JSON spellings of each value.
- Unseal only known references spelled exactly as rendered, so a resent call
seals back to the bytes the gateway recorded; Chat calls without a type
unseal too.
- Log why a credential read failed: servers before 0.5.2 have no tree.
- Docs: v-pre around {{...}} for the VitePress build, the 0.5.2 requirement,
privacy_resolve in earlier conversations, the 6-character unseal minimum,
and what local storage holds.
Tool results are sealed as they arrive, so a continuation normally holds no value by the time it is sent. The send is still the last place one can be caught, and the RFC's claim is that every body that goes upstream is sealed on the way out. Sealing is idempotent, so the extra pass counts nothing unless a path did skip it.
# Conflicts: # docs/en/gateway/08-context-profiles.md # docs/zh/gateway/08-context-profiles.md # openviking_gateway/kernel.py # openviking_gateway/proxy.py # web-studio/src/features/admin/gateway/lib/profile-schema.test.ts
There was a problem hiding this comment.
🟡 Changes recommended
Critical gaps in secret refresh, custom-tool argument sealing, and compaction/window-reset handling can expose credentials upstream or persist plaintext secrets.
3 open issues
What changed in this PR
Adds opt-in credential sealing to the Gateway’s Privacy integration, replacing registered values with references before model requests and optionally restoring values in client tool calls.
Changes:
- Adds per-user credential catalogs, request sealing, client-call unsealing, failure handling, and counters.
- Exposes live profile switches through the API and Studio, both disabled by default.
- Adds gateway and Studio tests, bilingual documentation, and the supporting RFC diagrams.
| File | Description |
|---|---|
web-studio/src/i18n/locales/zh-CN/gateway/profiles.ts |
Adds Chinese credential-setting labels. |
web-studio/src/i18n/locales/en/gateway/profiles.ts |
Adds English credential-setting labels. |
web-studio/src/features/admin/gateway/lib/profile-schema.ts |
Defaults both switches to off. |
web-studio/src/features/admin/gateway/lib/profile-schema.test.ts |
Tests preservation of credential settings. |
web-studio/src/features/admin/gateway/lib/client-guides.ts |
Links to credential-sealing documentation. |
web-studio/src/features/admin/gateway/lib/api.ts |
Adds credential switches to profile types. |
web-studio/src/features/admin/gateway/components/profiles-settings.tsx |
Adds sealing and unsealing controls. |
web-studio/src/features/admin/gateway/components/profiles-pages.test.tsx |
Tests controls, summaries, and saving. |
web-studio/src/features/admin/gateway/components/profiles-page.tsx |
Summarizes credential settings on profile cards. |
tests/gateway/test_secret_guard.py |
Tests matching, catalogs, protocol flows, and failures. |
openviking_gateway/tool_loop.py |
Seals results and unseals client reply copies. |
openviking_gateway/tool_catalog.py |
Excludes privacy_resolve when sealing is enabled. |
openviking_gateway/secret_guard.py |
Implements credential catalogs and transformations. |
openviking_gateway/proxy.py |
Integrates sealing, unsealing, and enforcement. |
openviking_gateway/models.py |
Defines and validates credential switches. |
openviking_gateway/kernel.py |
Seals recalled text before recording it. |
openviking_gateway/blocks.py |
Adds instructions for using credential references. |
openviking_gateway/app.py |
Initializes the credential catalog service. |
docs/zh/gateway/13-configuration.md |
Documents credential settings in Chinese. |
docs/zh/gateway/11-security-and-data.md |
Explains credential exposure and storage boundaries. |
docs/zh/gateway/08-context-profiles.md |
Documents behavior, limits, and failures. |
docs/zh/gateway/06-manage-in-studio.md |
Explains immediate application of credential switches. |
docs/zh/api/25-gateway.md |
Documents sealing and unsealing counters. |
docs/en/gateway/13-configuration.md |
Documents credential settings in English. |
docs/en/gateway/11-security-and-data.md |
Explains credential exposure and storage boundaries. |
docs/en/gateway/08-context-profiles.md |
Documents behavior, limits, and failures. |
docs/en/gateway/06-manage-in-studio.md |
Explains immediate application of credential switches. |
docs/en/api/25-gateway.md |
Documents sealing and unsealing counters. |
bot/docs/zh/design/rfc-agent-secret-use.md |
Adds the credential-use design and acceptance criteria. |
bot/docs/zh/design/images/secret-use-plugin.zh.svg |
Illustrates plugin execution and output sealing. |
bot/docs/zh/design/images/secret-use-gateway.zh.svg |
Illustrates Gateway request and reply processing. |
bot/docs/zh/design/images/secret-use-deployments.zh.svg |
Compares deployment modes and plaintext exposure. |
bot/docs/zh/design/images/secret-use-before-after.zh.svg |
Compares plaintext and reference-based histories. |
bot/docs/zh/design/images/secret-use-architecture.zh.svg |
Illustrates Gateway, plugin, and Privacy boundaries. |
Review effort: Balanced
…ed credentials - Seal compaction and new-window replacement text before it is stored: the opening block it copies may predate sealing or a registered value. - Never exempt client tool calls (custom_tool_call, Chat custom, function_call) from sealing, so a data URI argument holding a credential is sealed. - Re-read every credential target on refresh instead of skipping by version: a target deleted and created again restarts at version 1.
|
Superseded by #8384. That PR rewrites the gateway part on current |

Description
Adds credential sealing to the OpenViking Gateway, as designed in the RFC at #7335 (sections 5 and 6).
Today a credential that reaches the conversation is resent to the model provider on every later turn. It gets there through
privacy_resolve, a pasted key, tool output such ascat .env, or recalled content. Withseal_secretson, the gateway replaces every registeredcredentialvalue with its existing privacy reference before anything is sent upstream, so the provider only ever sees references. Withunseal_tool_callsalso on, references the model writes into client tool-call arguments are replaced with the real values in the copy sent to the client, which makes references usable without a harness plugin.Both switches are off by default, including for new profiles. With them off, request bytes and behaviour are unchanged.
Human Involvement
Related Issue
RFC: #7335. Related: #7213.
Type of Change
Changes Made
openviking_gateway/secret_guard.py: the per-user catalog (value ↔ reference), the protocol-agnostic seal function and the unseal function.credentialvalues only: current version, top-level string fields, at least 6 characters.thinking/redacted_thinking/reasoningblocks,signatureandencrypted_contentfields, anddata:URIs are left alone. Tool-call arguments and tool results are never exempt.secrets_sealed_egress.unseal_tool_callson, requests that carry tool definitions go through the tool loop, and references in client tool-call arguments are unsealed in the client copy only. Anchors and captured content stay in reference form. Only exact references to the caller's owncredentialvalues are unsealed; assistant text and thinking never are.seal_secretsandunseal_tool_calls. They cannot be overridden byX-OpenViking-Contextand are read from the live profile rather than frozen at session creation.privacy_resolveis dropped from the gateway tools whileseal_secretsis on; the session preamble explains reference usage whenunseal_tool_callsis on; request logs gain seal / unseal counters and never record values or references.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:
pytest tests/gateway: 1176 passed, 89 skipped, 0 failed. The skips are tests that need a Redis server or themcppackage, neither of which is on this machine. The newtests/gateway/test_secret_guard.pyaccounts for 39 of the passes.ruff format --checkandruff checkonopenviking_gatewayandtests/gateway: clean.Studio
vitest run: 1920 passed, 2 failed. Both failures are in files this PR does not touch:script/architecture.test.tsreportsroutes/arranger/*, andserver-configuration/lib/config-file-api.test.tsexpects an English string on a machine with a Chinese locale.Unsealing has only been exercised against a simulated upstream. It has not been run end to end with a real client.
Checklist
Screenshots (if applicable)
None.
Additional Notes
bot/docs/zh/design/rfc-agent-secret-use.mdand five figures. The plugin PR carries the same commits.skillcategory is not covered.