Skip to content

fix(tech-detect): validate Clerk publishable keys - #1481

Closed
WilliamK112 wants to merge 2 commits into
squirrelscan:mainfrom
WilliamK112:codex/clerk-key-shape-1478
Closed

WilliamK112 wants to merge 2 commits into
squirrelscan:mainfrom
WilliamK112:codex/clerk-key-shape-1478

Conversation

@WilliamK112

Copy link
Copy Markdown
Contributor

Summary

  • require a publishableKey signal to decode to a Clerk frontend host ending in $
  • keep real production and development Clerk keys detectable while rejecting Stripe-shaped keys
  • document the stricter signal and add the unreleased changelog entry

Fixes #1478

Verification

  • bun test packages/tech-detect/tests (422 passed)
  • bun run --filter @squirrelscan/tech-detect typecheck
  • bun run format:check
  • bun run lint
  • bun run docs:check
  • bun run test:release

Checklist

  • I added or updated tests for behavioral changes.
  • I did not include secrets, customer data, or incompatible third-party material.
  • Every commit includes a DCO Signed-off-by line (git commit -s).

Docs: updated docs/cloud/technologies.mdx
Skill: used the gh-cli workflow for issue and pull request handling

@nc9

nc9 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Thank you William, the Clerk key validation is going in with your commit and authorship intact. Review notes: it decodes the key body and checks the host, which is sounder than the alternative draft (that one still matched a body holding a base64 fragment of clerk, a host without the closing $, and trailing bytes); it stays linear on 1 MB hostile inputs; and real pk_test and pk_live keys still match. We add two maintainer commits on top: your three test lines get the secret-scan allowlist comment (the Secret scan job failed on them), and the tests are rebuilt with keys made at run time, a few more cases (base64url, unpadded, malformed bodies) and a lower body floor so short real hosts such as a.clerk.x.com$ still match. This lands in the next release batch and this PR closes with the new SHAs after the release.

nik

@WilliamK112

Copy link
Copy Markdown
Contributor Author

Thank you for adopting this and preserving authorship. I checked the full CI after your note and pushed follow-up 2b756c14: it rebuilds the four stale Clerk fixtures in packages/audit-engine/tests/tech-bundle-real-build-1254.test.ts with a valid run-time key and adds the secret-scan allowlist comments. The focused tech-detect plus real-bundle suite passes: 14 tests, 0 failures; format check is clean.

The adopted PR #1482 currently reports the same four audit-engine misses, plus an unrelated per-host throttle timing failure. Cherry-picking 2b756c14 should resolve the four Clerk misses.

nc9 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed head: 2b756c1

Verdict: pending maintainer review. The new commit (2b756c1) does what William describes and addresses the four stale fixtures. This PR is the source for the adopted #1482, so the findings below are mostly for the maintainer's merge decision.

  1. Medium: the PR is not mergeable as is. GitHub reports it as conflicting with main, and no CI has run on this head (status is pending). Per the earlier maintainer note it lands through fix(tech-detect): validate Clerk publishable keys (#1481 adopted) #1478 #1482 with authorship preserved.
  2. Low: the body floor is still {20,200} in both regexes (packages/tech-detect/src/fingerprints/other.ts, the two inBundle patterns). A key for a short host such as a.clerk.x.com$ (16 base64 characters) is not matched. The maintainer commits on fix(tech-detect): validate Clerk publishable keys (#1481 adopted) #1478 #1482 lower the floor.
  3. Low: isClerkPublishableKey requires the decoded host to contain clerk.. Keys for a custom frontend API domain without that label are not matched. This is deliberate and fine for the false-positive goal, but worth a line in the docs.
  4. Info: linear behaviour holds. The body is capped at 200 characters, the validator runs only on regex candidates, and matchesInCode still bounds candidates by MAX_IN_CODE_CANDIDATES.
  5. Info: conventions are met. Both commits carry DCO sign-offs, the CHANGELOG entry is under [Unreleased], docs/cloud/technologies.mdx is updated, there is no new runtime dependency, and the new test file covers Stripe pk_live_ and pk_test_ negatives plus live and dev Clerk positives.

Thank you William for the quick follow-up on the fixtures.

nik

@nc9

nc9 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Thank you William, your follow-up commit 2b756c14 is folded in under your authorship: it fixes the real-build fixture key (without it four tests in tech-bundle-real-build-1254 fail under the stricter check, which the earlier staged branch would have hit in CI) and the secret-scan allowlist comments. The two maintainer commits are now one: the Clerk tests rebuilt with run-time keys, more cases, and a lower body floor. Status: tests green locally (tech-detect 17 files, tech-bundle-real-build-1254 11), Secret scan clean. It lands in the next release batch and this PR closes with the new SHAs after the release.

nik

@nc9

nc9 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Landed in v0.0.155 as 51027b0b, d9319e20 (your commits, authorship kept) via #1503, with a maintainer follow-up on top. Thank you William for the Clerk key validation.

nik

@nc9 nc9 closed this Nov 1, 2026
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.

Tech detection: Clerk publishable-key pattern matches a Stripe publishableKey (pk_live_)

2 participants