feat(redaction): exact-value secret redaction from user pattern file - #87953
Closed
hermes-node8 wants to merge 0 commit into
Closed
feat(redaction): exact-value secret redaction from user pattern file#87953hermes-node8 wants to merge 0 commit into
hermes-node8 wants to merge 0 commit into
Conversation
hermes-node8-app
Bot
force-pushed
the
feat/redaction-exact-value-pattern-file
branch
from
August 16, 2026 22:21
1ec6b10 to
ff5e381
Compare
Author
|
Friendly bump — this PR has been open since Aug 16 and CI hasn't run on the branch yet (fork PRs appear to need a maintainer to approve the workflow run; no checks have reported). Could someone approve the run and take a look? Happy to adjust anything that comes up in review. |
hermes-node8-app
Bot
force-pushed
the
feat/redaction-exact-value-pattern-file
branch
from
August 28, 2026 18:58
ff5e381 to
667746b
Compare
Author
Author
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.
Problem
Hermes redacts shapes: any
KEY=valuewhose key matches the built-in keyword families (PASS,TOKEN,SECRET,API_KEY, ...) is masked byredact_sensitive_text()at every message boundary. But exact values — secrets under non-obvious keys (PIN,x_passphrase), or bare values in prose — are only masked when a provider-specific rule happens to recognize their shape. The gaps are tracked in #77162 / #77165 / #77465 (plain-.envsecrets under non-suffixed names, profile ContextVar scope, encoding transforms) and #72778 (file-read call-site wiring).Solution
A fail-safe, file-driven exact-value pass inside
redact_sensitive_text():Loads an optional user pattern file — plain JSON, hand-written or generated by companion tooling; no external tooling required:
{ "mask": {"head": 2, "tail": 2, "floor": 12}, "literals": ["exact-value", {"value": "top-tier", "mask": "full"}], "key_patterns": {"PIN": true, "x_passphrase": true} }Masks exact registered literals and registered
KEY=value/KEY: value/"KEY": "value"forms regardless of value length — the class the keyword families miss (PIN=1234).Path resolution:
security.redact_patterns(config.yaml, bridged at startup) →HERMES_REDACT_PATTERNSenv → default$HERMES_HOME/state/redaction/redact_patterns.json(~/.hermesfallback — profiles/relocated installs work).Mask styles: length-driven default (2+2 visible chars, floor 12 — preserves the built-in ≥8-hidden invariant while phones and short emails stay partially visible for troubleshooting); per-entry
"full"or custom{"head", "tail", "floor"}; unknown styles fall back to the safe default.Safety properties
file_read=Truecontent uses the non-reusable sentinel ([Bug]: redact_sensitive_text corrupts API keys in config files when read via read_file/search_files, causing 401 #35519 semantics) — a masked value can never be written back over the real file..env, config, or vault sources.Reviewer feedback addressed
security.redact_patterns), bridged to the env var at all three entry points, mirroring the existingsecurity.redact_secretsbridge; the env var remains for programmatic overrides.PIN=1234) are masked by the key-pattern pass.Related work
ctx.register_redaction_patterns()— complementary: a developer/plugin API for vendor token shapes; this PR is the end-user file-driven exact-value layer. No overlap.Validation
tests/agent/test_redact_registry_patterns.py(mask styles incl. unknown-style fallback, longest-first alternation, short values, mtime rotation pickup, broken-file fail-safe with auto-recovery, file-read sentinel, write-back invariant, missing-file no-op,HERMES_HOMEdefault-path resolution, JSON key forms, quoted multi-word values, separator-whitespace preservation, empty-value passthrough, path-keyed cache switching) andtests/hermes_cli/test_redact_patterns_bridge.py(env wins, config fallback).Follow-ups
"patterns"(regex) section plus named shape styles (email keeps domain, phone last-4) — natural v2 on the same file.