Skip to content

security/leaked-secrets: generic *Assignment patterns need a value-plausibility gate (form labels, i18n, code expressions = 80% of 557 FPs) #1292

Closed

Description

@nc9

Generic Secret Assignment, Generic API Key Assignment and Generic Token Assignment match on a key name (password, secret, apiKey, token…) and report almost any value next to it. Hand-verifying all 697 unreviewed Generic Secret Assignment flags from a ~38k-site batch (v0.0.141; one GET per source, masked context, nothing used or tested) gave 557 false positives, 66 public-by-design and 63 real. The three biggest false-positive classes have nothing secret-like in the value at all:

pattern flags / sites example shape
value equals the key name or a label 130 / 127 password:"Password", secret:"secret", form field names in react-hook-form or zod schemas
i18n dictionaries 95 / 72 {password:"Contraseña", apiKey:"Clé API"} in translation bundles
code expressions and selectors 63 / 60 "a=ice-pwd:"+e.pwd, input[type=password], env.SECRET||"x"

A single value-plausibility gate removes about 55% of the rule's false positives in this class. The value must:

  • be a quoted string literal, not an expression or concatenation fragment
  • differ from the key name (case-insensitively, ignoring _, - and spaces) and not be a plain dictionary word or identifier
  • contain a digit or symbol, or be 16+ characters
  • not sit inside a selector or attribute-match context ([type=…], :password)

Related: closed #1241 (key-name constants) still fires on v0.0.141 for storage-key values shaped like "*_secret_v6".

