[v24.x backport] crypto, WebCrypto, and WebIDL updates#63563
Open
panva wants to merge 27 commits into
Open
Conversation
Collaborator
|
Review requested:
|
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## v24.x-staging #63563 +/- ##
=================================================
- Coverage 89.92% 89.91% -0.01%
=================================================
Files 686 689 +3
Lines 208389 210582 +2193
Branches 40077 40396 +319
=================================================
+ Hits 187387 189340 +1953
- Misses 13238 13422 +184
- Partials 7764 7820 +56
🚀 New features to boost your workflow:
|
ed231b8 to
51e937e
Compare
This comment was marked as outdated.
This comment was marked as outdated.
aduh95
reviewed
May 26, 2026
aduh95
approved these changes
May 26, 2026
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Collaborator
Contributor
|
Should #63584 be included here? |
Member
Author
|
#62645 is there |
PR-URL: nodejs#62389 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: nodejs#62183 Refs: https://wicg.github.io/webcrypto-modern-algos/#kangarootwelve Refs: https://wicg.github.io/webcrypto-modern-algos/#turboshake Refs: https://www.rfc-editor.org/rfc/rfc9861.html Refs: https://github.com/openssl/openssl/issues/30304 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Collaborator
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
PR-URL: nodejs#62389 Backport-PR-URL: nodejs#63563 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
PR-URL: nodejs#62183 Backport-PR-URL: nodejs#63563 Refs: https://wicg.github.io/webcrypto-modern-algos/#kangarootwelve Refs: https://wicg.github.io/webcrypto-modern-algos/#turboshake Refs: https://www.rfc-editor.org/rfc/rfc9861.html Refs: https://github.com/openssl/openssl/issues/30304 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Consolidate all asymmetric key import paths (DER/PEM, JWK, raw) into a single KeyObjectHandle::Init() entry point with a uniform signature. Remove the per-type C++ init methods (InitECRaw, InitEDRaw, InitPqcRaw, InitJwk, InitECPrivateRaw) and their JS-side callers, replacing them with shared C++ and JS helpers. createPublicKey, createPrivateKey, sign, verify, and other operations that accept key material now handle JWK and raw formats directly in C++, removing redundant JS-to-C++ key handle round-trips. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#62499 Backport-PR-URL: nodejs#63563 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#62527 Backport-PR-URL: nodejs#63563 Reviewed-By: James M Snell <jasnell@gmail.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#62527 Backport-PR-URL: nodejs#63563 Reviewed-By: James M Snell <jasnell@gmail.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Refs: https://hackerone.com/reports/3655230 Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#62626 Backport-PR-URL: nodejs#63563 Refs: https://hackerone.com/reports/3655230 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#62706 Backport-PR-URL: nodejs#63563 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#62905 Backport-PR-URL: nodejs#63563 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#62883 Backport-PR-URL: nodejs#63563 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#62924 Backport-PR-URL: nodejs#63563 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Move KeyObject type and handle storage behind NativeKeyObject and expose it to JS through a module-private slot reader, mirroring the CryptoKey hardening. Cache the native slot tuple in a private field and lazily derive secret and asymmetric metadata from the cached KeyObjectHandle. Update internal crypto, QUIC, and comparison callers to use private helpers instead of public KeyObject accessors. Keep getKeyObjectSlots restricted to internal/crypto/keys with an ESLint guard. Add regression coverage for brand checks, hidden slots, clone and transfer behavior, own-property reflection, and post-clone crypto operations. Extend the CryptoKey brand test to assert getSlots is not reachable through the public constructor or prototype chain. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#63111 Backport-PR-URL: nodejs#63563 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Clone CryptoKey algorithm dictionaries into null-prototype objects before storing or caching them internally. Copy nested hash dictionaries and publicExponent bytes so internal consumers and transferred keys do not observe user-mutable input objects or polluted Object.prototype fields. Keep public algorithm and inspect output as ordinary objects. Make the clone path check only own hash and publicExponent properties. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#63111 Backport-PR-URL: nodejs#63563 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Add ESLint rules that reject public KeyObject and CryptoKey accessor reads after internal brand checks. Internal code must use the private key helpers so it reads native-backed slots instead of user-replaceable properties. Add a separate rule that rejects instanceof checks against KeyObject and CryptoKey constructors, including the global CryptoKey constructor. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#63111 Backport-PR-URL: nodejs#63563 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
BoringSSL declares EVP_CIPHER_do_all_sorted and EVP_MD_do_all_sorted, but stock no-decrepit builds do not provide those symbols. Add a Node build flag that keeps ncrypto and its dependents on a local BoringSSL fallback list when libdecrepit is absent. Keep embedders that provide the EVP enumeration symbols on the normal OpenSSL-compatible path, matching Electron's patched BoringSSL build. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#63206 Backport-PR-URL: nodejs#63563 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Add OPENSSL_WITH_* feature macros for crypto capabilities that vary by OpenSSL version and use those instead of repeating version checks. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#63255 Backport-PR-URL: nodejs#63563 Refs: electron/electron#36256 Refs: electron/electron#41720 Refs: electron/electron#51127 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#63255 Backport-PR-URL: nodejs#63563 Refs: electron/electron#36256 Refs: electron/electron#41720 Refs: electron/electron#51127 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#63255 Backport-PR-URL: nodejs#63563 Refs: electron/electron#36256 Refs: electron/electron#41720 Refs: electron/electron#51127 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#63255 Backport-PR-URL: nodejs#63563 Refs: electron/electron#36256 Refs: electron/electron#41720 Refs: electron/electron#51127 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Add a WebCrypto-specific CryptoJob mode that returns a promise from run() and resolves it when native work is finished. Encode job output directly as Web Crypto values, including CryptoKey instances and CryptoKeyPair dictionaries. Convert operation-specific setup failures from AdditionalConfig into OperationError rejections. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#63363 Backport-PR-URL: nodejs#63563 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Remove async function wrappers from SubtleCrypto methods while keeping their public promise-returning behaviour. Route method entry points through a shared helper that converts synchronous validation errors into rejected promises. Let the internal implementations return native job promises directly. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#63363 Backport-PR-URL: nodejs#63563 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Pass CryptoKey handles directly into KDF jobs instead of exporting secret bytes in lib. Normalize HKDF, PBKDF2, and Argon2 around the same job construction pattern so WebCrypto derivation paths avoid extra key material copies and keep operation failures in native job handling. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#63363 Backport-PR-URL: nodejs#63563 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Avoid re-wrapping native WebCrypto promises with PromiseResolve(), since resolving a promise can read its user-mutated constructor. Add a helper for chaining internal WebCrypto job promises without consulting Promise species state, and use it for intermediate job results. Also align JWK wrapping and unwrapping with the spec's fresh-global JSON handling by detaching internal JWK values from user prototypes. Use the internal UTF-8 encoder/decoder bindings instead of shared TextEncoder/TextDecoder prototype methods. Expand the WebCrypto prototype pollution regression test to cover SubtleCrypto methods, export formats, zero-length KDF results, JWK toJSON/kty pollution, and encoder/decoder prototype poisoning. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#63363 Backport-PR-URL: nodejs#63563 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
PR-URL: nodejs#63417 Backport-PR-URL: nodejs#63563 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Rework lib/internal/webidl.js into a documented shared converter module that follows the Web IDL conversion algorithms more closely. Improvements: - Add documented converters and helper factories for primitive values, dictionaries, enums, sequences, interfaces, required arguments, integers, `Uint8Array`, and `BufferSource`. - Move WebCrypto onto the shared converters, while keeping compatibility wrappers for its existing `BufferSource` and `BigInteger` behavior. - Use shared converters from Blob, Performance, Web Locks, and structured clone option handling. - Add benchmarks for `ConvertToInt` and WebCrypto Web IDL converter hot paths. - Add focused tests for core converters, WebCrypto converters, integer conversion, and buffer source behavior. Fixes: - Make the shared `BufferSource` and `Uint8Array` converters reject resizable `ArrayBuffer` and growable `SharedArrayBuffer` backing stores unless explicitly allowed. WebCrypto preserves its legacy resizable backing-store behavior through compatibility wrappers until a semver-major follow-up can opt in to the stricter behavior. - Use Web IDL `ToNumber` and `ToString` behavior for BigInt, Symbol, and object primitive conversion. - Use exact BigInt modulo for 64-bit `ConvertToInt` wrapping and document the final Number approximation behavior. - Normalize mathematical modulo results to `+0` where Web IDL requires it. - Process inherited dictionaries in least-derived to most-derived order, sorting members only within each dictionary level. - Use `IteratorComplete` truthiness for sequence conversion. - Cover detached buffers, resizable-backed views, growable-backed views, cross-realm buffer sources, mutation-after-call behavior, inherited dictionary member order, and sequence iterator completion behavior. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#62979 Backport-PR-URL: nodejs#63563 Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Instead of first discarding the top 24 bits of the argument and then checking that the low 8 bits are within the expected range, first check that the original 32-bit integer is within the expected range and then discard the top 24 bits. PR-URL: nodejs#62763 Backport-PR-URL: nodejs#63563 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Xuguang Mei <meixuguang@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#62645 Backport-PR-URL: nodejs#63563 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com>
sxa
pushed a commit
to sxa/node
that referenced
this pull request
Jun 22, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#63161 Backport-PR-URL: nodejs#63563 Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#63363 should release on v26.x first before this goes in