]> git.kaiwu.me - njs.git/commit
Webcrypto: fix buffer overflow when exporting large keys to JWK
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 12 Jun 2026 01:20:01 +0000 (18:20 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Thu, 2 Jul 2026 22:11:19 +0000 (15:11 -0700)
commit6576aa136078488e54337dc7143a696a4cdadef2
tree0e1209676264220095e21d0a01489859868a8813
parentf078f14372ee789ea1435f35672407c13917b5e7
Webcrypto: fix buffer overflow when exporting large keys to JWK

njs_export_base64url_bignum() and qjs_export_base64url_bignum() wrote
BN_num_bytes() bytes into a fixed 512-byte stack buffer without a bound
check.  An RSA key with a modulus larger than 4096 bits (over 512 bytes),
generated or imported via SPKI/PKCS8, overflowed the buffer during
exportKey("jwk").

While here, add exception throwing on a parallel import part in both
engines.

Reported by Vaibhav Rajput.
external/njs_webcrypto_module.c
external/qjs_webcrypto_module.c