Skip to content

test: cover webcrypto prototype pollution systematically#63520

Open
panva wants to merge 1 commit into
nodejs:mainfrom
panva:refactor-proto-pollution-test
Open

test: cover webcrypto prototype pollution systematically#63520
panva wants to merge 1 commit into
nodejs:mainfrom
panva:refactor-proto-pollution-test

Conversation

@panva
Copy link
Copy Markdown
Member

@panva panva commented May 23, 2026

Followup to #63363 - drive the regression test from the WebCrypto algorithm registry so all supported algorithms and operations are covered regardless of whether they are native-job backed or js-based.

I extracted this from a WIP that adds js-based Hybrid KEM algorithms to Web Cryptography (based on a discussion with the Chromium team, pending spec merge).

Drive the regression test from the WebCrypto algorithm registry so all
supported algorithms and operations must add explicit coverage
regardless of whether they are native-job backed or js-based.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
@panva panva added test Issues and PRs related to the tests. webcrypto labels May 23, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto

@nodejs-github-bot nodejs-github-bot added crypto Issues and PRs related to the crypto subsystem. needs-ci PRs that need a full CI run. labels May 23, 2026
@panva panva added dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. dont-land-on-v25.x PRs that should not land on the v25.x-staging branch and should not be released in v25.x. labels May 23, 2026
@panva panva requested review from Renegade334 and aduh95 May 23, 2026 17:05
Comment on lines 37 to 52
const constructorDescriptor =
Object.getOwnPropertyDescriptor(Promise.prototype, 'constructor');
const speciesDescriptor =
Object.getOwnPropertyDescriptor(Promise, Symbol.species);
let promise;
Object.defineProperty(Promise.prototype, 'constructor', {
__proto__: null,
configurable: true,
get: common.mustNotCall(
`${name} Promise.prototype.constructor getter`),
});
Object.defineProperty(Promise, Symbol.species, {
__proto__: null,
configurable: true,
get: common.mustNotCall(`${name} Promise[Symbol.species] getter`),
});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this operation is used a lot, might be an idea to cache the descriptors (originals and dummies) for re-use.

Comment on lines 74 to 79
const descriptor = Object.getOwnPropertyDescriptor(prototype, 'then');
Object.defineProperty(prototype, 'then', {
__proto__: null,
configurable: true,
get: common.mustNotCall(`${name} ${prototypeName}.prototype.then`),
});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

@panva panva added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels May 23, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 23, 2026
@nodejs-github-bot

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RSLGTM

@codecov
Copy link
Copy Markdown

codecov Bot commented May 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.12%. Comparing base (dfe2d47) to head (73f0d8d).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63520      +/-   ##
==========================================
- Coverage   90.13%   90.12%   -0.01%     
==========================================
  Files         718      718              
  Lines      228399   228400       +1     
  Branches    42931    42941      +10     
==========================================
- Hits       205860   205841      -19     
- Misses      14283    14314      +31     
+ Partials     8256     8245      -11     
Files with missing lines Coverage Δ
lib/internal/crypto/util.js 96.45% <100.00%> (+<0.01%) ⬆️

... and 35 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. crypto Issues and PRs related to the crypto subsystem. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. dont-land-on-v25.x PRs that should not land on the v25.x-staging branch and should not be released in v25.x. needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. webcrypto

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants