Repository navigation
feat: security that applies everywhere, with rules you can see and a log of what they caught - #85
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Merged
fylorn
added a commit
that referenced
this pull request
Sep 21, 2026
Security that applies everywhere (#85): outbound redaction and tool-call inspection each get one mode and one rule set for every upstream. Rules can be listed, turned off one at a time, supplemented with custom regular expressions and tried on a sample, and every hit is kept in a log. Breaking: CONTROL_API_VERSION 4. providers[].trust, providers[].redact, route rules' guard, security.scan_configs and security.scan_rules are gone from the configuration, and /leaks and /baseline from the control API. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Outbound redaction and tool-call inspection become global: one mode and one rule set each, applied the same way to every upstream. Every rule can be listed, switched off one by one, and supplemented with your own regular expressions, and everything the two guards catch is kept in a log.
Why
trustandredactclasses, and each route rule'sguardstacked on top of each other. Observe mode detected every class; enforce mode replaced only the upstream's classes. For an official endpoint that meant "credentials detected" while observing, and nothing replaced after switching to enforce.config.yaml.security.scan_configsdid not change anything: the config watcher ran and alerted in every mode.What changes
Config (
security), no migration:Removed:
providers[].trust,providers[].redact, route rules'guard,security.scan_configs,security.scan_rules.Data plane
cut, whoever the upstream is. The response-text prompt-injection check is gone: applied globally it flags ordinary answers that discuss prompt injection.Messages: the errors a client gets when a tool call is cut, and the scan findings, name the rule (“Download and run”) rather than its id; a custom rule, which has no reason attached, no longer leaves an empty
()behind.Events:
LeakSeenandRedactedbecomeSecretsFound { replaced, items: [{ rule, custom, kind, masked, count }] }.ToolCallFlaggedcarriesaction(cut/record) andcustominstead ofhigh.ResponseInspectedis removed.Store: a
security_eventstable (one row per hit) replacesleaks; old leak rows are moved into it.requests.tool_calls,flaggedandredactedare dropped. Rows expire with requests.Control API (
CONTROL_API_VERSION4)GET /security,PUT /security/{guard}/mode,PUT /security/{guard}/builtin/{id},POST|PUT|DELETE /security/{guard}/custom[/{name}]: only settings that differ from the factory default are written; patterns are compiled before anything is written.POST /security/{guard}/test: tries a sample against the current rules, one pattern, or one built-in rule (even one that is switched off, so a rule can be tried before it is turned on). Redaction samples are encoded as they would appear in a request body, so the answer matches the gateway. Offsets are in UTF-16.GET /security/events: the log, filtered by guard and range, paged backwards./summarygainssecuritycounts (same rows as the log), replacingflagged_requests,redacted_requestsand/leaks. History rows and request details carry their security events./leaks,/baseline(the upstream behaviour baseline), and the trust/redact fields on upstreams and their preview.Tests
cargo test --workspace(1505 passed),clippy -D warnings,fmt --check, andscripts/smoke.sh(51 passed) locally. New: end-to-end redaction with a switched-off rule and a custom rule, tool-call cutting by rule action and custom rule, JSON-safe custom matches, plain-text test offsets, the store migration moving leak rows, and the control API for rules, tests (including one built-in rule while it is off) and the log.🤖 Generated with Claude Code