Skip to content

fix(rules): leaked-secrets classifies signed-URL JWTs and browser SDK keys; names and lone AWS ids stay reported #1293 #1294 - #1320

Closed
nc9 wants to merge 5 commits into
mainfrom
fix/1293-1294-secrets-public-clients
Closed

nc9 wants to merge 5 commits into
mainfrom
fix/1293-1294-secrets-public-clients

Conversation

@nc9

@nc9 nc9 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1293
Fixes #1294

Depends on #1298, #1300, #1309 and #1292/#1308 (a chain on one file; merge in that order and this PR shows only its own diff).

Classifies signed-URL tokens and browser SDK keys. Per review (public and info findings are absent from the JSON output, so a downgrade is a silent drop for machines): only positive evidence downgrades to public; a name or a URL parameter alone keeps the finding reported at medium with the evidence in meta.

What changes

  • A JWT that is the value of a token/jwt/sig/signature/access_token/X-Amz-* URL parameter with an exp, no role, and either a url claim or the /object/sign/ storage path in the URL is labelled Signed URL Token (JWT), still medium and in the output, with expiresAt, expired and a hint. A session or user JWT in ?token=, a service_role key, an admin scope, a role-carrying token and a token with no exp are never labelled this way.
  • Public (positive evidence): apiKey as the key of the object that is the argument of Bugsnag...(/amplitude...( or the value of bugsnag:/amplitude: (the SDK must be the immediately enclosing call or object); data-*-api-key/data-*-access-token on a <script src> from another host (secret-named attributes are not claimed); RevenueCat prefixes (appl_, goog_, amzn_, strp_, rcb_ + 28-40 alnum with a digit) within 200 characters of Purchases/RevenueCat.
  • Dropped after review: Datadog, Rollbar, Crisp, Tawk.to, Smartlook and Help Scout rows (their apiKey/accessToken is the secret key or has no distinctive shape).
  • Hint only (stays medium, not public): NEXT_PUBLIC_/NUXT_PUBLIC_/VITE_/PUBLIC_ env names and public*/publishable*/client*Key names (privileged words disqualify even the hint); no hint for an sk_/rk_/sb_secret_ value.
  • A lone AKIA id (no 40-character base64-alphabet value within 300 characters, keyed or not) is medium instead of high, still visible, with meta.pair. An id beside any such value stays high.

Verification

  • 20 tests in leaked-secrets-public-clients.test.ts; harness fixtures for the AWS id (now medium alone, high with a secret) updated; snapshot churn confined to AWS and the RevenueCat generator. Suites pass by path, tsgo, make validate, detect-secrets hook clean. Codex pass not run (MCP unavailable).
  • Skill change: none.

Probes (bypass and false-negative)

Rule Probe Result
Signed URL label Supabase signed URL in img src, srcset, og:image, inline JSON, ?jwt=, ?sig=, ?signature= Labelled, medium, with expiry and hint (visible)
Signed URL label Session JWT with an email in ?token= / ?access_token= (no url claim, no sign path) Hole in v1 (relabelled any ?token= JWT). Fixed: plain JWT. A token with no url claim under the /object/sign/ path is labelled
Signed URL label No exp; role: authenticated; service_role; admin scope; sb_secret_ in the URL Not labelled; reported as before
SDK context datadogSetup({apiKey}), new Rollbar({accessToken}), Crisp.configure, Tawk_API.init Hole in v1 (brand word anywhere nearby made any key public). Fixed: not claimed, medium generic
SDK context // bugsnag, clean config then var sendgrid={apiKey}; /* amplitude */ var svc={apiKey}; Bugsnag.start({other:1}); var svc={apiKey} Hole in v1. Fixed: not the enclosing call; medium generic
SDK context Bugsnag.start({apiKey}), amplitude.getInstance().init({apiKey}), bugsnag={apiKey} Public
Widget attribute data-secret, data-tb-secret, data-client-secret, data-password, data-aws-secret on a third-party script Hole in v1 (public/info, base was medium). Fixed: not claimed; medium generic
Widget attribute Secret-prefixed data-api-key on a third-party script; data-api-key on a first-party script Stripe Live Key high; generic medium
RevenueCat goog_ModuleLoaderConfigurationData1xx, prefix + 28-40 alnum with no Purchases/RevenueCat within 200 chars Hole in v1 (public with no context). Fixed: no finding without the SDK's name
Public-looking names NEXT_PUBLIC_X_API_KEY holding sk_live_...; client_secret_key, publicPrivateApiKey; NEXT_PUBLIC_SECRET_KEY, VITE_PASSWORD Reported (stripe high; others medium, never public)
AWS id ["AKIA...","<40>"], {id, secret:"<40>"}, a secret 250 characters away Hole in v1 (only keyed secrets counted). Fixed: high
AWS id Id with no 40-character value within 300 characters; a secret 400+ characters away Medium with pair
AWS id Unattributed AKIA..._PROD token Keeps Secret Key (provider unknown)
Performance 100k ?token=eyJ leads, 40k widget attributes, 2.5k long public-looking names, 40k AKIA ids Linear, under the 5 s bound

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). Fixed: the corpus test (security/leaked-secrets.test.ts) never finished on the original head: the RevenueCat generator could not fire bare (the pattern needs the SDK name beside the value), and draw() retried for ever. The generator now carries a key name and skips contexts that spell their own key names, draw() fails after 500 attempts instead of hanging, and the snapshot (expected.json) was regenerated (the AWS pair hint wording had drifted from the stale snapshot). Draft: corpus A/B pending.

Review round (stack rebased on v0.0.157)

  • Signed URL Token (JWT) now needs ALL of an exp, a url claim and a token/jwt/sig/signature/access_token/X-Amz-* query parameter, and no role or admin scope. A url claim without the parameter, a user or API token inside a /object/sign/ URL (no url claim), and role/admin-scope tokens are not labelled (they keep their own tier). The host is not checked: the label never lowers a finding (medium, visible). A Supabase-issued token with an admin scope is a Supabase JWT, not a grant.
  • refineJwt order is pinned by tests: a wallet token, a Shopify storefront JWT, a Hygraph token and an expired token in ?token= keep their own classification; service_role and admin scope stay high; the order of returns and the accept(value, content, index) hook from fix(rules): leaked-secrets samples, placeholders, base64 runs, prefix collisions, Paystack labelling #1283 #1227 #1298 are intact.
  • SDK keys: the immediately enclosing call rule (closed nested objects do not hide it, an open nested one does, the 240-character reach, amplitude.init(fn(), {...})), the RevenueCat 28-to-40 character tail with a digit in its first 40, and the data-bugsnag|amplitude|revenuecat-api-key attributes on third-party vs first-party script tags are pinned.
  • An AWS id alone stays medium; the docs and CHANGELOG now state the blind spot (an id in one script and its secret in another ranks below high).
  • Fixed earlier on this PR: the corpus test hang (RevenueCat generator key name, bounded draw(), regenerated snapshot).
    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"]);
@nc9
nc9 force-pushed the fix/1293-1294-secrets-public-clients branch 3 times, most recently from a9d115f to a6cde89 Compare November 1, 2026 12:29
@nc9
nc9 force-pushed the fix/1293-1294-secrets-public-clients branch 2 times, most recently from 66d7dd6 to 8da3e7c Compare November 1, 2026 15:00

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 fix/1293-1294-secrets-public-clients branch 3 times, most recently from a4a8de8 to ec5d810 Compare November 1, 2026 18:47
nc9 added 5 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]>
…sample data tables and puzzle objects are not leaks #1292 #1308

Signed-off-by: Nik Cubrilovic <[email protected]>
… keys; public-looking names and lone AWS ids stay reported with evidence #1293 #1294

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the fix/1293-1294-secrets-public-clients branch from ec5d810 to 7c9ac53 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