Skip to content

leaked-secrets: cap the stored length of a finding's value (a 1 MB password value is kept whole) #1592

Closed

Description

@nc9

Problem

The caps on security/leaked-secrets count findings, not bytes. A generic secret value has no length cap: scanPageForSecrets on an inline const password="<32 chars repeated 32000 times>"; keeps two records with 1,024,011-character values. A crawl of 100 such pages with distinct values stays far below every finding and page ceiling while retaining over 100 MB of value text. Found by an independent review of #1552's worst-case figures, which are now documented as estimates for ordinary-length values.

Acceptance Criteria

  • A finding's stored value is cut to a fixed maximum length (pick one with a measured reason; the match must still be recognisable and redacted the same way), and a cut value is marked as cut so a report reader can tell.
  • A test builds a page with a 1 MB secret-shaped value and asserts the retained record size is bounded by the cap, with an explicit timeout and no process-wide patches.
  • The docs worst-case figures for the collector (docs/rules/security/leaked-secrets.mdx) are re-derived from the cap and stop calling value text unbounded.
  • No true positive is dropped: a value over the cap is still reported (cut and marked), never skipped.
  • CHANGELOG [Unreleased] has a bullet; rule meta text changes are called out so the private rule catalog can be regenerated.

nik

Activity

  1. added
    bug
    size: S
    rules
    security
    performance
    on Nov 4, 2026
  2. added theissue type on Nov 4, 2026
  3. anhnt256 commented on Nov 5, 2026

    @anhnt256
    Contributor

    Hi! I'd like to pick this up. I have a fix ready: a finding's stored value is cut to 2,048 characters at the single construction point in scanInto (surrogate-safe via clampItemString), so page, external-script and decoded-blob scans are all covered. Classification still sees the full value, a cut value is marked with truncated: true in the check item meta, and length keeps the full length. Verified locally: the issue's 1 MB case now stores 2,048 characters, 4 new tests pass, and the full security suite passes (2,943 tests). Opening a PR now.

  4. nc9 commented on Nov 5, 2026

    @nc9
    ContributorAuthor

    sure - thanks! will test locally in a moment

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

    bugperformancerulessecuritysize: S

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions