Repository navigation
fix(logging): preserve non-secret env references; add exemption list and redaction notification - #160364
fix(logging): preserve non-secret env references; add exemption list and redaction notification#160364slzszyt-ux wants to merge 26 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
Codex review: stale review; fresh review needed. Summary Next step Review history (3 earlier review cycles)
|
|
Thanks for the thorough review - all findings are addressed in the new revision (head [P1] reference-prefix bypass - fixed. Real behavior proof - added to the PR body. Sink-level trace from the production 2026.9.6 redaction bundle carrying this PR's guard changes, across the real log sink, diagnostic sink, and model-visible sink, with synthetic values only:
Note on the model-visible sink: it intentionally keeps upstream's narrow assignment policy (assignment-family patterns are excluded from model-visible payloads), so the new exemption does not change what that sink masks - the fix targets the log and diagnostic sinks where the bypass was found. Input-safety hold - fixed. The credential-shaped literal fixtures are gone from the diff; all fixtures are now assembled programmatically from parts ( Line-cap ratchet - partially addressed. The model-visible marker/notice presentation moved into the sibling module Maintainer security approval - understood; the @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Status update + requests for maintainer attention, since this PR currently needs both a security approval and a ClawSweeper hold release to proceed. What the latest revision (head
Why this matters (real-world evidence in this issue): two independent reporters confirmed the false-positive class in production — including @Oldrich333's case where masked values were written back into knowledge records and were only recoverable from git history. The operator allow-list is the only non-lossy route for namespace collisions that anchoring cannot decide (e.g. Requests:
|
…tructuredAuthParamRanges does not produce ranges for Basic/Bearer credential headers, so the pattern engine (already exempted) is the only path that handles them
What problem this solves
OpenClaw's text redaction is always-on and runs over model-visible tool payloads and persisted transcripts. Four related DX problems bite agent-driven work:
process.env.FOOafter a secret-looking key is treated as a credential and masked, corrupting source/config content. Repro on2026.9.6:const token = ***;->const token = ***;.logging.redactPatternsonly adds patterns, so a deployment cannot exempt a benign value that keeps getting masked.***/proces…OKENis indistinguishable from real content.Why this change was made
1. Preserve non-secret references.
isNonSecretReferenceValuerecognizesprocess.env.FOO,process.env["FOO"],os.environ["FOO"],os.environ.get("FOO"),os.getenv("FOO"),getenv("FOO")and skips masking them. Anchored on the raw input from the capture start so bracket/quote forms truncated by the capturing pattern are still recognized; applies only to assignment-family patterns - vendor-token and header patterns keep masking.2.
logging.redactAllowPatterns. Regex strings (same/…/flagssyntax asredactPatterns). A candidate secret value matching any exempt pattern is left unmasked. Default[]leaves behavior unchanged; registered exact secret values stay masked. Wired through value-pattern redaction, the sensitive-redaction bitmap, and structured-field redaction; plus config schema, help, labels, and docs.3. Obvious notification. Model-visible redaction replaces masked spans with a self-describing marker (
⟦redacted⟧) instead of the ambiguous***/hint, and appends a one-line notice to the tool content when redaction changed it. Diagnostic log surfaces keep the compact***.4. Control UI panel. New
session.redactiongateway event, scopedSESSION_READ_SCOPEand broadcast to session subscribers when a projectedsession.messagecarries a model-visible redaction marker/notice (containsModelVisibleRedaction). The Control UI handles it inhandleGatewayEventand raises a notification panel viashowToast. The event carries only session scope plus a timestamp - no secret material.Evidence
Unit tests (branch)
src/logging/redact.test.tscovers, with values assembled from parts (so the diff contains no credential-shaped literal):process.env.<NAME>assignments) are preserved on every sink;os.environ["…"],os.getenv("…")) stay masked (safety boundary);Sink-level trace (real redactor, synthetic values)
Produced with the production 2026.9.6 redaction bundle carrying this PR's guard changes, exercising the same registered sinks the gateway uses (log, diagnostic, model-visible). No private values involved - all inputs synthetic:
complete referencetoken = process.env.GATEWAY_TOKEN;reference-prefixed credentialtoken=proces…tialsynthetic secretMY_TOKEN=aaaaaa…aaaacomplete referencetoken = process.env.GATEWAY_TOKEN;reference-prefixed credentialtoken=proces…tialsynthetic secretMY_TOKEN=aaaaaa…aaaacomplete referencetoken = process.env.GATEWAY_TOKEN;reference-prefixed credentialtoken=process.env.FOO-privateCredentialsynthetic secretMY_TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaLegend: the complete reference stays intact on every sink; the reference-prefixed
credential and the synthetic secret are masked (diagnostic/log sinks keep a short
hint, the model-visible sink emits the self-describing marker and appends the notice).
Note: the model-visible sink intentionally keeps upstream's narrow assignment policy (assignment-family patterns are excluded from model-visible payloads), so the new exemption does not change what that sink masks; the fix targets the log and diagnostic sinks where the bypass was found.
Review fixes in this revision
isNonSecretReferenceValuenow requires the entire captured value to be a complete reference ($-anchored alternation, evaluated on the delimiter-stripped capture). A capture like the review's reference-prefixed credential example no longer qualifies and is masked on log and diagnostic sinks (see sink trace). Regression test added; the bitmap path got the same boundary.src/logging/redact-model-visible.ts. Ifsrc/logging/redact.tsstill exceeds its baseline, I'll split the reference exemption and the allow-list feature into separate PRs - guidance welcome.session.redactionpayload carries only session scope and a timestamp.Related: #160343