Skip to content

fix(js-x-ray): match quoted property keys in findPropertyMatch - #703

Merged
fraxken merged 2 commits into
NodeSecure:masterfrom
HoyeongJeon:fix/find-property-match-quoted-key
Sep 1, 2026
Merged

fix(js-x-ray): match quoted property keys in findPropertyMatch#703
fraxken merged 2 commits into
NodeSecure:masterfrom
HoyeongJeon:fix/find-property-match-quoted-key

Conversation

@HoyeongJeon

Copy link
Copy Markdown
Contributor

findPropertyMatch requires !prop.computed && isIdentifier(prop.key), so a property key written as a string literal is skipped even though its name is statically known.

crypto.scrypt(password, salt, 64, {  cost : 1024 }, cb)   // reported
crypto.scrypt(password, salt, 64, { "cost": 1024 }, cb)   // not reported

Both build the same object at runtime, and cost: 1024 is well below the lowest OWASP row, so the second one was a miss.

The key name is now resolved through a small getPropertyName helper:

key resolved
{ cost: 1 } "cost"
{ "cost": 1 } "cost"
{ ["cost"]: 1 } "cost"
{ [cost]: 1 } null

The last row stays excluded. The real key is the value of cost at runtime, so it is not statically known. The existing test covering it still passes.

isWeakScrypt is the only probe using the helper today, so it is the only behaviour change. Added a regression test there, plus three cases on the helper itself.

Split out of #699 as suggested on Discord, so it can land independently.

@HoyeongJeon
HoyeongJeon requested a review from a team as a code owner September 1, 2026 16:01
@changeset-bot

changeset-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

馃 Changeset detected

Latest commit: 8292236

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@nodesecure/js-x-ray Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@fraxken
fraxken requested a review from clemgbld September 1, 2026 16:56
@fraxken
fraxken merged commit eceb98a into NodeSecure:master Sep 1, 2026
5 checks passed
@HoyeongJeon
HoyeongJeon deleted the fix/find-property-match-quoted-key branch September 12, 2026 08:37
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.

3 participants