Skip to content

feat(rules): leaked-secrets names Cerebras, OpenRouter, NVIDIA, Fireworks, Shopify Admin, Stripe restricted, Google OAuth secrets; sbp_ is a PAT #1309 - #1318

Closed
nc9 wants to merge 3 commits into
mainfrom
feat/1309-secrets-new-patterns
Closed

nc9 wants to merge 3 commits into
mainfrom
feat/1309-secrets-new-patterns

Conversation

@nc9

@nc9 nc9 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1309

Depends on #1298 and #1300 (same file; this branch is a chain on top of them. Merge those first and this PR shows only its own diff).

Named patterns and labels for provider formats that had none or the wrong one. No allowlist and no downgrade: every new detection reports at its own tier, so the review rule (positive evidence for any downgrade) has nothing to bite on except false-positive risk, which the probes below cover.

What changes

  • New patterns: OpenRouter sk-or-v1-+64 hex, Cerebras csk-+40+ lowercase alnum, NVIDIA nvapi-+60+, Fireworks fw_+24-48 alnum (medium, tail must mix upper, lower and a digit so fw_config_name is not a key), Stripe restricted rk_live_, Shopify Admin shpat_/shpss_/shpca_/shppa_+32 hex, Google OAuth client secret GOCSPX-+28.
  • Server-side classes (Shopify Admin, Stripe restricted, Google OAuth client secret, Supabase PAT) are critical in a browser script.
  • sbp_+40 hex is relabelled Supabase Personal Access Token (it is a Management API token for the user's whole account, not a service_role key). The label Supabase Service Role Key had no other user in either repo.
  • A JWT whose iss host is management-*.hygraph.com is Hygraph Management Token (high); another *.hygraph.com/graphcms.com host is Hygraph Content API Token (medium). Whole-host match on the parsed issuer.
  • Cerebras keys beside Groq keys in one array both report (the old legacy sk- pattern never saw csk-: its prefix sits inside a word).
  • Paystack labelling is in fix(rules): leaked-secrets samples, placeholders, base64 runs, prefix collisions, Paystack labelling #1283 #1227 #1298.

Verification

  • 12 new tests in leaked-secrets-providers.test.ts, one harness generator per pattern (the corpus meta-tests derive a positive per context, a prefilter assertion, a corrupted-keyword near-miss, a mid-token near-miss and a duplicate case from each). Suites pass by path (2440 + 244), tsgo --noEmit, make validate, detect-secrets hook clean. Codex pass not run (MCP unavailable).
  • Rule count changes: +7 patterns (the private release guards that pin the catalog will need the new count at release).
  • Skill change: none.

Probes (false-positive and bypass)

Pattern Probe Result
Cerebras 20-char tail, upper-case tail, desk-<48> (prefix inside a word) No match
OpenRouter sk-or-v1- in prose; 20-hex tail No match
Shopify Admin 31 hex; 32 non-hex letters; each of the four prefixes with 32 hex Only the valid forms match (all four reported)
Google OAuth GOCSPX- + 10 chars No match
NVIDIA nvapi- + 20 chars No match
Stripe restricted rk_live_+10; rk_test_+24 No match / not a live key
Fireworks fw_config_option_name_for_the_firewall, fw_ + 26 lowercase, fw_ + 30 uppercase+digits No match (identifier shapes)
Hygraph management-eu.hygraph.com.evil.test, nothygraph.com issuers Ordinary JWT, medium
sbp_ 20-hex tail No match; service_role JWT and sb_secret_ keep their labels
All 1 MB of near-miss prefixes (fw_, nvapi-, shpat_, sk-or-v1-) Linear, under the 4 s bound
Fireworks my-fw_Aa1... (hyphen to the left of the prefix) No match (left boundary excludes letters, digits, _ and -)

Rebase 2026-11-01

Rebased on main (v0.0.156, 99f63d3) as part of the stack 1298 -> 1300 -> 1318 -> 1319 -> 1320; CHANGELOG bullets re-inserted under [Unreleased]; .secrets.baseline line numbers refreshed (no new entries). Draft: corpus A/B pending.

Review round (stack rebased on v0.0.157)

  • Docs: the duplicated "server-only classes" paragraph is one again, with Paystack restored.
  • Fireworks fw_: a camelCase identifier with a digit (fw_handleResizeEvent2Callback) is no longer a key (two lowercase-word/Capital boundaries read as a name); a random key still reports at medium; the 24/48 bounds, the no-upper and no-digit lookaheads and the medium tier are pinned.
  • Shopify Admin tokens: a file name (/files/shpat_<hash>.png, via the asset-name rule), a CSS class (.shpca_<hash>) and a longer word (x-shpat_<hash>) are not tokens; a real shpat_ + 32 hex in a string, assignment, header or Bearer reports high. All four prefixes tested, including a page that holds only a shppa_ token.
  • Tiers asserted, not only types: Shopify Admin, sbp_, GOCSPX- and Stripe restricted keys are critical in a browser-served script (and not in plain HTML); OpenRouter, Cerebras and NVIDIA stay high and Fireworks medium (rule-level check names asserted too). OpenRouter's lowercase-hex alphabet, the graphcms.com Hygraph host and look-alikes are tested.
  • sk-or-v1-+65 hex, GOCSPX-+40, shpat_+64 hex and sbp_+64 report "Secret Key (provider unknown)" at medium: accepted as is.
    Skill change: none.


test("each Shopify prefix is a token; a Stripe restricted key is critical in a script", () => {
for (const prefix of ["shpat_", "shpss_", "shpca_", "shppa_"]) {
expect(found(`var k="${prefix.replace("sh", "s" + "h")}${runOf(r, HEX, 32)}";`).map((f) => f[0])).toEqual(["Shopify Admin API Token"]);

describe("tiers, boundaries and false-positive shapes pinned after review (#1309)", () => {
const rr = seededRng(13090);
const shp = (prefix: string, hex = runOf(rr, HEX, 32)) => `${prefix.replace("sh", "s" + "h")}${hex}`;
@nc9
nc9 force-pushed the feat/1309-secrets-new-patterns branch 3 times, most recently from a6a34aa to 25049d7 Compare November 1, 2026 18:47
nc9 added 3 commits November 2, 2026 06:34
…rs, docs passwords, base64 A runs, asset names; labels Paystack keys #1283 #1227

Signed-off-by: Nik Cubrilovic <[email protected]>
…con JWTs, presigned ids; search keys and consent issuers stay reported #1287 #1229

Signed-off-by: Nik Cubrilovic <[email protected]>
…orks, Shopify Admin, Stripe restricted and Google OAuth secrets; sbp_ is a personal access token; Hygraph JWTs #1309

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the feat/1309-secrets-new-patterns branch from 25049d7 to d1ed5f3 Compare November 1, 2026 19:54
@nc9 nc9 mentioned this pull request Nov 1, 2026
@nc9

nc9 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

@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

2 participants