Skip to content

fix(publish-gate): fold more obfuscations and catch UTF-8 look-alikes in the leak scan - #11570

Merged
kyle-sexton merged 7 commits into
mainfrom
fix/8811-publish-gate-utf8-pass
Oct 31, 2026
Merged

kyle-sexton merged 7 commits into
mainfrom
fix/8811-publish-gate-utf8-pass

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Closes #8811

Replaces #11533, whose fix lane could not close its open review thread: the gap changes the shared leak scan and the lane runs no code. This PR carries #11533's commits, merged with main, plus the UTF-8 pass that thread asked for. #11533 is held with do-not-merge.

Summary

normalize() in lib/publish-gate.mjs now repeats, per line, NFKC, stripping of zero-width characters (U+200B-U+200D, U+2060, U+FEFF) and the soft hyphen, \uXXXX decoding, tag removal and entity decoding until a pass changes nothing, then drops a single backslash before ASCII punctuation. A backslash before /, ., " or ' stays: folding those turns tracked regex sources and escaped JSON into paths, hostnames and assignments.

New here: scanLeak reads bytes as latin1, so NFKC and the invisible strip never saw a real zero-width space or fullwidth letter in the lanes' leak scan. It now also decodes the bytes as UTF-8 and runs the blocking credential patterns over that text with normalize(). Latin1 stays for the byte patterns, the warn-only assignment, and the UTF-16LE and split-line passes, so non-ASCII text beside a plain assignment still only warns.

Not verified

  • The lanes' scan jobs did not run this head; scanLeak was only called directly, in the suites and the tree comparison below.
  • A hidden plain assignment (not a credential format) is not blocked by the UTF-8 pass. That label warns or blocks only in the latin1 pass.
  • A credential split across lines by a look-alike is not caught: the line-break fold (fix(publish-gate): match a credential split across a line break #8806), a split across two sources, and base64, hex and reversed encodings stay out of scope, as the issue states.
  • Carried from fix(publish-gate): fold more obfuscations in normalize() #11533: the tag and entity fixpoint has no pass cap, so cost grows with nesting depth; a cap would let deeper nesting slip past, and a slow scan already fails closed. The tracked-tree test compares whole files, as the issue's done-when states.

Fix

  • lib/publish-gate.mjs: the normalize() folds, exported normalize and firstHit (with an optional fold), and folds() counting \uXXXX and backslash escapes, from fix(publish-gate): fold more obfuscations in normalize() #11533. New: the UTF-8 pass in scanLeak. It calls firstHit over the blocking patterns rather than findSecret, whose first hit can be a plain assignment on an earlier line, and it skips bytes whose UTF-8 and latin1 readings match.
  • lib/publish-gate.test.mjs: one case per fold and the tracked-tree test from fix(publish-gate): fold more obfuscations in normalize() #11533. New: seven scanLeak cases on UTF-8 bytes (zero-width space, soft hyphen, fullwidth look-alike, a credential after a plain assignment, non-ASCII beside a plain assignment, plain non-ASCII text, invalid UTF-8 around a token).
  • plugins/review/lib/publish-gate.mjs, plugins/visualization/lib/publish-gate.mjs: regenerated by scripts/sync-shared-copies.sh.
  • .changes/review/ and .changes/visualization/ fragments: one more sentence for the leak scan.

Verification

  • Before the fix, the four hidden-credential cases failed and the three guard cases passed; after it, all seven pass.
  • lib/publish-gate.test.sh: 97 tests, 97 passed, 0 failed.
  • .github/actions/resolve-config/callers.test.mjs: 211 passed, 0 failed.
  • .github/scripts/apply-patch/apply-patch.test.mjs: 195 passed, 0 failed.
  • .github/scripts/work-resolve-issue/report-outcome.test.mjs: 347 passed, 0 failed.
  • scripts/sync-shared-copies.sh --check: all 548 registered copies match.
  • scripts/check-changelog-fragments.sh --check: all fragments valid.
  • scanLeak over all 16,018 tracked regular files, fix(publish-gate): fold more obfuscations in normalize() #11533's head against this change: 0 results differ, so no file newly blocks or warns. Total scan time went from about 15.4 s to about 17.1 s.

Related

#8811
#11533
#8806

🤖 Generated with Claude Code

melodic-automation-lanes Bot and others added 7 commits October 31, 2026 12:22
Lane-Activity: work-resolve-issue/resolve-issue
Lane-Activity: pr-unblock/address-feedback
Lane-Thread: PRRT_kwDOTCGFQM6yQvxk
scanLeak read bytes as latin1 only, so NFKC and the invisible strip never
saw a real zero-width space or fullwidth letter, and a credential hidden
that way passed the lanes' leak scan. Add a UTF-8 pass for credential
formats; latin1 stays for the byte patterns and the warn-only assignment.

The pass uses firstHit over the blocking patterns rather than findSecret,
whose first hit can be a plain assignment on an earlier line.

Refs: #8811

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KeBVgcHpe4YpFuL5b24Ft2
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T15:00:03.544909Z 870d9f2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 870d9f2ab6300b143e0c79de52127a2250a5e7ea: 0 finding(s), 0 as inline comments.

No security issues found in this change.

Scope read: the whole diff (6 files). That is lib/publish-gate.mjs (a trusted path), its two generated copies under plugins/review/lib/ and plugins/visualization/lib/, the test file, and two changelog fragments. No plugin.json or marketplace.json change, so there are no manifest <field> lines. No instruction-surface deletions. The PR context file contains no embedded directives.

What lib/publish-gate.mjs gates: the publish gate and the lanes' leak scan (scanLeak) decide what may be published and what blocks a lane. I read the change for widening, meaning anything that lets through what the base blocked:

  • normalize() only adds folds: NFKC, invisible-character stripping, \uXXXX decoding, a tag and entity fixpoint, and single-backslash folding. The raw-line check still runs first and the normalized copy is checked in addition, so nothing the base blocked is now passed.
  • folds() now also counts \uXXXX and backslash escapes, so more lines escalate a plain assignment from warn to block. That is narrower, not wider.
  • The new UTF-8 pass in scanLeak runs after classify and deeperLeak and can only add a credential block (firstHit(BLOCKING, decoded)). Existing blocks and warns return earlier and are unchanged. It skips when the UTF-8 and latin1 readings are equal, so ASCII-only input behaves as before.
  • The fixpoint loop terminates. Every pass either shrinks the text or reaches a stable NFKC form, and <[^<>]*> does not backtrack quadratically on a single scan. Deeply nested tags cost O(n²) per line. The PR body acknowledges this and says a slow scan fails closed, so it is not a bypass and no attacker impact follows.
  • The \\([^\sA-Za-z0-9/."']) fold deliberately leaves \/, \., \" and \' as written. That keeps the tracked-tree false-positive test passing and does not open a bypass for the credential formats covered by the new tests.

Residual gaps (already stated in the PR body, out of scope per the linked issue): base64, hex and reversed encodings, the line-break fold (#8806), and a hidden plain assignment (not a credential format) in the UTF-8 pass. These are existing limits, not regressions from this diff.

Spend: the leak scan takes slightly longer (about 15.4 s to about 17.1 s over the whole tree per the PR body). That is CI time only, with no billing change, so there is no cost hold.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 870d9f2ab6300b143e0c79de52127a2250a5e7ea: 0 finding(s), 0 as inline comments.

Code review: no findings

I read the full diff (.claude-lane/pr.diff), the PR context, and the head lib/publish-gate.mjs (the two plugin copies are byte-identical in the diff). I ran no code. Test and measurement numbers in the PR body (97 tests, the 16,018-file scanLeak comparison) are the author's claims, and I did not confirm them.

Trusted path: lib/publish-gate.mjs matches the trusted-path list, so I read the whole change and what it gates. Every change makes the gate stricter. normalize() folds more, folds() counts more escapes as a reason to block a plain assignment, and scanLeak gains a UTF-8 pass that only returns credential-format blocks. Nothing loosens an existing check. The new UTF-8 pass is guarded by decoded !== text, uses BLOCKING, so it cannot return the warn-only label, and keeps the latin1 passes ahead of it. I found no way for it to hide an earlier block or warn.

Closing issue #8811, checked against its done-when list:

  • normalize() now does NFKC, invisible-character strip, \uXXXX decode, and tag and entity folding to a fixpoint. It folds a single backslash only before punctuation other than / . " '. The PR body explains why, as the issue's "a step that adds a hit is dropped, with the reason" clause requires. Tests pin it (a backslash before a letter, a slash, a dot or a quote stays).
  • Each new fold has its own findSecret case, plus seven scanLeak cases on UTF-8 bytes.
  • The tracked-tree false-positive test is committed.
  • The two shared copies match the source, and the changelog fragments exist for both carriers (review and visualization) at bump: patch, which fits a stricter-gate fix.
  • No plugin.json or marketplace.json changed, so no manifest lines apply.

Residual gaps, all stated in the PR body or changelog (not findings):

  • A machine path written with JSON-escaped slashes (\/home\/name\/) still passes, because \/ is deliberately left unfolded.
  • The tag and entity fixpoint has no pass cap, so a single very long line of deeply nested &amp;amp;… costs quadratic time. The author notes that a slow scan fails closed.
  • Hidden plain assignments are not blocked by the UTF-8 pass.
  • Line-break and cross-source splits stay with fix(publish-gate): match a credential split across a line break #8806.

Spend: none. No paid or billed resource and no lane-run settings change.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 31, 2026
Merged via the queue into main with commit 34f80de Oct 31, 2026
44 checks passed
@kyle-sexton
kyle-sexton deleted the fix/8811-publish-gate-utf8-pass branch October 31, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(publish-gate): fold more obfuscations in normalize()

1 participant