From 252839a8e01bd5e113dd13f0c1153fc955f3903f Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Mon, 21 Nov 2022 23:09:57 +0100 Subject: [PATCH] crypto: ensure "x" is present when importing private CFRG webcrypto keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/45569 Reviewed-By: Antoine du Hamel Reviewed-By: Tobias Nießen Backport-PR-URL: https://github.com/nodejs/node/pull/47336 --- lib/internal/crypto/cfrg.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/internal/crypto/cfrg.js b/lib/internal/crypto/cfrg.js index 98e236052f555e..7b825fc93e0669 100644 --- a/lib/internal/crypto/cfrg.js +++ b/lib/internal/crypto/cfrg.js @@ -276,6 +276,10 @@ async function cfrgImportKey( } } + if (!isPublic && typeof keyData.x !== 'string') { + throw lazyDOMException('Invalid JWK keyData', 'DataError'); + } + verifyAcceptableCfrgKeyUse( name, isPublic ? 'public' : 'private',