lib: harden kKeyOps lookup with null prototype

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/62877
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This commit is contained in:
Filip Skokan authored and Antoine du Hamel committed 2026-05-05 16:19:36 +02:00
1 parent 8950247027
commit c4ca303b36
2 files changed
+11

No files matched your search

+1
View File
@@ -764,6 +764,7 @@ function getDigestSizeInBytes(name) {
}
const kKeyOps = {
__proto__: null,
sign: 1,
verify: 2,
encrypt: 3,
+10
View File
@@ -9,6 +9,7 @@ const assert = require('assert');
const {
normalizeAlgorithm,
validateKeyOps,
} = require('internal/crypto/util');
{
@@ -49,3 +50,12 @@ const {
assert.strictEqual(normalized.name, 'ECDSA');
assert.strictEqual(nameReadCount, 1);
}
{
for (const ops of [
['sign', 'toString', 'constructor'],
['sign', '__proto__', 'constructor'],
]) {
validateKeyOps(ops);
}
}