Skip to content

security/leaked-secrets: items hide value length and location; add meta.length and an offset #1230

Closed

Description

@nc9

Observed on squirrel v0.0.138; maskSecret and the item builder in packages/rules/src/security/leaked-secrets.ts are unchanged on current main.

Problem

A security/leaked-secrets item carries id: "<type>: <masked value>", label: "Found in <location> (<url>)" and optional decoded meta. The mask is the first 6 characters, up to 20 stars, then the last 4 (value.slice(0, 6) + "*".repeat(min(len - 10, 20)) + value.slice(-4)). Consequences when verifying a flag by hand:

  • The star run is capped at 20, so a 40-character and a 400-character value look identical; the length (often the quickest false-positive tell) is hidden.
  • For inline-script and html locations the label names only the page URL. There is no byte offset or line and column, so finding the match in a minified 1 MB page means searching for a 6-character prefix.

Repro: audit a page with an inline <script> containing a long value assigned to apiKey and compare the JSON item for a 32-character and a 200-character value: the ids have the same shape and nothing else tells them apart.

Proposal

Add to each item's meta (so the JSON, LLM and XML renderers carry it): length (characters of the matched value) and offset (zero-based character offset into the scanned body, or line/column), plus scriptUrl or scriptIndex for inline scripts. Keep the value itself masked.

Acceptance Criteria

  • Every security/leaked-secrets item in -f json output has meta.length equal to the matched value length.
  • Every item has an offset (or line and column) that, applied to the fetched body, points at the first character of the match; a test asserts this for an inline script and an external script.
  • Inline-script items identify which script (index or position) the match is in.
  • The masked id is unchanged and no unmasked value appears in any output.

Activity

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

    @WilliamK112
    Contributor

    I can take this. I will keep the masked id unchanged, thread source-location data through the existing leaked-secret match/item path, and add focused inline/external-script tests that prove meta.length, match offset, and inline script identification without exposing the raw value.

  4. nc9 commented on Oct 30, 2026

    @nc9
    ContributorAuthor

    Fixed in v0.0.142 (d1b8b958), via the stacked release PR #1331.

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

    enhancementrulessize: S

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions