Skip to content

security/leaked-secrets: real-world precision is near zero on high and medium tiers (776-site sample) #357

Closed

Description

@nc9

Pulled the latest cloud report for each of 776 audited sites (last 120 days) and aggregated the security/leaked-secrets checks. Counts are sites, not findings unless stated.

tier sites top patterns (findings / sites)
high (fail) 6 Telegram Bot Token 50/1, Resend 2/2, Bitbucket 1/1, Neon 1/1, Google AIza reported as "Firebase" by an old build 1/1
medium (warn) 185 Sanity Token 346/74, LinkedIn Client Secret 187/44, Generic Secret Assignment 116/40, Cloudflare API Token 85/27, Segment 39/5, Generic Token Assignment 29/16, Heroku 15/4, Generic API Key 15/13, Bearer 9/5
public (info) 118 Google browser key 75/68, PayPal Client ID 66/15, Supabase anon 29/17, Stripe pk_live 19/19

Verified against the live pages, every high-tier hit is a false positive:

  • Telegram [0-9]{8,10}:[\w-]{35} matched the tail of a Webflow interaction id: …a0d694967460:785cabcc-e500-e2f4-e9f0-06a5104d3f11. No boundary before the digits.
  • Resend re_[a-zA-Z0-9]{32,} matched inside an image filename …_Care_DryCrackedSkinReliefHydratingBalm_ATF…. No boundary before re_.
  • Google AIza is a Maps browser key (public tier in current code, reported as high by an older build).

The medium tier is dominated by context patterns keyed on ordinary words: sanity is not even a keyword (the pattern is a bare sk[a-zA-Z0-9]{30,}, which matches minified identifiers and base64), and linkedin, cloudflare, together, segment, heroku, mistral, datadog appear in prose or script URLs on most sites, after which any 16/32/40/64-char hash or UUID nearby is reported. Cloudflare API Token fires on SRI sha512- hashes and challenge nonces on every Cloudflare-fronted site. PayPal Client ID ([Aa][Zz]…{60,}) fires on Italian and Indonesian slugs starting with az.

Net: with 776 real sites the scanner produced zero confirmed leaks and roughly 1,100 false findings. A 100-site write-up on the current detector would be all noise.

What the reference tools do differently (trufflehog, gitleaks):

  • every prefix pattern is bounded (\b or a preceding-char class), and keyword prefilters use provider-unique tokens (AKIA, sk_live, hooks.slack.com), never English words;
  • generic patterns carry an entropy floor (gitleaks: 3.5 for generic-api-key) and a stopword/placeholder allowlist;
  • an unverified generic hit is reported at a lower tier than a provider-specific one, and multi-detector overlap on one value suppresses it.

Acceptance Criteria

  • Every prefix-anchored pattern rejects a match whose preceding character is [A-Za-z0-9_] (Telegram inside a UUID pair and Resend inside _Care_Dry… no longer fire)
  • Context patterns keyed on linkedin, cloudflare, together, segment, heroku, mistral, datadog, sanity no longer report a value that is an SRI hash, UUID, hex digest, or a substring of a URL
  • Sanity Token requires the Sanity-specific shape or a sanity keyword within the context window
  • PayPal Client ID no longer matches words inside URL slugs (requires a value position, not prose or path)
  • Generic assignment patterns skip values containing spaces or fewer than 3.5 bits/char Shannon entropy
  • Re-running the 776-site corpus (private) reports fewer than 10 medium-tier sites and every remaining high-tier hit is a real credential shape
  • The leaked-secrets unit corpus (test/leaked-secrets-harness) passes with the knownGap negatives promoted to hard negatives

Activity

  1. added
    bug
    on Sep 16, 2026
  2. nc9 commented on Sep 16, 2026

    @nc9
    ContributorAuthor

    Corpus harness is up in #358 (1015 pass / 45 todo, bench baseline 14.2 ms/MB, peak RSS 383 MB on a 66.7 MB synthetic corpus). Building it surfaced 14 more defects beyond the six above, all encoded as knownGap cases:

    1. Twitter Bearer Token can never fire: the /a{16,}/i false-positive filter drops the 19 leading As.
    2. FALSE_POSITIVE_PATTERNS are unanchored substring tests: any real token containing xxx, fake, sample or dummy anywhere is dropped.
    3. Sanity sk…{30,} also fires inside base64 data URIs and CSS class soup.
    4. Authorization: Bearer <dotted> yields a duplicate medium "Bearer Token" beside the JWT/Discord finding; a Supabase anon JWT in a Bearer header gets a false medium warning.
    5. Bearer values under 20 chars are reported by neither tier.
    6. PayPal runs before Azure Storage Key and claims a substring of the AccountKey, downgrading a high to public info.
    7. DO Spaces DO[A-Z0-9]{20,} runs before New Relic and claims the tail of any NRAL key containing DO.
    8. Two brand keywords in one window: Cohere (40 alnum, first context pattern) claims a prefix of a Together 64-hex key.
      9-11. looksLikeCodeIdentifier drops about 30% of random keyed values: lowercase-then-uppercase opening, on/is/get prefixes, _ with lowercase (real Cloudflare tokens contain _).
    9. "Supabase Anon Key" is just the generic HS256 JWT header, so any first-party session JWT reports as Supabase anon and a service_role JWT reports as public (the role claim is never decoded). The sbp_ shape labelled "Service Role Key" is a personal access token.
    10. No pk_test_ pattern; under apiKey: the generic assignment warns on a public Stripe test key.
    11. Railway tokens are plain UUIDs; railway_… matches a shape Railway does not issue.

    Suggested order: 2, 1 and 12 are one-liners with large effect; 6 and 7 are pattern reordering; 3 needs a value-position gate or removal of the bare pattern.

  3. nc9 commented on Sep 16, 2026

    @nc9
    ContributorAuthor

    Refinement from encoding the real-world negatives in #358 (33 known gaps now, 1038 pass / 64 todo): the "ordinary word" context family is narrower than stated above. With the keyword only in prose and a hash in an unrelated attribute, together/segment/mistral/datadog are already silent: the key-context gate holds. They fire when the page also has a minified member assignment (w.s="<16 hex>" from the Shopify wpm bootstrap, e.k="<40>" from the Cloudflare challenge bootstrap) or a keyword-named attribute (data-heroku-dyno). SRI integrity and data-cfemail are correctly suppressed. So the fix is in classifyKeyName / the single-letter minified key acceptance, not in the keyword list. The boundary family (Telegram in a UUID pair, Resend and Neon in filenames and slugs, fooghp_/xsk_live_/abcAKIA mid-token) all fire HIGH today and is the first fix. Shopify storefront tokens and web-pixel Api-Key are tagged as a scoping question rather than a must-not-fire.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions