Skip to content

fix(gitleaks): anchor the installation-token rule on a word boundary - #928

Merged
kyle-sexton merged 1 commit into
mainfrom
fix/gitleaks-ghs-word-boundary
Oct 30, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
fix/gitleaks-ghs-word-boundary

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

No related issue: main-red fix for a downstream consumer; claude-code-plugins main has failed its gitleaks scan since the 19:15Z standards sync.

Summary

The github-app-installation-token rule matched words that end in "ghs" followed by a long snake_case tail. claude-code-plugins' test fixtures contain highs_and_lows_of_the_market_over_the_year and laughs_out_loud_at_the_whole_long_meeting_today to prove its guardrails ignore them. Since sync #11340 brought this rule over, every main pr-require-checks run there has failed lint-repo on gitleaks (first red: run 41115660342 at 19:29Z).

Fix

Anchor the regex on a leading word boundary: \bghs_[A-Za-z0-9._-]{36,}. Both real formats still match: a classic token and a stateless ghs_<appid>_<jwt> token, where the prefix follows =, a quote or whitespace.

Verification

  • components/gitleaks/gitleaks.test.sh gains a stay-quiet case. It fails against the old config ([20] ... exit expected 0 got 1) and the full suite passes with the fix (25/25).
  • A local gitleaks git --log-opts=--all over claude-code-plugins with the fixed rule gives 0 hits for this rule (6 before). A sample holding both real token shapes still gives 2 hits.

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_01KeBVgcit2kegjiQYpvp8ji

The github-app-installation-token regex had no leading boundary, so words
ending in "ghs" with a long snake_case tail (highs_and_lows_..., laughs_out_...)
matched. claude-code-plugins' test fixtures carry exactly those words to prove
the guardrails ignore them, and since the 19:15Z sync its main gitleaks scan
fails on them. A leading \b keeps both real token formats matching.

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

chatgpt-codex-connector Bot commented Oct 30, 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-30T21:28:00.120675Z b837c7b 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

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

No findings.

I read the 2-file diff and the PR context, and looked for other copies of the regex. The only occurrence outside the diff and PR context is .gitleaks.toml:25.

  • Regex change: \bghs_[A-Za-z0-9._-]{36,} no longer matches highs_… or laughs_…, because there is no word boundary between h or g and s_. It still matches a token that follows =, :, a quote or whitespace, which covers the two token shapes the tests use.
  • New test: I counted the tails of both test strings. They are 36 and 40 characters, so the old rule would have matched both and the stay-quiet case would fail against it. The test sits beside the existing stateless-token case and uses the same assert_exit pattern.
  • Residual gap, not worth blocking: a real token directly preceded by a word character, such as x_ghs_<...> or 1ghs_<...>, is no longer flagged. That is a rare shape, and the PR accepts it in exchange for removing the false positives.
  • Verification: I did not run gitleaks or the test suite. The PR's claims of 25/25 passing and 0 hits in claude-code-plugins are author-claimed and unverified by me.
  • PR body contract: the body follows it. It opens with No related issue: <reason>, and has Summary, Fix, Verification and Related sections.
  • Closing issue: there is none, so no acceptance criteria apply. Nothing in the PR context file reads as embedded instructions.

@github-actions

Copy link
Copy Markdown

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

No security findings in PR #928 at head b837c7b. critical-findings: 0

The PR adds a leading \b to the github-app-installation-token rule in .gitleaks.toml, and adds a stay-quiet test case to components/gitleaks/gitleaks.test.sh. I read the diff and the PR body. The settled-threads and PR-context files were not supplied, so I used gh pr view and gh pr diff.

  • Narrowed detection: the rule now misses a ghs_ token only when a word character (letter, digit or _) directly precedes it, for example foo_ghs_<jwt>. Real tokens appear after =, a quote, whitespace, : or Bearer , where \b still matches. The change cannot be abused for exfiltration: an attacker who controls a commit could only skip this one custom rule by prefixing a word character, and that does not help them reach a secret they don't already hold. The default gitleaks github-app-token rule is still active (useDefault = true) and has no boundary, so it still catches classic-format tokens even with a prefix. Only the stateless ghs_<appid>_<jwt> form loses coverage in that prefixed case. This is a SUGGESTION-level observation at most, with no concrete exploit path, so I did not report it.
  • Trust controls: none of the trust-control, hold or trusted-path files are touched. There are no workflow, token-scope, kill-switch, manifest or instruction-surface changes. The test addition only runs gitleaks against a temp directory.
  • Manifests: no plugin manifests are changed, so there are no manifest <field> lines.
  • Throughput-phase note: no named friction holds are weakened.

@kyle-sexton
kyle-sexton merged commit 087158f into main Oct 30, 2026
24 checks passed
@kyle-sexton
kyle-sexton deleted the fix/gitleaks-ghs-word-boundary branch October 30, 2026 21:31
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.

1 participant