Skip to content

feat(rules): leaked-secrets public tier: Shopify platform tokens, beacon JWTs, search-only keys, presigned ids #1287 #1229 - #1300

Closed
nc9 wants to merge 2 commits into
mainfrom
fix/1287-1229-secrets-public-tier
Closed

nc9 wants to merge 2 commits into
mainfrom
fix/1287-1229-secrets-public-tier

Conversation

@nc9

@nc9 nc9 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1287
Fixes #1229

Depends on #1298 (this branch is rebased on it; merge #1298 first, then this PR shows only its own diff).

Extends the public-by-design tier of security/leaked-secrets, on one rule: a finding moves to the informational tier only on positive evidence in the token or right beside it. Public and info findings are absent from the JSON audit output, so a downgrade is effectively a drop for machine consumers; anything the evidence does not cover keeps reporting. Review (review-pub-secrets) found the first version of this PR broke that rule in several places; this is the corrected version.

What changes

  • Shopify wallet JWT (merchantId + merchantOrigin, registered claims and expiresAt only, signed, no role/admin): public.
  • Shopify Shop sessions JWT (client_id + unique_id): public only with a https://shopifyinc.com/sessions URL (parsed, not matched) beside it. The claim names alone no longer qualify.
  • Netlify web vitals JWT: only inside a data-netlify-cwv-token attribute, with iss: netlify, only the web-vitals ids, signed.
  • An apiKey assignment (only that one assignment type) in a Shopify platform bundle: cdn.shopify.com/shopifycloud/, or /cdn/shopifycloud/ on any host when the bundle names Shopify at least three times. Secrets, tokens, AWS keys and provider keys in the bundle still report.
  • api-key / data-api-key on apps.shopify.com (parsed host): not reported.
  • AKIA/ASIA id in a presigned URL: informational only with BOTH X-Amz-Signature and X-Amz-Expires (the first version relaxed this; reverted).
  • Search keys: not downgraded. A key named search_api_key etc. reports at medium as before, with a meta.hint saying the name suggests a search-only key and that an admin key under the same name reads the same. Typesense client config likewise unchanged.
  • Consent-management issuer allowlist: removed. An issuer host does not say whether a token is a beacon or an API credential (a Transcend or Didomi API token has the same registered claims).
  • Unsigned tokens (alg: none / no alg) are never claimed.

Deliberately not done

Verification

No new rule. Skill change: none.

Bypass probes and results

Every row is a test in leaked-secrets-public-tier.test.ts.

Allowlist Probe Result
Search-key name ALGOLIA_SEARCH_API_KEY, searchOwnerKey, search_sudo_api_key, searchIndexingApiKey, azure_search_api_key, search_admin_api_key holding an admin key; Typesense config with an admin key HIGH hole in v1 (name-only downgrade, info/absent from JSON). Fixed: no downgrade; medium + hint (no hint for privileged names)
Dedup {searchApiKey:"K", adminApiKey:"K"} v1 reported only the info record. Now no public record exists for it; reported at medium, never public
Shopify bundle path /cdn/shopifycloud/ on evil.test or any host with no Shopify in the bundle; a bundle with password/secret/client_secret/aws_secret_access_key; ../, %2e%2e, ?/cdn/shopifycloud/, #..., cdn.shopify.com.evil.test, [email protected] v1 skipped ALL generic assignments on any host. Fixed: only apiKey, only evidence-backed hosts/bundles. All others report. Residual: a hostile site that serves /cdn/shopifycloud/x.js containing the word "shopify" three times hides an apiKey assignment in that file only
Consent beacon allowlist alg: none from onetrust.com; API-token-shaped tokens with iss api.transcend.io / api.didomi.io v1 made them public. Fixed: allowlist removed; ordinary JWT, medium
Shop sessions shape A custom app's session token with client_id+unique_id+client_account_id, no Shopify context v1 classified it Shopify. Fixed: needs the sessions URL beside it; lookalike hosts do not count
Beacon claims Wallet/Netlify shapes plus admin:true, is_admin, email, permissions, scope, role; escaped (admin), duplicate (role twice) and __proto__ claims All report as ordinary JWTs (claim allowlist on the parsed payload)
Unsigned token Wallet and Netlify tokens with alg: none or no alg Report
Presigned id Scope tail + signature without X-Amz-Expires; signature alone; scope alone; id in a non-credential parameter; bare id v1 downgraded the first. Fixed: both signature and expiry required; all of these report
Netlify attribute Same claims outside data-netlify-cwv-token, in data-other Report
App Store apps.shopify.com.evil.test, [email protected], data-secret on the listing Report
Provider token on a Shopify store sk_live_ in a /cdn/shop/ theme asset Reports (high)

Control regression

The private real-site corpus run on main vs the #1298 base shows 0 findings removed or added; this PR's rules do not fire on it either way.

Final review round

The /cdn/shopifycloud/ skip now requires a Shopify host by parsed hostname (cdn.shopify.com with /shopifycloud/, or *.myshopify.com with /cdn/shopifycloud/). Mentions of "Shopify" in the file no longer matter; a custom-domain shop's copy is not recognised and reports like any other script. Tests: evil.test, acme.myshopify.com.evil.test, myshopify.com.evil.test, cdn.shopify.com/cdn/shopifycloud/ with the word Shopify repeated ten times all report.

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)

Delta review leftovers

Tests added for the surviving mutants: the Netlify attribute anchoring (spaces around =, case, quotes, a later attribute, a value before the token, a longer attribute name), the /cdn/shopifycloud/ path on *.myshopify.com versus the bare /shopifycloud/ on cdn.shopify.com, and every registered claim including exp on the wallet, session and Netlify tokens (any other claim is not allowed). Mutants for each fail a test.
Skill change: none.

nc9 added 2 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]>
@nc9
nc9 force-pushed the fix/1287-1229-secrets-public-tier branch from 7dc919a to de4eb53 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