Skip to content

[v24.x backport] crypto, test, and tooling fixes - #66970

Open
panva wants to merge 11 commits into
nodejs:v24.x-stagingfrom
panva:backport-v24-20261024
Open

panva wants to merge 11 commits into
nodejs:v24.x-stagingfrom
panva:backport-v24-20261024

Conversation

panva and others added 11 commits October 24, 2026 00:54
Resolve local actions and reusable workflows from the running
workflow commit with $/ references, independent of checkout paths.

Remove the tarball job's action-only checkout and the WPT action
checkout/copy workaround, which are no longer needed.

Signed-off-by: Filip Skokan <[email protected]>
Assisted-by: Codex
PR-URL: nodejs#66013
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Xuguang Mei <[email protected]>
Reviewed-By: Ulises Gascón <[email protected]>
Refresh conditional algorithm registration on FIPS changes and use the
current state for parameter restrictions.

Use per-algorithm availability checks in normalization and native named
key generation. Remove getPqcKeyTypes().

Enable supports() tests under FIPS and cover state transitions in warmed
workers.

Signed-off-by: Filip Skokan <[email protected]>
Assisted-by: Codex
PR-URL: nodejs#66160
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Read buffer lengths and element sizes from internal slots in
randomFillSync() and randomFill(). Shadowed properties can otherwise
skip filling, change the selected range, or fail a native bounds check.

Use the intrinsic byte length for the getRandomValues() quota check and
keep its delegation to randomFillSync().

Signed-off-by: Filip Skokan <[email protected]>
Assisted-by: Codex
PR-URL: nodejs#66237
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Aviv Keller <[email protected]>
Skip redundant PBKDF2 WPT variants during regular CI. Keep the full
matrix when producing a WPT report. Retain the RSA WPT variants because
v24 cannot skip whole variants without hanging empty test runs.

Use fewer scrypt, PBKDF2, and Argon2 derivations in parallel tests.
Reuse RSA key material across OAEP hash and PSS salt tests.

Signed-off-by: Filip Skokan <[email protected]>
Assisted-by: Codex
PR-URL: nodejs#66244
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Xuguang Mei <[email protected]>
Convert algorithm dictionaries on the original receiver, with name
read once. Validate normalized parameters in their operation steps
after the method-level key checks and generation usage checks.

This also makes Argon2 validation use converted parallelism and keeps
later dictionary conversion errors ahead of semantic parameter errors.

Signed-off-by: Filip Skokan <[email protected]>
Assisted-by: Codex
PR-URL: nodejs#66237
Backport-PR-URL: nodejs#66391
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Xuguang Mei <[email protected]>
Require cSHAKE and KMAC output lengths and KMAC key lengths to be
multiples of 8 bits. KMAC keys must be at least 32 bits. Share these
restrictions between operations and supports.

Use OpenSSL's KMAC provider for all supported inputs and its cSHAKE
implementation for non-empty function names or customization strings.
Keep using SHAKE when both cSHAKE parameters are empty. Remove the
custom Keccak framing, partial-bit handling, and short-key fallback.

Document the OpenSSL 4.0 requirement for non-empty cSHAKE parameters and
reject customization strings containing null bytes. Keep the documented
512-byte customization limit and let backend failures reach callers.

Signed-off-by: Filip Skokan <[email protected]>
Assisted-by: Codex
PR-URL: nodejs#66237
Backport-PR-URL: nodejs#66391
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Xuguang Mei <[email protected]>
Instead of creating a RandomBytesJob object, it calls CSPRNG()
directly now.

Assisted-by: Claude Code
Signed-off-by: Mert Can Altin <[email protected]>
PR-URL: nodejs#66348
Reviewed-By: Filip Skokan <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Signed-off-by: Filip Skokan <[email protected]>
The typed array Blob constructor tests expect little-endian byte order.
Mark them as expected failures only on big-endian platforms, so failures
on little-endian platforms remain visible.

Signed-off-by: Filip Skokan <[email protected]>
Assisted-by: Claude, Codex
PR-URL: nodejs#66322
Reviewed-By: Daeyeon Jeong <[email protected]>
Honor allow_uncaught_exception for unhandled promise rejections in the
WPT worker path. Apply setup settings before nested callbacks, preserve
settings after results start, and apply promise_setup settings when its
callback runs. Keep rejection failures in single_test mode.

Cover the worker runner and remove the flaky expectation for the Web
Locks test that deliberately rejects.

Refs: nodejs#59142
Signed-off-by: Filip Skokan <[email protected]>
Assisted-by: Claude, Codex
PR-URL: nodejs#66322
Reviewed-By: Daeyeon Jeong <[email protected]>
ncrypto::KEM creates a new EVP_PKEY_CTX per operation. Parameters,
entropy, scratch buffers, and outputs are private to each call. ML-KEM
expansion finishes during import, and operations read an immutable key.
EC and X25519 retain read-only recipient keys. RSA synchronizes mutable
caches internally.

Remove the outer locks serializing jobs that share a KeyObject or
CryptoKey. Cover cold keys and worker clones across RSA, EC, X25519, and
ML-KEM, checking every resulting shared secret.

Refs: https://docs.openssl.org/3.5/man7/openssl-threads/
Signed-off-by: Filip Skokan <[email protected]>
Assisted-by: Codex
PR-URL: nodejs#66413
Reviewed-By: James M Snell <[email protected]>
Raw and JWK getters return independently owned bytes or BIGNUMs. RSA
metadata snapshots public parameters and PSS restrictions. EC fallback
paths reconstruct or duplicate the source key. EC PKCS8 export changes
encoding flags only on its own clone.

Early OpenSSL 3 key downgrading mutated shared provider fields. Current
OpenSSL publishes separate legacy and provider conversion caches under
internal read/write locks. Ordinary DER/PEM export, equality, signing,
and key derivation already access the same keys without these locks.

Remove export and metadata acquisitions, including their coverage of V8
allocation and encoding, and remove the now-unused shared mutex storage.
Retain shared immutable key ownership. The concurrent reuse test checks
that EC PKCS8 export leaves the original flags intact.

Refs: nodejs#36825
Refs: https://docs.openssl.org/3.5/man7/openssl-threads/
Signed-off-by: Filip Skokan <[email protected]>
Assisted-by: Codex
PR-URL: nodejs#66413
Reviewed-By: James M Snell <[email protected]>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/actions
  • @nodejs/crypto
  • @nodejs/gyp
  • @nodejs/security-wg

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. v24.x Issues that can be reproduced on v24.x or PRs targeting the v24.x-staging branch. labels Oct 23, 2026
@panva
panva requested a review from aduh95 October 23, 2026 22:56
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@codecov

codecov Bot commented Oct 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.22652% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.42%. Comparing base (9e39360) to head (14bd819).
⚠️ Report is 842 commits behind head on v24.x-staging.

Files with missing lines Patch % Lines
src/crypto/crypto_random.cc 37.03% 9 Missing and 8 partials ⚠️
lib/internal/crypto/webidl.js 91.25% 6 Missing and 1 partial ⚠️
lib/internal/crypto/util.js 94.44% 6 Missing ⚠️
lib/internal/crypto/hash.js 50.00% 4 Missing ⚠️
src/crypto/crypto_keys.cc 84.21% 0 Missing and 3 partials ⚠️
src/crypto/crypto_kmac.cc 71.42% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@                Coverage Diff                @@
##           v24.x-staging   #66970      +/-   ##
=================================================
+ Coverage          90.31%   90.42%   +0.11%     
=================================================
  Files                711      717       +6     
  Lines             228425   240577   +12152     
  Branches           43160    45894    +2734     
=================================================
+ Hits              206293   217535   +11242     
- Misses             14090    14509     +419     
- Partials            8042     8533     +491     
Files with missing lines Coverage Δ
lib/internal/crypto/aes.js 94.59% <100.00%> (+0.86%) ⬆️
lib/internal/crypto/argon2.js 98.71% <100.00%> (+0.01%) ⬆️
lib/internal/crypto/cfrg.js 95.45% <100.00%> (-0.59%) ⬇️
lib/internal/crypto/chacha20_poly1305.js 98.26% <100.00%> (+0.03%) ⬆️
lib/internal/crypto/diffiehellman.js 97.69% <100.00%> (-0.01%) ⬇️
lib/internal/crypto/ec.js 96.94% <100.00%> (+0.05%) ⬆️
lib/internal/crypto/hkdf.js 100.00% <100.00%> (ø)
lib/internal/crypto/keygen.js 98.23% <100.00%> (-0.21%) ⬇️
lib/internal/crypto/mac.js 99.03% <100.00%> (+0.03%) ⬆️
lib/internal/crypto/ml_dsa.js 97.07% <100.00%> (-0.45%) ⬇️
... and 18 more

... and 267 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

Copy link
Copy Markdown
Collaborator

@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

lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. v24.x Issues that can be reproduced on v24.x or PRs targeting the v24.x-staging branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants