Skip to content

fix(rules): leaked-secrets treats an AMD/RequireJS module path as a name #1292 - #1529

Closed
nc9 wants to merge 3 commits into
mainfrom
fix/1292-requirejs-paths
Closed

nc9 wants to merge 3 commits into
mainfrom
fix/1292-requirejs-paths

Conversation

@nc9

@nc9 nc9 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Refs #1292 (the last open class: "a RequireJS path (/js/) ... produces no item"; the issue's amended note says Magento_Customer/js/change-email-password is still to be dropped).

A value that is an AMD / RequireJS module path was reported as a generic secret under a password, secret, token or apiKey key: the older rooted-path rule only reads lower-case segments, so Magento_Customer/js/change-email-password (capitals, no leading slash) fell through. A new narrow rule, isModulePath, drops it:

  • two or more segments joined by /, at most 128 characters, optionally behind a loader-plugin prefix (text!);
  • every segment at most 32 characters and at most three words joined by -, _ or . (camelCase parts and plurals included), each word from a list of module-path words (model, customer, password, template, ...), with at most two digits and three capitals after the first letter; a word outside the list makes the value report (the first version accepted any lower-case run, which let Magento_Customer/<30 random lower-case letters> through);
  • and the path says what it is: a Vendor_Module head (two CamelCase names of lower-case words, no digits) or a js segment.

Fuzz: random values with / still report

isModulePath on random values, 300,000 per shape, seeded: Magento_Customer/<8-40 lower-case> 0; <3 letters>/js/<8-40 lower-case> 0; lower-case 8-40 with one to three slashes 0; URL-safe 24-64 with slashes 0; Magento_Customer/<3-7 lower-case> 68 (227 per million; short tails that are a listed word such as app or api). Before this change (any lower-case run was a segment) the lower-case head-plus-tail shapes passed 20,000 of 20,000 and a lower-case value with an exact js segment 158 per million. The test pins 0 of 100,000 lower-case values and 0 of 2,000 each of the head-plus-tail shapes, and 0 of 20,000 mixed-alphabet values. Reported rate under password: is unchanged by this PR for values it does not drop.

Only paths whose words are all in the module-path word list are suppressed; a path with an unlisted word reports as before. In a review sample of 30 real-looking Magento paths, 19 still reported for that reason. Trade-off: a passphrase made only of listed words in this shape can be suppressed. Measured cost in review: dense module-path input 10 to 40% slower; an 8 MB hostile dense-random-slash input 1.3 s to 3.3 s, RSS unchanged, below the 5 MB page cap in real runs.

The real paths in the test still drop: Magento_Ui/js/form/element/abstract, Magento_Customer/js/change-email-password, text!Magento_Ui/templates/form/element/input, js/lib/secret-keeper, and the other six in the test.

Tests

leaked-secrets-module-path-1292.test.ts: eleven module paths under four key names are not reported; a digit run, a long segment, a run of capitals, one segment, a module head with a drawn tail, and an over-long path are not module paths; the fuzzes above, a word outside the list, a fourth word, plurals, and exact bounds (digits 2/3, capitals 3/5, segment 32, path 128, the js/head rule). Docs list the rule and its bounds.

Skill change: none.

Mutants killed: digit bound (0, 3, 100), capitals bound 3 to 5, js rule removed or always true, words per segment 3 to 4, plural rule, segment and path length bounds.

@nc9 nc9 mentioned this pull request Nov 2, 2026
@nc9

nc9 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Landed in v0.0.159 as b54ae757, ecb3fd38, c5b4248e via #1531 (the commits were re-created by the rebase-merge; matched by their cherry-pick trailers). Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.159

nik

@nc9 nc9 closed this Nov 2, 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

Development

Successfully merging this pull request may close these issues.

1 participant