Repository navigation
fix(redact): leave JSON keys and identifiers alone; keep PEM matches inside one string - #330
Merged
Merged
Conversation
…inside one string Outbound redaction ran its rules over the whole request body, so a custom rule such as `abc123` matched inside item ids (Codex sends `fco_<uuid>`), call ids, tool names and keys. The placeholder made the id invalid and the upstream rejected the request; since the history is resent every turn, the conversation stayed broken. Hits now skip every key and the values of identifier keys (`id`, `*_id`, `*Id`, `type`, `role`, `name`, `namespace`, `model`, `status`, `object`, `phase`), alongside the base64 payloads that were already skipped. The private-key rule searched for the END marker across the whole body: a lone `-----BEGIN` in one message joined up with an END in a later one and replaced every item in between with a single placeholder. In JSON it now looks only within the string the header is in. Co-Authored-By: Claude Opus 5.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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Problem
fco_<uuid v7>(hex), so a rule such asabc123can land inside one; the placeholder makes the id invalid and the upstream rejects the request (invalid input[N].id ... contained additional characters). The history is resent every turn, so the conversation stays broken.-----BEGIN ... PRIVATE KEY-----header in one message joined up with an END in a later message, and every item in between was replaced by one placeholder (items silently dropped, two items merged into one object).Fix
flow::hitsdrops hits inside JSON keys and inside the values of identifier keys:id,*_id,*Id,type,role,name,namespace,model,status,object,phase— next to the base64 payloads it already skipped. One shared JSON string walker (json_strings) serves both.private_keyslooks for the header end and END only within the JSON string the header is in.Tests
keys_and_identifiers_are_left_alone: Responses, Anthropic and Bedrock shaped ids, call ids, tool names, keys andmodelstay; text, tool output and arguments are still replaced.a_pem_does_not_reach_into_the_next_string.cargo test -p tw-guard,cargo test -p tw-gateway, clippy and fmt pass locally.🤖 Generated with Claude Code