8 Commits

Author SHA1 Message Date
Antoine du Hamel
5d15cbb416
crypto: fix cross-realm SharedArrayBuffer validation
PR-URL: https://github.com/nodejs/node/pull/57974
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2025-04-24 13:28:51 +00:00
Felipe Forbeck
6bf7fd7f4e
crypto: fix cross-realm check of ArrayBuffer
This patch modifies the `isNonSharedArrayBuffer` function in the WebIDL
implementation for the SubtleCrypto API to properly handle `ArrayBuffer`
instances created in different JavaScript realms.

Before this fix, when a `TypedArray.buffer` from a different realm
(e.g., from a VM context or worker thread) was passed to
`SubtleCrypto.digest()`, it would fail with:

> TypeError: Failed to execute 'digest' on 'SubtleCrypto': 2nd argument
> is not instance of ArrayBuffer, Buffer, TypedArray, or DataView."

The fix use the `isArrayBuffer` function from `internal/util/types` to
detect cross-realm `ArrayBuffer` instances when the prototype chain
check fails.

PR-URL: https://github.com/nodejs/node/pull/57828
Refs: https://github.com/storacha/w3up/issues/1591
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2025-04-22 15:01:21 +02:00
Filip Skokan
d18f4878cf src: refactor SubtleCrypto algorithm and length validations
PR-URL: https://github.com/nodejs/node/pull/57319
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2025-03-08 06:38:17 -08:00
Nathan Baulch
4c045351c1
lib: fix typos
PR-URL: https://github.com/nodejs/node/pull/55065
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2024-09-25 14:35:18 +00:00
Jason Zhang
973144b7c6
lib: convert signals to array before validation
Co-authored-by: Jake Yuesong Li <jake.yuesong@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/54714
Fixes: https://github.com/nodejs/node/issues/54674
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2024-09-06 17:40:21 +00:00
Filip Skokan
9d652f42eb stream: treat compression web stream format per its WebIDL definition
PR-URL: https://github.com/nodejs/node/pull/50631
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2023-11-12 10:01:51 +00:00
Shelley Vohr
136a96722a
crypto: account for disabled SharedArrayBuffer
PR-URL: https://github.com/nodejs/node/pull/50034
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-10-06 09:17:04 +00:00
Filip Skokan
3ef38c4bd7
crypto: use WebIDL converters in WebCryptoAPI
WebCryptoAPI functions' arguments are now coersed and validated as per
their WebIDL definitions like in other Web Crypto API implementations.
This further improves interoperability with other implementations of
Web Crypto API.

PR-URL: https://github.com/nodejs/node/pull/46067
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2023-01-17 08:57:58 +00:00