Skip to content

fix(publish-gate): block credentials after a JSON-escaped newline or tab - #12566

Merged
kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-12562-41552297497-1
Nov 3, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-12562-41552297497-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #12562

Summary

Opened by the work-resolve-issue lane. The run's own summary:

scanLeak now ends with one more pass: the UTF-8 reading with JSON's \n, \r and \t escapes decoded (and \ decoded to one backslash, left to right, so a literal backslash before n is not a line break), checked against BLOCKING only. A \b-anchored token after an escaped line break or tab now blocks, and the WARN_ONLY assignment and HIDDEN results cannot come from this pass. I chose a separate decoded pass over widening normalize, because normalize's comment and its tracked-tree test limit which escapes it may fold. normalize, findSecret and the publish gate itself are unchanged, and the pass runs only when the text holds such an escape.

Not verified

  • node --test lib/publish-gate.test.mjs (the new suite and the tracked-tree tests) was not executed: this lane's shell runs only the named wrappers, so it is left to the PR's CI
  • tidy skipped: the change touches lib/ (a listed shared path), spans 12 files and 6 areas (over the 1-area cutoff)
  • The issue's last criterion, ci-workflows scan-upload withholding a JSON file with a line-start token, holds only after release (it fetches the gate at tip); it is a check outside this repository
  • Review noted, as by design: decoding \n gives the ^-anchored netrc 'password <value>' line shape and tab-separated 32/64-hex R2 pairs inside JSON strings the same blocking reading they already get in plain text; no tracked file found affected
  • The WARN_ONLY password/secret assignment is \b-anchored but not a blocking format, so it gets no decoded-pass test; per the issue's refinement, no new warn behaviour is added for escaped JSON

Fix

  • lib/publish-gate.mjs: new BREAK_ESCAPES/unescapeBreaks helpers and a final scanLeak pass that runs firstHit(BLOCKING) on the escape-decoded UTF-8 text; scanLeak's doc comment names the pass
  • lib/publish-gate.test.mjs: new 'leak scan on JSON-escaped text' suite: after-newline and after-tab JSON.stringify cases for each \b-anchored blocking shape (AWS, GitHub, OpenAI, Slack, Stripe, R2 pair, Cloudflare, upload token, npm, Google, JWT, Pulumi, both netrc forms), lone CR and CRLF, the exist
  • plugins/review/lib/publish-gate.mjs: regenerated byte copy (sync-shared-copies)
  • plugins/visualization/lib/publish-gate.mjs: regenerated byte copy (sync-shared-copies)
  • plugins/work-items/lib/publish-gate.mjs: regenerated byte copy (sync-shared-copies)
  • plugins/harness-ops/lib/publish-gate.mjs: regenerated byte copy (sync-shared-copies)
  • plugins/source-control/lib/publish-gate.mjs: regenerated byte copy (sync-shared-copies)
  • .changes/review/work-resolve-issue-issue-12562-41552297497-1-5eba9e7f.md: patch fragment (copy only; the plugin does not call scanLeak)
  • .changes/visualization/work-resolve-issue-issue-12562-41552297497-1-8a7150f1.md: patch fragment (copy only; the plugin does not call scanLeak)
  • .changes/work-items/work-resolve-issue-issue-12562-41552297497-1-feeaad7c.md: patch fragment for the telemetry body gate's leak scan
  • .changes/harness-ops/work-resolve-issue-issue-12562-41552297497-1-ee6b9d2b.md: patch fragment for the telemetry body gate's leak scan
  • .changes/source-control/work-resolve-issue-issue-12562-41552297497-1-4b45ceb0.md: patch fragment for the babysit-loop telemetry body gate's leak scan

Verification

The runner ran each check from the base copy against 4d2ab61:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • sync-shared-copies (generate): regenerated the 5 plugin copies of lib/publish-gate.mjs
  • sync-shared-copies --check: all 565 registered copies match their canonical sources
  • check-changelog-fragments: all 19 fragments under .changes/ valid (run before and after the review fixes)
  • check-changed-skills: no changed skills, nothing to gate
  • check-affected: 11 passed, 7 skipped, 0 failed over 12 changed files (run before and after the review fixes)
  • cant-fail-scan --file lib/publish-gate.test.mjs --lines 412-462 --check: PASS, no gating findings
  • fresh-context review subagent (hand-traced, nothing executed): no correctness bug; each new assertion traced to hold, \ decoding correct, no performance risk. Applied its test-gap findings: added a lone-CR case, added a case that pins the \ decoding (a naive decoder would block it), and made the d
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/41552297497

Left out: the items under Not verified.

Related

#12562

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 4d2ab612bad13ed37d8d64a2ea8876479205b211: read 12 of 12 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #12566, fix(publish-gate): block credentials after a JSON-escaped newline or tab

No security issues found.