Acceptance Criteria

  • Fixtures for each pattern above (form-schema labels, an i18n bundle in 2 languages, an ICE pwd concatenation, a [type=password] selector, an env||"x" fallback) produce no Generic * Assignment item.

  • A storage-key constant like const K="app_secret_v6" produces no item (regression for fix(rules): ignore credential key-name constants #1241).

  • Real assignments still report: SECRET_KEY="<40 hex>", password:"Xk9!…" (12+ mixed), client_secret:"GOCSPX-…" (fixtures).

  • The rule docs describe the plausibility gate.

  • A value that is a CSS-module class (Name_key_hash, -module__), a URL or path (starts with http, // or /), a dotted, colon or snake identifier with no digit run, a RequireJS path (/js/), an env-var reference, or ends in .../… or is bullets/empty produces no item (one fixture per class). A bech32 secret1… or 0x hex address is still reported: a 0x value of 64 hex is also a private-key shape, so these are not dropped (amended 2026-11-01). (amended 2026-11-01: a css-loader class with a ___hash tail is dropped, but a Name_key_hash class such as AuthScreen_password_Yo still reports on purpose, because it reads like a drawn password; a dotted, colon or snake identifier is dropped only when it is all lower case and has a credential word, so mail:saveAccount and __ns:key still report. A RequireJS module path such as Magento_Customer/js/change-email-password is still to be dropped: a fix is in progress.) (amended 2026-11-02: a RequireJS/AMD module path is dropped when every word is on the module-path word list; the issue's own examples are, and paths with unlisted words still report as before. A vocabulary of every Magento module word would also suppress passphrases made of those words, and each added word widens a suppression.)

  • A match whose captured span contains ;, === or an unbalanced (/) is rejected (fixture from minified code).

Activity

  1. added
    bug
    on Oct 29, 2026
  2. added theissue type on Oct 29, 2026
  3. nc9 commented on Oct 30, 2026

    @nc9
    ContributorAuthor

    More value classes from the same hand-verified generic-secret lane (v0.0.141, ~38k sites). Each is cheap to reject on the value alone:

    value class flags / sites example
    CSS-module class names 26 / 22 {form:"AuthScreen_form_x1",password:"AuthScreen_password_Yo"}
    URL or route values 22 / 21 forgotPassword:"https://…/forgot-password", password:"/settings/password/"
    i18n keys and IPC identifiers 26 / 14 password:"auth_reset_password", secret:"mail:saveAccount", "__ns:key"
    crypto chain name used as a key 25 / 5 addresses:{secret:"secret1<38>"} (a bech32 address), 0x… 40-hex addresses
    RequireJS module paths 4 / 3 changeEmailPassword:'Magento_Customer/js/change-email-password'
    match runs across statements 4 / 4 minified this.apiKey…this.baseURL…, apiKey===e.apiKey
    env-var name as value 3 / 3 KEY: import.meta.env.VITE_…, all-caps SOME_API_KEY
    ellipsis, bullets, empty 13 / 11 "Abc...", "••••••••", ""

    Adding criteria.

    • A value that is a CSS-module class (Name_key_hash, -module__), a URL or path (starts with http, // or /), a dotted, colon or snake identifier with no digit run, a RequireJS path (/js/), a bech32 secret1… or 0x 40-hex address, an env-var reference, or ends in .../… or is bullets/empty produces no item (one fixture per class).
    • A match whose captured span contains ;, === or an unbalanced (/) is rejected (fixture from minified code).
  4. nc9 commented on Oct 30, 2026

    @nc9
    ContributorAuthor

    Maintainer decision: a plain word under a password/secret/token-named key (for example changeme) keeps reporting, because a weak default is a real credential at least as often as a placeholder. The plain-word skip in the acceptance criteria is not implemented; the other classes (labels, i18n, code spans, storage keys, CSS-module classes, credential-free URLs, addresses, env references, masks) are.

    nik

  5. nc9 commented on Nov 1, 2026

    @nc9
    ContributorAuthor

    Amended the acceptance criterion on addresses: a bech32 secret1… value and a 0x hex value stay reported, because a 0x value of 64 hex is also a private-key shape and a blockchain address cannot be told from a key by its shape alone. The plausibility gate drops the other listed shapes (CSS-module classes, URLs and paths, dotted, colon and snake identifiers, env-var references, elided or masked values).

    nik

  6. nc9 commented on Nov 1, 2026

    @nc9
    ContributorAuthor

    Amended the identifier criterion to the shipped behaviour. A css-loader class with a ___hash tail is dropped, but a Name_key_hash class (for example AuthScreen_password_Yo) still reports on purpose, because it reads like a drawn password. A dotted, colon or snake identifier is dropped only when it is all lower case and contains a credential word, so a colon identifier with a capital (mail:saveAccount, __ns:key) still reports. The other criteria are ticked as met on v0.0.158. That criterion stays open for one shape: a RequireJS module path that does not start with / (Magento_Customer/js/change-email-password) still reports; a fix is in progress.

    nik

  7. nc9 commented on Nov 2, 2026

    @nc9
    ContributorAuthor

    Checked against v0.0.159 (shipped RequireJS rule: a word list). Met: the plausibility-gate criteria, app_secret_v6, real assignments, the ;/===/unbalanced-paren rule, German Geheimnis, and the amended identifier text (mail:saveAccount, __ns:key and AuthScreen_password_Yo still report on purpose). Open: the value-class criterion for RequireJS paths. The issue's own examples (Magento_Customer/js/change-email-password, changeEmailPassword:'...') no longer report, but the rule drops a path only when every word is on its list: of 15 further real-looking Magento/RequireJS paths under password:, 7 dropped and 8 still report (for example Magento_Checkout/js/action/set-payment-information, Magento_Customer/js/password-strength-indicator, Magento_Braintree/js/view/payment/adapter). Leaving this open: either extend the word list or amend the criterion to the listed module-path words.

    nik

  8. nc9 commented on Nov 2, 2026

    @nc9
    ContributorAuthor

    Amended the value-class criterion to the shipped behaviour, with the original text kept visible. A RequireJS/AMD module path is dropped when every word is on the module-path word list; the issue's own examples (Magento_Customer/js/change-email-password, changeEmailPassword:'...') are, and paths with unlisted words still report as before (of 15 further real-looking Magento/RequireJS paths under password:, 7 dropped and 8 still report). A vocabulary of every Magento module word would also suppress passphrases made of those words, and each added word widens a suppression, so the list is not extended on speculation: a specific path someone reports is a one-line list edit with a justification. All criteria are now met on v0.0.159. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.159

    nik

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions