Skip to content

fix(rules): leaked-secrets plausibility gate on generic assignments; sample data tables are not leaks #1292 #1308 - #1319

Closed
nc9 wants to merge 4 commits into
mainfrom
fix/1292-1308-secrets-generic-gates
Closed

nc9 wants to merge 4 commits into
mainfrom
fix/1292-1308-secrets-generic-gates

Conversation

@nc9

@nc9 nc9 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1292
Fixes #1308

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

A plausibility gate on the three generic assignment patterns and an exemption for credentials that are sample data. Per the maintainer's decision, a plain word under a credential-named key (password:"changeme") keeps reporting: the pinned corpus negative is unchanged, and #1292 has a comment saying so. The gate only skips values that cannot be credentials by shape.

What changes (#1292)

Not reported under a generic assignment (shape only; a drawn value falls into none): a key repeated as its value or a translated label (already), lower-case words joined by _, : or . (each at most 8 characters, at most two digits: app_secret_v6; a capital, a longer word or - joiners read as drawn, so Prod_token_8fK2mQ9x and hyphenated passphrases are not covered), CSS-module classes (-module__, __x___y), a URL or path with no credential in it (no run of 20+ characters, no 6-character piece with a digit, no query value of 8+, no userinfo; so a long letters-only path secret and https://hooks.zapier.test/hooks/catch/123/abc/ still report), an env reference (process.env.NAME, import.meta.env.NAME, ${NAME}; $ADMIN123 and env.Secret9x! are passwords), a short elided stub (12 or fewer characters then .../…) and masks, and a code span (===/!==, or with a ;: =>, &&, ||, function, return, ;var, a statement after the ;; or unbalanced parentheses around a member access).
Reversed after review: 0x+40 hex, bech32 secret1..., long snake identifiers and Name_key_hash all keep reporting (positive evidence only).

What changes (#1308)

  • A password that is a row of an array of 3+ same-keyed objects whose emails are all on reserved domains (example.com/.org/.net, .test, .example, .invalid, .localhost; NOT .local) is sample data: not reported.
  • The same table with any other email reports as Possible Demo Login (seed data table) at medium with a hint.
  • Puzzle or generator markers need TWO distinct markers in the enclosing object (FLAG{, a string flag/flagPath/flagValue, candidates: [, a crack... key, sample + options, options + length), or one marker inside a table of 3+ same-shaped records. One marker alone never skips.
  • A single config object, two rows, rows with different keys and a table of credentials with no emails are not exempt.

Verification

  • 19 tests in leaked-secrets-sample-data.test.ts, each class paired with a control; the existing corpus negative for changeme is restored to its original wording. Suites pass by path (2436 + 296), tsgo, make validate, detect-secrets hook clean. Codex pass not run (MCP unavailable).
  • Skill change: none.

Probes (bypass and false-negative)

Rule Probe Result
Plain word changeme, Summer2024!, Passw0rd123 under password Report (maintainer decision; the pinned corpus negative is unchanged)
Passphrase Correct-Horse-Battery-Staple-Pony Reports. Whether a lower-case passphrase passes is decided by the existing entropy floor, which this gate does not change (the earlier claim in this PR was wrong)
Joined identifier app_secret_v6, secret:reset:token, auth.token.value Not reported
Joined identifier kqzvmplxwn_rtbhdgcsyj_fmaoeiuqzk under api_key, Prod_token_8fK2mQ9x under secret Hole in v1. Fixed: report
Credential-free URL https://hooks.zapier.test/hooks/catch/<7 digits>/<8 alnum>/, https://user:<pw>@host/x, ?key=<12 letters>, https://hooks.acme.test/services/<32 letters> Hole in v1 (query values under 20, letters-only paths). Fixed: all report
Addresses 0x+40 hex, secret1+38 lowercase under secret Hole in v1 (dropped). Fixed: report
Code span Zx9&&Kw3mQ7, return-of-the-king-2024, a=>bQ9x7Lm2K, `p
Markers {flag:"beta",password:"<real>",host:...}, {secret:"<real>",options:{retries:3,length:10}}, {password:"<real>",candidates:[1,2]}, {flagPath:"/x",password} Hole in v1 (any one marker skipped). Fixed: one marker alone reports
Markers Puzzle (crack* + candidates + flagPath), generator (sample + options/length), one marker in a 3-row table Not reported. Residual: two markers in the same object as a real password hide it
Seed table Reserved-domain table; real-domain table; @corp.local table; mixed domains; two rows; differently shaped rows; [{name,secret}] with no emails Dropped; demo login; demo login (v1 treated .local as reserved: fixed); demo login; generic; generic; generic
Feature flags flags:{beta:true}, flag:true, featureFlags:[...] beside a real password Report
Performance 8000-row table, 300k [, 15k elided values, 40k [{a:1}, prefixes 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: EMAIL_HOST_RE and KEY_IN_ROW_RE are registered with sharedRegex (tests/shared-regex.test.ts was red on the original head). Draft: corpus A/B pending.

Review round (stack rebased on v0.0.157)

  • Performance: the sample-table scan was quadratic on a long run of key or local-part characters. KEY_IN_ROW_RE keys are bounded to 64 characters and email hosts are found from each @ with a one-character look behind and a bounded read ahead (emailHosts). A test with 250 tables of three rows, one holding a 7,000-character run, finishes in under a second (10.4 s with the unbounded key regex).
  • Scope: the email domains that decide whether a table is sample data are those of the rows that carry the secret's own key. A real 40-hex secret row beside an unrelated row with an example.com email now reports; rows with reserved-domain emails stay a sample whatever else the array holds; one real-domain row among the secret's own rows keeps the table reporting.
  • security/leaked-secrets: generic *Assignment patterns need a value-plausibility gate (form labels, i18n, code expressions = 80% of 557 FPs) #1292 AC gaps: German "Geheimnis" is a label (a value with a digit or symbol still reports); a storage key with a version suffix (authentication_secret_v6, up to sixteen-character words then _v and one or two digits) is a name. bech32 and 0x addresses keep reporting by design (a 64-hex 0x value is also a private-key shape); the AC is amended by lane-review-prs.
  • CHANGELOG now says _, : or ., as the code does.
  • The docs(skills): document squirrel self disk and --prune in the squirrelscan skill (1.3) #265 per-host-throttle timing failure on this PR's CI is a load flake unrelated to the change: filed as per-host-throttle sequential-mode test fails under load (expected >= 30 ms) #1521 (Bug, XS, with acceptance criteria), not touched here.
    Skill change: none.

Joined-identifier gate narrowed

The gate dropped almost every random lower-case value joined by _ or : (words of at most eight characters, at most two digits), including Bearer and Basic header values. It now needs at least one word that names a credential (secret, token, key, pass, pwd, auth, cred, api, private, bearer, session, sign, salt, jwt, login, access), and the value of a Bearer or Basic header is never read as a name. The versioned-key rule goes through the same path. The twelve catalogue names stay dropped (tested); 600 random neutral joined values (words without a credential word, _ and :) are dropped by the gate in zero cases (the control is the same words joined by -, which the gate never reads; dotted names are dropped by the older dotted-catalogue rule, not this gate). Mutants (no credential-word requirement, no Bearer/Basic exemption, a one-word list) fail a test. Docs and CHANGELOG match.
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 fix/1292-1308-secrets-generic-gates branch 3 times, most recently from eb6da46 to cad5406 Compare November 1, 2026 18:47
nc9 added 4 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]>
@nc9
nc9 force-pushed the fix/1292-1308-secrets-generic-gates branch from cad5406 to 11a8f92 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