Trusted path checked. lib/publish-gate.mjs is on the trusted-path list, so I read its whole change and the function it changes. In scanLeak (lib/publish-gate.mjs#L287-L301) the change adds one last pass. That pass decodes \\, \n, \r and \t in the UTF-8 reading and runs firstHit(BLOCKING, …) on the result. It returns early only with a credential block, and it runs after every earlier pass (classify, deeperLeak, the NFKC/UTF-8 pass), none of which changed. The final warn ? { warn: true } : {} return is also unchanged. So the gate can only block more than it did on the base. Nothing that blocked before now passes, and no warning is suppressed. The change widens no control.

  • ReDoS / cost: unescapeBreaks uses /\\([\\nrt])/g with a lookup callback. That is linear, and it can never return undefined because the capture group only matches keys of BREAK_ESCAPES. The BLOCKING patterns already run over the UTF-8 reading, so the extra pass adds no new regex exposure. It runs on one more string of about the same length.
  • Decoding order: \\ is decoded left to right in the same alternation, so an escaped backslash followed by n is not misread as a line break. That could only cause a false block anyway, never a missed one.
  • Plugin copies: plugins/{harness-ops,review,source-control,visualization,work-items}/lib/publish-gate.mjs all have the same change, which I read once at plugins/harness-ops/lib/publish-gate.mjs. These are ordinary plugin library paths, not hook, workflow, settings or manifest paths, so where they sit does not change what the code does.
  • Tests and changelog fragments: lib/publish-gate.test.mjs only adds test cases, built from split string literals so no real token is written. The .changes/** fragments are prose only.
  • PR context: I found no embedded instructions aimed at this lane. No plugin manifests changed. No owner friction holds were touched.

Spend and holds: none. The change adds no billing surface and no lane spend.

No prior findings from this lane; the round cap did not apply.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

claude-review reviewed 4d2ab612bad13ed37d8d64a2ea8876479205b211: read 12 of 12 changed file(s); 1 finding(s), 0 as inline comments.

Code review: PR #12566, publish-gate: block credentials after a JSON-escaped newline or tab

Scope. I read every hunk of the canonical lib/publish-gate.mjs and lib/publish-gate.test.mjs changes and of the three distinct changelog fragments. The five plugin copies are byte-identical to each other, so I read plugins/harness-ops/lib/publish-gate.mjs and counted the other four (review, source-control, visualization, work-items) as copies. Each copy sits at the same lib/publish-gate.mjs path inside its own plugin, so the path doesn't change what the code does. No plugin manifest changes, so the manifest checks don't apply.

What the change does. scanLeak now ends with one more pass. It takes the UTF-8 reading, decodes \\, \n, \r and \t left to right with unescapeBreaks, and runs firstHit(BLOCKING, …) on the result. I traced it by hand against SECRET_PATTERNS and the test helpers (key, hex, b64url, clean at lib/publish-gate.test.mjs:32-45); I ran nothing.

  • Escape handling. Decoding \\ in the same pass means a literal backslash before n (x\\npassword …) is not read as a line break. A real break after an escaped backslash (C:\\dir\\\n<token>) still is.
  • Line splitting. firstHit splits on \r?\n, so a decoded lone \r or a tab is a non-word character in front of the token, and the \b anchor holds.
  • No warn path. Only BLOCKING patterns run, so this pass can't produce the WARN_ONLY or HIDDEN result. That matches the issue's refinement.
  • Earlier passes. Every sample I traced stays unmatched by the earlier passes, because the escape letter sits directly before the token. So each test reaches the new pass and gets the expected label.
  • Clean inputs. The negative cases (C:\\new\\table\\rules, clean plus a tab, an escaped assignment) stay {} under the new pass.

Closing issue #12562, acceptance criteria:

  • Blocks the two {} rows for every \b-anchored shape, with a test for each: met in code. The test list misses one \b-anchored shape, the R2 access_key_id= / secret_access_key= assignment alternative (inline comment).
  • Text clean today stays clean (separate decoded pass): met by design, since normalize is unchanged. The new negative tests cover it. The author's claim that no tracked file is affected is unverified: the tracked-tree suite does not run scanLeak.
  • Plugin copies stay in sync: the five copies in the diff are identical. The author's sync-shared-copies --check result is author-claimed and unverified.
  • scan-upload withholds once released: outside this repository. The PR says so under "Not verified".

Author-claimed, unverified: the CI-style checks in the Verification section, and the fact that node --test lib/publish-gate.test.mjs was not run by the authoring lane. This review ran nothing either.

Note for the security lane (not counted here): unescapeBreaks decodes a single JSON level. In text that is JSON inside JSON, such as a tool result holding gh api JSON inside an execution file (one of the surfaces the issue names), a line break is written as \\n. That decodes to a literal backslash and n, so a token at the start of a line there is still missed. The issue's criteria only name single JSON.stringify encoding.

No cost or hold class applies.

critical-findings: 1

Findings not posted inline (their lines are not in the diff):

  • lib/publish-gate.test.mjs:124 (RIGHT): Advisory: one \b-anchored shape has no test. The issue's first acceptance criterion reads: "scanLeak blocks the two {} rows above, for every \b-anchored shape in SECRET_PATTERNS, with a test for each."

The R2 key pair label has two shapes (lib/publish-gate.mjs:51):

  • the hex pair, which this sample covers;
  • the assignment alternative \b(?:access_?key_?id|secret_?access_?key)["']?\s*[:=]\s*["']?[0-9A-Za-z/+]{16,}, which has no sample.

In one-line JSON the assignment form is missed today for the same reason as the others: {"text":"intro\naccess_key_id=AbCdEfGhIjKlMnOp12"} has the letter n directly before access. The new pass catches it, but no test fails if a later change stops it. (A quoted value fails in JSON either way, because \" can't match ["']?[0-9A-Za-z/+], so the sample needs an unquoted value.)

Adding a row covers both the newline and the tab loops:

    ["R2 key pair", `${"access"}_key_id=${"Ab1".repeat(6)}`],

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 3, 2026
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 4d2ab612bad13ed37d8d64a2ea8876479205b211.

Merged via the queue into main with commit 542fd60 Nov 3, 2026
65 checks passed
@kyle-sexton
kyle-sexton deleted the work-resolve-issue/issue-12562-41552297497-1 branch November 3, 2026 00:55
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): scanLeak misses credentials after a JSON-escaped newline or tab

1 participant