Skip to content

fix: stop redacting prose after "pass:" in transcripts and logs - #160888

Merged
steipete merged 16 commits into
mainfrom
steipete/redact-prose-pass
Sep 29, 2026
Merged

steipete merged 16 commits into
mainfrom
steipete/redact-prose-pass

Conversation

@steipete

@steipete steipete commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: ordinary prose is masked as a secret when a sentence contains pass: followed by a word, for example an agent's status line "The boundary tests now pass: older clients receive compatible speed values" was persisted as "…now pass: *** clients…" in the Team chat transcript. Because transcript redaction runs before the message is committed, the masked word is unrecoverable.

Also fixes, found while proving the first fix on Bun: on the Bun runtime the default redaction fast-path skipped every default pattern for a text once a run of key characters longer than roughly 70k preceded an = (a long base64 blob with = padding is enough), so long tool output and transcripts could keep credentials unmasked. Node was unaffected.

User Impact

Chat transcripts, logs, and tool output keep prose intact when a sentence clause ends with pass:, including in long texts. Real password assignments stay redacted: pass: value at a text or line start (LF or CR), indented YAML, YAML list items (- pass: value), a value on the next line (pass:\n value), after {, ,, ;, (, [, tabs or quotes, after any inline key=value or key:value field regardless of spacing or length (user=bot pass: value, user = bot pass: value, key=<300 chars> pass: value), plus pass=value, pass = value, pass= value, quoted pass: "value", prefixed db-pass: value, namespaced smtp.pass: value, and ?pass= / form-body pairs are unchanged. On Bun, default redaction now runs for long texts the same way it does on Node.

Why This Change Was Made

Bare pass: classification. The unquoted config-assignment pattern treated bare pass as a secret key in both its colon and equals forms. Bare pass is an English word far more often than a config key, and the colon form is exactly how prose introduces a list. The generic colon alternative now uses a key list without bare pass; the equals alternative and every other pattern keep the full list. Bare pass: is handled by a small programmatic matcher (BARE_PASS_ASSIGNMENT_MATCHER, same interface as the existing AWS matcher) that runs at the generic rule's old position, before the namespaced and prefixed rules, and is registered as an ambiguous assignment shape like that rule (tool-payload exclusion and source-assignment preservation unchanged). One matchAll finds every pass: key that is not inside another word, then a single forward pass over the text classifies each one and reads the unquoted value that follows a record key. An occurrence is prose only when a plain word or number plus one space precedes it and no assignment (=, : glued to a value, or an earlier pass: field, bare or namespaced) has been seen since the last line break; a recognized field skips past its value so a line break before a continued value does not reset that state. A spaced key: value phrase earlier on the line is deliberately not an assignment: that is how prose introduces lists ("Release notes: all suites pass: nothing else changed"), so an inline user: bot pass: value record on one line is the accepted cost of this fix (user=bot pass: value and user:bot pass: value stay records; maintainer decision from review rounds 4 and 5, restated when Codex autoreview raised the same shape on the final revision); every other position is a record start and masks exactly as before. Keys preceded by ., - or _ are left to the namespaced and prefixed patterns (their value is not consumed) but still mark their line as a record, and so does any other credential key with a colon, in any letter case (password: x pass: y, Authorization: Bearer x pass: y); pass inside another word (bypass:, compass:) is not a key and cannot swallow a real pass: field that follows it. Whitespace around the colon may include line breaks, as in the old rule, so a YAML explicit key (? pass\n: value) stays covered. Earlier revisions tried to express this as a regex with a bounded look-back; every bound left a gap (aligned spacing, long inline fields) that review found, and an unbounded regex was not linear. The forward pass has no bounds and is linear in the text, and the matcher is excluded from tool-payload redaction like the other ambiguous assignment rules.

Provider error previews. The embedded-agent error observation owner composed its explicit redaction policy from getDefaultRedactPatterns(), which returns only the configurable string sources, so it would have lost bare pass: masking in providerErrorMessagePreview once that rule became a matcher (found by ClawSweeper on the previous head). getDefaultRedactPatterns() now returns the full default policy, programmatic matchers included, so that caller keeps working unchanged; the string-only list it used to return had no other production consumer and is removed (the one test helper that builds logging.redactPatterns config keeps only the strings). The matcher's ambiguous-assignment treatment (tool-payload exclusion, source-assignment preservation) comes from a small matcher set beside the string set, which stays pattern text because tests feed it to config. A regression asserts a provider message starting with pass: <secret> reaches the preview masked.

Default prefilter on Bun. redactSensitiveText first runs one prefilter regex over the whole text and returns early when nothing could match. Its obfuscated-key trigger used a repeated group inside a lookbehind (=(?<=(?:\+|[INV])(?:[INV+]*[KEY])+[INV+]*=)). JavaScriptCore allocates a backtracking frame per iteration of that group and abandons the whole match, returning false with no error, once the key run before = exceeds roughly 70k characters. The trigger is rewritten as two flat lookbehinds that accept the same language (the run right before = holds a splice and a key character): =(?<=[INV+][INV+KEY]*=)(?<=[KEY][INV+KEY]*=). Equivalence was checked exhaustively on all strings up to length 6 over {a, +, ZWSP, =, space, %} (55,986 strings, 0 differences), and the new form is faster on both runtimes (200k-character text: Node 4.2 ms → 2.9 ms, Bun 243 ms false → 13.6 ms true).

Evidence

  • Regression tests at both layers: redactSensitiveText (pattern owner; the cases live in redact-patterns.test.ts beside the pattern table, redact.test.ts is untouched) and redactTranscriptMessage (the transcript entry point that produced the incident): the prose stays unchanged, and an assistant message carrying smtp:\n user = bot pass: <secret> is persisted with the secret replaced by opaque…7890 (transcript-redact.test.ts).
  • Record shapes asserted masked: bare pass: line, indented YAML, - pass: list item, value on the next line, ;-separated, CR-separated, { user: bot, pass: … }, user=bot pass: …, user = bot pass: …, user= bot pass: …, user = bot pass: …, key=<300 chars> pass: …, user\tpass: …, two records on one line (including values that end in letters, a namespaced, underscore-prefixed, password: or Authorization: Bearer first field, a first value continued on the next line, and a first value that itself contains pass:), a YAML explicit key ? pass\n: …, bypass:\n pass: …, host:db.example.test pass: …, login (pass: …), and a 200k-character token followed by =v pass: …. Prose shapes asserted unchanged: the incident sentence, "Release notes: all suites pass: nothing else changed. Both pass: done.", "Suite result: 12 pass: 0 fail, 1 skipped.", "Use the bypass: it keeps the compass: north.", a clause wrapped across a line break, a 200k-character token followed by pass: still prose, and a 40 KiB text whose pass: lands exactly on a 16 KiB chunk start.
  • The 200k-character record also exercises the prefilter fix on every runtime: on Bun 1.4.2 it was unmasked before this change at 100k, 131k, 150k and 200k characters (masked up to 65k) and is masked at every size after it; a direct Bun run of redactSensitiveText was used as the Bun proof because the PR CI test lanes run under Node.
  • node scripts/run-vitest.mjs over the 13 redaction and transcript suites (src/logging/*redact*.test.ts, src/agents/transcript-redact*.test.ts, src/agents/provider-request-header-redaction.test.ts): 288 tests passed. bun --bun node_modules/vitest/vitest.mjs run src/logging/redact-patterns.test.ts: 5 passed. A test asserts every default string pattern compiles under the safe-regex guard, because a rejected default pattern is dropped silently (an earlier YAML attempt hit exactly that).
  • Independent review: Codex autoreview (P1) on each revision; its rounds on the matcher flagged the lost value-on-next-line shape, a second pass: field after a masked value ending in a letter, a bare field after a namespaced or underscore-prefixed one, a second field after a continued value, the YAML explicit-key form, a word-internal bypass: swallowing the next field, a password: field before a bare one, and a key occurrence inside a consumed value stalling the scan; all are fixed and asserted. ClawSweeper's review of the matcher head (round 10) found the provider-error preview policy gap described above, fixed and asserted in embedded-agent-error-observation.test.ts. ClawSweeper rounds 1–8 on earlier regex revisions found the record-start, YAML list, CR, chunk-start, spaced inline field, aligned/long inline field, and Bun large-input gaps; all are covered by the matcher and the prefilter fix above.
  • Test cost (--maxWorkers=1 wall): src/logging/redact-patterns.test.ts 3.4 s (5 tests, including the 200k-character inputs), src/agents/transcript-redact.test.ts 6.9 s (87 tests, whole file). No timers, sleeps, or process boots added.
  • Follow-up (not in this PR): redacting a 100 KB text shaped like a+a+a+…password=value takes ~15 s under Node because the form-body key grammar backtracks quadratically inside each 16 KiB chunk; the result is correct, the time is not. Tracked separately.

The unquoted config-assignment pattern treated bare `pass` as a secret key in
both the colon and the equals form, so a sentence such as "tests now pass: older
clients ..." lost its next word to `***` in persisted transcripts and logs. The
colon alternative now uses a key list without bare `pass`; `pass=`, `pass = `,
namespaced, prefixed, quoted, query, and form-body forms keep masking.
@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Sep 29, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 29, 2026
@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 29, 2026, 2:46 AM ET / 06:46 UTC (Revision 12).

ClawSweeper review

What this changes

The branch changes log and transcript redaction to preserve prose after pass:, keeps password assignments masked, repairs a Bun long-input prefilter, and adds regression coverage.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main still masks ordinary prose after pass:. The branch addresses that defect and fixes the provider-preview gap from the previous review; this review found no remaining blocking defect.

Priority: P1
Reviewed head: 8b8746febf71caac5512b77a09ec5b7ec7ae81b0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has focused boundary coverage, reported Bun runtime evidence, and no remaining actionable finding on this head.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The verified maintainer-authored PR is exempt from the external-contributor proof gate. Transcript and provider-preview tests cover the changed owner, and the body reports direct Bun before/after redactor results; no stored-data format changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The verified maintainer-authored PR is exempt from the external-contributor proof gate. Transcript and provider-preview tests cover the changed owner, and the body reports direct Bun before/after redactor results; no stored-data format changes.
Evidence reviewed 7 items Current main still has the defect: The generic unquoted assignment rule on fetched main includes bare pass in its colon form, so the reported prose can still be masked. The latest release has the same rule.
Release check: Tag v2026.9.6 retains the original bare-pass assignment rule; the requested fix is not established as shipped.
Introduced matcher: The branch classifies bare pass: using surrounding record context and registers the matcher in the default redaction policy.
Findings None None.
Security None None.

How this fits together

OpenClaw's redaction policy processes agent messages, provider errors, and log text. Its output reaches persisted transcripts, logs, and error previews.

flowchart LR
  A[Agent messages and logs] --> B[Redaction policy]
  C[Provider errors] --> B
  B --> D{Prose or credential field?}
  D --> E[Preserved text]
  D --> F[Masked credential]
  E --> G[Transcript and log output]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +96, Tests +199. Total +295 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 113 17 +96
Tests 4 202 3 +199
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 315 20 +295

Review metrics

Metric Value Why it matters
Production and test growth production +96 net lines, tests +199 net lines The production growth implements contextual classification and the Bun prefilter repair; the test growth covers the affected redaction boundaries.

Technical review

Best possible solution:

Use the shared redaction policy at transcript, log, and provider-preview boundaries, preserving ordinary prose while masking credential-shaped records and retaining the documented inline-field tradeoff.

Do we have a high-confidence way to reproduce the issue?

Yes, at source level: current main's bare pass: colon rule matches the reported prose before transcript persistence. I did not execute a current-main reproduction.

Is this the best way to solve the issue?

Yes. The patch changes the shared redaction owner and covers its transcript and provider-preview callers; the earlier preview gap is repaired on this head.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c259398c7cb3.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The current rule irreversibly masks transcript prose, while redaction changes also affect credential exposure.
  • merge-risk: 🚨 security-boundary: Credential classification changes before transcript and log output; the maintainer has explicitly accepted the documented spaced-inline-field limitation.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The verified maintainer-authored PR is exempt from the external-contributor proof gate. Transcript and provider-preview tests cover the changed owner, and the body reports direct Bun before/after redactor results; no stored-data format changes.

Evidence

What I checked:

  • Current main still has the defect: The generic unquoted assignment rule on fetched main includes bare pass in its colon form, so the reported prose can still be masked. The latest release has the same rule. (src/logging/redact-patterns.ts:73, c259398c7cb3)
  • Release check: Tag v2026.9.6 retains the original bare-pass assignment rule; the requested fix is not established as shipped. (src/logging/redact-patterns.ts:73, eb377ac59e6c)
  • Introduced matcher: The branch classifies bare pass: using surrounding record context and registers the matcher in the default redaction policy. (src/logging/redact-patterns.ts:292, 8b8746febf71)
  • Previous finding resolved: The new head returns programmatic matchers from the full default policy, which the provider error observation caller composes into its explicit policy. A new preview regression covers bare pass: masking. (src/logging/redact.ts:1573, 8b8746febf71)
  • Boundary coverage: Added tests cover prose and credential shapes at the redaction owner, transcript entry point, and provider-preview caller. The PR body reports a direct Bun 1.4.2 before/after run for long input; this review did not execute target code. (src/agents/transcript-redact.test.ts:135, 8b8746febf71)
  • Accepted security tradeoff: The maintainer-authored PR body explicitly accepts that an inline user: bot pass: value record is treated as prose; it documents the narrower user=bot and user:bot forms that remain masked. The security-sensitive guard identifies the author as an administrator. (src/logging/redact-patterns.ts:273, 8b8746febf71)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (11 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-29T03:34:43.702Z sha 9022036 :: blocked before merge. :: [P1] Keep masking space-separated inline pass credentials
  • reviewed 2026-09-29T03:57:53.881Z sha ae821a1 :: needs real behavior proof before merge. :: [P1] Keep masking pass after spaced inline fields
  • reviewed 2026-09-29T04:19:10.920Z sha 7965b31 :: blocked before merge. :: [P2] Bound the inline field prefix before full-text redaction
  • reviewed 2026-09-29T04:34:14.985Z sha d7a88e8 :: blocked before merge. :: [P1] Keep masking pass after aligned or long inline fields
  • reviewed 2026-09-29T04:55:42.657Z sha 838bfe5 :: blocked before merge. :: [P1] Keep masking aligned and long inline pass fields | [P1] Retain pass masking for large Bun inputs
  • reviewed 2026-09-29T05:12:31.991Z sha 2d55c59 :: blocked before merge. :: [P1] Mask later pass fields in the same record
  • reviewed 2026-09-29T06:01:33.604Z sha 75dd0b7 :: blocked before merge. :: [P1] Keep bare-pass masking in composed default policies
  • reviewed 2026-09-29T06:15:58.281Z sha 2bb7263 :: blocked before merge. :: [P1] Include bare-pass masking in provider error redaction

@steipete
steipete marked this pull request as ready for review September 29, 2026 02:19
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: 8b8746febf71caac5512b77a09ec5b7ec7ae81b0
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/logging/redact-patterns.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/logging/redact.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

Review found that dropping bare `pass` from the colon form also exposed
unquoted `pass: value` lines in config-shaped text. A record-start pattern now
keeps those masked (text or line start with indentation, or right after `{` or
`,`); only a `pass:` that follows another word mid-sentence is treated as prose.
…terns

Review found `- pass: value` list items uncovered by the record-start rule; the
rule now accepts a YAML `- ` marker after indentation and a `;` separator. The
first attempt used an optional nested group that the safe-regex guard rejects,
which silently dropped the whole pattern, so a new test asserts every default
string pattern compiles under that guard.
…-pass

# Conflicts:
#	src/logging/redact.test.ts
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

…able

Leave src/logging/redact.test.ts byte-identical to main and host the prose/config
`pass:` boundary cases in redact-patterns.test.ts next to the patterns they pin.
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Sep 29, 2026
…ith full context

Review found two boundary gaps in the record-start rule: a carriage-return-only
line break before `pass:` was not a record start, and the `^` alternative could
read a 16 KiB chunk start as a record start in long text, masking prose. Accept
`\r` as well as `\n`, and register the pattern as chunk-unsafe so it always sees
the full text. Regressions cover both, and the chunk case fails without the
registration.
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Sep 29, 2026
Review found `user=bot pass: value` unmasked: the record-start rule only knew
line starts and a few separators. A preceding inline `key=value` / `key:value`
field, and `(`, `[`, `|`, `&` or a quote, now count as record context, while a
`pass:` that follows a plain word mid-sentence stays prose.
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Sep 29, 2026
…l-text limit

The Bun test lane drops full-text masks for this pattern above roughly 100k
characters (tracked separately); 60k exercises the same linear-cost property
and masks identically under Node and Bun.
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 29, 2026
Replace the record-start regex for bare `pass:` with a programmatic
RedactMatcher. One matchAll finds every `pass:<value>` occurrence and a
single forward pass over the text classifies each one: prose only when a
plain word plus one space precedes it and no `=` or glued `key:value`
field has been seen on that line; everything else masks, including the
YAML value-on-next-line shape the generic rule covered. Namespaced and
prefixed keys stay with their own patterns. The cost is linear in the
text, so long unbroken tokens and dense occurrences no longer need
length bounds that left gaps.
The obfuscated-key trigger in DEFAULT_REDACT_PREFILTER_SOURCES used a
repeated group inside a lookbehind. JavaScriptCore allocates a
backtracking frame per iteration and abandons the whole match, returning
no match and no error, once the key run before `=` passes roughly 70k
characters. redactSensitiveText then took its nothing-could-match fast
path and skipped every default pattern for that text on Bun; Node was
unaffected. Express the same language with two flat lookbehinds (the run
right before `=` holds a splice and a key character), checked
exhaustively equivalent on all strings up to length 6 over the relevant
alphabet and faster on both runtimes.
…e's position

Rework BARE_PASS_ASSIGNMENT_MATCHER after review: one case-insensitive
matchAll finds every credential key with a colon (bare `pass` plus the
generic colon key list; `pass` inside another word is never a key), and
one forward pass classifies each. Namespaced, prefixed and other
credential keys only mark their line as a record without consuming their
value; a bare `pass:` is prose only after a plain word or number with
no assignment earlier on the line, otherwise its unquoted value is read
in place and masked, skipping past it so line breaks inside the match and
keys inside the value cannot disturb the scan. The matcher now runs where
the generic rule handled bare `pass:`, before the namespaced and prefixed
rules, and is registered as an ambiguous assignment shape so tool-payload
exclusion and source-assignment preservation match the old rule. The
string pattern list is derived from the ordered default list.
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Knip's production scan flags the export as unused: the matcher is
registered inside the pattern table and consumed through the default
lists, so nothing imports it by name.
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. and removed P2 Normal backlog priority with limited blast radius. labels Sep 29, 2026
… policy

getDefaultRedactPatterns() returned only the configurable string
sources, and the embedded-agent error observation owner composes its
explicit policy from it, so providerErrorMessagePreview lost bare
`pass:` masking once that rule became a programmatic matcher. Return
the full default policy, matchers included; the string-only list had no
other production consumer and is removed, and the logger plugin test
helper that builds logging.redactPatterns config keeps only the strings.
The matcher's ambiguous-assignment treatment moves to its own matcher
set so the string set stays pattern text. A regression asserts a
provider message starting with `pass: <secret>` reaches the preview
masked.
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 29, 2026
@steipete
steipete merged commit 98f117a into main Sep 29, 2026
209 of 211 checks passed
@steipete
steipete deleted the steipete/redact-prose-pass branch September 29, 2026 07:04
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit to openclaw/clawsweeper that referenced this pull request Sep 30, 2026
OpenClaw #160879 rewrote src/logging/redact.test.ts. The pinned TruffleHog
3.97.4 scan now labels its synthetic connection-string fixtures PLAIN,
ESCAPED_UNICODE, or HTML nondeterministically, and the redacted Postgres
assertion changed indentation. The exact attribution rows only permitted
PLAIN/ESCAPED_UNICODE for that path, so every OpenClaw PR touching the file
was refused before review (hosted run 36514869480 on openclaw/openclaw#160888).

Add seven exact rows for the post-rewrite identities and permit HTML for this
one source. Rows still bind detector, decoder, Raw/RawV2 and complete-line
digests, path, mode, and committed roles. Pre-rewrite rows stay for merge
bases that predate #160879.

Proof: source-admission replay of the #160888 range with pinned native
3.97.4: original policy refused 5/5 runs; candidate admitted 12/12 (104
classified findings). Focused production-policy regression added.

OpenClaw Bay is unaffected; no status, queue, publication, telemetry, or
observer contract changes.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 30, 2026
…claw#160888)

* fix(logging): stop redacting prose after "pass:" as a secret

The unquoted config-assignment pattern treated bare `pass` as a secret key in
both the colon and the equals form, so a sentence such as "tests now pass: older
clients ..." lost its next word to `***` in persisted transcripts and logs. The
colon alternative now uses a key list without bare `pass`; `pass=`, `pass = `,
namespaced, prefixed, quoted, query, and form-body forms keep masking.

* fix(logging): keep config-shaped pass: assignments masked

Review found that dropping bare `pass` from the colon form also exposed
unquoted `pass: value` lines in config-shaped text. A record-start pattern now
keeps those masked (text or line start with indentation, or right after `{` or
`,`); only a `pass:` that follows another word mid-sentence is treated as prose.

* fix(logging): mask pass: in YAML sequence items and guard default patterns

Review found `- pass: value` list items uncovered by the record-start rule; the
rule now accepts a YAML `- ` marker after indentation and a `;` separator. The
first attempt used an optional nested group that the safe-regex guard rejects,
which silently dropped the whole pattern, so a new test asserts every default
string pattern compiles under that guard.

* test(logging): keep the pass boundary regression beside the pattern table

Leave src/logging/redact.test.ts byte-identical to main and host the prose/config
`pass:` boundary cases in redact-patterns.test.ts next to the patterns they pin.

* fix(logging): treat CR line breaks as record starts and match pass: with full context

Review found two boundary gaps in the record-start rule: a carriage-return-only
line break before `pass:` was not a record start, and the `^` alternative could
read a 16 KiB chunk start as a record start in long text, masking prose. Accept
`\r` as well as `\n`, and register the pattern as chunk-unsafe so it always sees
the full text. Regressions cover both, and the chunk case fails without the
registration.

* fix(logging): treat inline key=value context before pass: as a record

Review found `user=bot pass: value` unmasked: the record-start rule only knew
line starts and a few separators. A preceding inline `key=value` / `key:value`
field, and `(`, `[`, `|`, `&` or a quote, now count as record context, while a
`pass:` that follows a plain word mid-sentence stays prose.

* fix(logging): accept spaced key = value context before pass: and prove the transcript path

Review found `user = bot pass: value` unmasked because the inline-record context
required the preceding field's value to touch its `=`. Spaces around `=` now
count; a spaced `key: value` phrase stays prose. A transcript-level test shows a
config-shaped `pass:` credential masked in assistant text before persistence.

* fix(logging): bound the inline-field prefix in the full-text pass: rule

Review noted the inline `key=value` branch scanned an unbounded identifier at
every start position while running over the full text. Bound the key (64) and
value (256) so each attempt costs a constant amount, and cover a 200k-character
single token before `pass:` in both prose and record shape.

* test(logging): keep the long-token pass: regression below the Bun full-text limit

The Bun test lane drops full-text masks for this pattern above roughly 100k
characters (tracked separately); 60k exercises the same linear-cost property
and masks identically under Node and Bun.

* fix(logging): classify bare pass: records with a linear matcher

Replace the record-start regex for bare `pass:` with a programmatic
RedactMatcher. One matchAll finds every `pass:<value>` occurrence and a
single forward pass over the text classifies each one: prose only when a
plain word plus one space precedes it and no `=` or glued `key:value`
field has been seen on that line; everything else masks, including the
YAML value-on-next-line shape the generic rule covered. Namespaced and
prefixed keys stay with their own patterns. The cost is linear in the
text, so long unbroken tokens and dense occurrences no longer need
length bounds that left gaps.

* fix(logging): keep the default prefilter linear on long key runs

The obfuscated-key trigger in DEFAULT_REDACT_PREFILTER_SOURCES used a
repeated group inside a lookbehind. JavaScriptCore allocates a
backtracking frame per iteration and abandons the whole match, returning
no match and no error, once the key run before `=` passes roughly 70k
characters. redactSensitiveText then took its nothing-could-match fast
path and skipped every default pattern for that text on Bun; Node was
unaffected. Express the same language with two flat lookbehinds (the run
right before `=` holds a splice and a key character), checked
exhaustively equivalent on all strings up to length 6 over the relevant
alphabet and faster on both runtimes.

* fix(logging): classify bare pass: keys in one pass at the generic rule's position

Rework BARE_PASS_ASSIGNMENT_MATCHER after review: one case-insensitive
matchAll finds every credential key with a colon (bare `pass` plus the
generic colon key list; `pass` inside another word is never a key), and
one forward pass classifies each. Namespaced, prefixed and other
credential keys only mark their line as a record without consuming their
value; a bare `pass:` is prose only after a plain word or number with
no assignment earlier on the line, otherwise its unquoted value is read
in place and masked, skipping past it so line breaks inside the match and
keys inside the value cannot disturb the scan. The matcher now runs where
the generic rule handled bare `pass:`, before the namespaced and prefixed
rules, and is registered as an ambiguous assignment shape so tool-payload
exclusion and source-assignment preservation match the old rule. The
string pattern list is derived from the ordered default list.

* chore(logging): keep the bare pass matcher module-private

Knip's production scan flags the export as unused: the matcher is
registered inside the pattern table and consumed through the default
lists, so nothing imports it by name.

* fix(logging): give provider error previews the full default redaction policy

getDefaultRedactPatterns() returned only the configurable string
sources, and the embedded-agent error observation owner composes its
explicit policy from it, so providerErrorMessagePreview lost bare
`pass:` masking once that rule became a programmatic matcher. Return
the full default policy, matchers included; the string-only list had no
other production consumer and is removed, and the logger plugin test
helper that builds logging.redactPatterns config keeps only the strings.
The matcher's ambiguous-assignment treatment moves to its own matcher
set so the string set stays pattern text. A regression asserts a
provider message starting with `pass: <secret>` reaches the preview
masked.
steipete added a commit to openclaw/clawsweeper that referenced this pull request Sep 30, 2026
…#1716)

OpenClaw #160879 rewrote src/logging/redact.test.ts. The pinned TruffleHog
3.97.4 scan now labels its synthetic connection-string fixtures PLAIN,
ESCAPED_UNICODE, or HTML nondeterministically, and the redacted Postgres
assertion changed indentation. The exact attribution rows only permitted
PLAIN/ESCAPED_UNICODE for that path, so every OpenClaw PR touching the file
was refused before review (hosted run 36514869480 on openclaw/openclaw#160888).

Add seven exact rows for the post-rewrite identities and permit HTML for this
one source. Rows still bind detector, decoder, Raw/RawV2 and complete-line
digests, path, mode, and committed roles. Pre-rewrite rows stay for merge
bases that predate #160879.

Proof: source-admission replay of the #160888 range with pinned native 3.97.4,
bound to the committed policy digest: baseline (main at the PR base) refused
5/5 runs; candidate admitted 11/12 and classified 86 findings, with one
refusal from the existing duplicate-record guard on a native chunk-overlap
duplicate. Focused production-policy regression added.

OpenClaw Bay is unaffected; no status, queue, publication, telemetry, or
observer contract changes.

Known limit (maintainer exception, follow-up #1724): decoded HTML/ESCAPED_UNICODE
URI findings are attributed to the plain literal wherever it occurs, so an
entity-encoded copy of an approved synthetic value borrows the plain witness;
this is pre-existing exact-path behavior for every HTML row and admits only the
same digest-bound synthetic value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant