Repository navigation
feat(gateway): seal secrets out of model requests and unseal tool calls - #8444
Merged
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Gateway part of the RFC in #7335 ("Agent 密钥可用不可见") and its supplement on auto-enrollment (comment).
A new context-profile switch,
seal_secrets, makes the gateway send a user's registered secrets, and new tokens the user types, to the model provider only as{{ov_privacy:…}}references. Client tools still receive the real value. It is off by default, and nothing changes for an existing deployment until it is turned on. Once it is on, a request that cannot be sealed is refused rather than sent unsealed.Stacked on #8408 (server feature table), #8384 (server seal endpoint) and #8445 (plugins). Until those merge, their commits show up here as the first three; review only the last commit,
feat(gateway): seal secrets out of model requests and unseal tool calls. The gateway code uses one thing from #8445: theprivacy_sealrow it adds to the feature table.This PR was split out of #8384, which used to hold the server, gateway and plugin parts together. The plugin part is #8445.
What changes
autocategory. The model gets a note asking it to save the entry under a proper name with a description.enroll_tool_secrets(off by default) also stores tokens found in tool output.ov privacycommands keep the reference.secret_seal_failed. A request that cannot be sealed (compressed or unparseable body, a text too large, tool calls that could not be unsealed): 400secret_seal_invalid_request. A reply whose tool calls cannot be unsealed: 502secret_unseal_failed. Each message names the case and what to do. There is no option that lets such traffic through; turningseal_secretsoff is the way out.privacy_seal(0.5.7). Against an older server the gateway refuses without calling the seal endpoint, and the message gives both versions. The version is read again within 30 s, so sealing resumes without a gateway restart.secrets_sealed,secrets_enrolled,secrets_unsealed,seal_calls,seal_cache_hits,seal_ms), and a docs page,docs/{en,zh}/gateway/14-seal-secrets.md, with one figure.Size
36 files, +4014/−44 in this PR's own commit: about 1520 lines of source (
openviking_gateway/sealing.pyis most of it), 1770 of tests and 720 of docs including the figure.How it was tested
On this branch, rebased on
mainat b6ab3ef.tests/gatewaywas rerun there; the other rows are from the previous base, and the files they cover have not changed since:tests/gatewayvitest run src/features/admin/gateway src/i18ncheck:docs,check:apiEnd to end with a real model (deepseek-v4-1-flash) through a local server and gateway, with a recording proxy in front of the model endpoint, so the check is what was actually sent to the provider. These runs were made on the combined tree (server, gateway and plugins together) before the split and before the last rebase. At that time the code also had a mode that let unsealable requests through and an option,
seal_secrets_strict, that refused them; the refusing path is now the only one, and the runs below that concern failures used it:credential/githubwith a description and used it throughov privacy run; the tool got the real value.enroll_tool_secretson, read a file with a token and write it back: nothing reached the provider, and the written file holds the real value.secret_seal_failedand nothing sent upstream. Sealing resumed without a gateway restart once the server was back.secret_seal_invalid_request, nothing sent upstream.Earlier runs on the same design (Chat, Anthropic and Responses protocols, rotation, a 60-token burst, Claude Code, pi and Codex CLI as clients, latency measurements) are described in the RFC supplement.
Known limits
seal_secretson, model requests of that profile fail while OpenViking is unreachable or older than 0.5.7. That is the intended trade: the switch is opt-in, and it promises that nothing goes out unsealed.seal_secretson.enroll_tool_secretsis on.openviking, references in calls to its tools reach the tool as values.data:URI, or long base64 underdata/file_data) is not scanned.{{ov_privacy:…}}reference starts a new gateway session once after the upgrade, because conversation identity now ignores the reference.Notes for reviewers
seal_secretson after it started no longer offers the gateway toolprivacy_resolve: the tool is dropped from the list whenever the session is sealed, whatever was chosen when the session began.proxy.pywas merged with the per-upstream billing evidence from feat(gateway): record per-upstream billing evidence #8337: a body is sealed beforebegin_call, and when a reply fails at unsealing, the upstream call is closed with the upstream's status and usage and the errorsecret_unseal_failed.https://claude.ai/code/session_01MSnwD1nmyEak2rMDLkSZMx