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 GitHub committed 2026-04-23 18:19:31 +00:00
1 parent 800f5828dc
commit 1f6f3ac871
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);
}
}