Skip to content

security/leaked-secrets: generic assignments flag key-name constants whose value is the name itself #1228

Closed

Description

@nc9

Observed on squirrel v0.0.138; packages/rules/src/security/leaked-secrets.ts is unchanged since on main.

Problem

The generic assignment patterns (Generic Secret Assignment, Generic API Key Assignment, Generic Token Assignment) match on the shape <name containing token/secret/key/password>: "<value>" and accept a value that is plainly a storage key or identifier rather than a credential.

Fixture (external script served as app.js, all names made up):

!function(){var d={GOOGLE_DRIVE_TOKEN:"google-drive-token",DROPBOX_ACCESS_TOKEN:"dropbox-access-token"}}();

Result: Generic Token Assignment: ACCESS********************ken" is reported (DROPBOX_ACCESS_TOKEN:"dropbox-access-token"). Pairs where the value is the kebab-case or snake_case form of the key name (a localStorage / config key constant) are the clearest case. The same rule family showed more of this on real sites in minified bundles: identifiers used as values (Password:t), error-message enums ({apiKey:"LoadCustomers",message:e.message}) and lookup tables ({"tools-secrets":"mcp-tools"}). Those three did not reproduce with the synthetic fixtures I tried on the released binary, so I am not claiming them here; if a maintainer can reproduce them, add them to the fixture set.

Expected

A generic assignment whose value is (a) the key name with a different case or separators, (b) a lowercase kebab/snake phrase of dictionary words with no digit and low entropy, or (c) an identifier or property access rather than a string literal, is not reported.

Acceptance Criteria

  • {DROPBOX_ACCESS_TOKEN:"dropbox-access-token"} and {GOOGLE_DRIVE_TOKEN:"google-drive-token"} produce no item.
  • {apiKey:"LoadCustomers",message:e.message}, {Password:t} and {"tools-secrets":"mcp-tools"} produce no item (fixture tests).
  • {apiKey:"<32 random alphanumerics>"} and {token:"<40 hex>"} are still reported.
    amended 2026-11-02: {apiKey:"<32 random alphanumerics>"} and {access_token:"<40 hex>"} are still reported. A bare token key is not matched by the Generic Token Assignment pattern, which anchors on access_token and auth_token; widening it to a bare token would flag CSRF and pagination tokens.

Activity

  1. added
    bug
    size: S
    rules
    security
    on Oct 28, 2026
  2. added theissue type on Oct 28, 2026
  3. WilliamK112 commented on Oct 28, 2026

    @WilliamK112
    Contributor

    I can take this. I’ll add the requested negative fixtures for key-name constants, identifier/property-access values, and low-entropy label strings, preserve the random alphanumeric and hex positive controls, and keep the change scoped to the generic-assignment detector. I’ll open a focused PR after the rule suite and relevant type/lint checks pass.

  4. nc9 commented on Nov 2, 2026

    @nc9
    ContributorAuthor

    Checked against main (e86767f). Ticked all three criteria; the third is amended (original text stays visible in the body). First release with the fix: v0.0.141 (37fe29f). Probed through the real rule, synthetic inputs: DROPBOX_ACCESS_TOKEN:"dropbox-access-token", GOOGLE_DRIVE_TOKEN:"google-drive-token", {apiKey:"LoadCustomers",message:e.message}, {Password:t} and {"tools-secrets":"mcp-tools"} produce no item; a 32-character alphanumeric apiKey reports Generic API Key Assignment; a 40-hex access_token and accessToken report Generic Token Assignment; a 40-hex bare token key reports nothing, because that pattern anchors on access_token and auth_token, so criterion 3 is amended to access_token. tests/security/leaked-secrets-precision.test.ts passes (23 tests). Closing. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.141

    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

    bugrulessecuritysize: S

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions