Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eeae754

Browse filesBrowse files
JonathanLopes404aduh95
authored andcommitted
crypto: reject inherited key type names
Use an own-property check when dispatching generateKeyPair's NID-only algorithm table Fixes: #62874 Signed-off-by: Jonathan Lopes <jonathan15989@protonmail.com> PR-URL: #62875 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent 169b5ea commit eeae754
Copy full SHA for eeae754

2 files changed

+15Lines changed: 15 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/crypto/keygen.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/keygen.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ function parseKeyEncoding(keyType, options = kEmptyObject) {
181181
}
182182

183183
const nidOnlyKeyPairs = {
184+
'__proto__': null,
184185
'ed25519': EVP_PKEY_ED25519,
185186
'ed448': EVP_PKEY_ED448,
186187
'x25519': EVP_PKEY_X25519,
Collapse file

‎test/parallel/test-crypto-keygen.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-crypto-keygen.js
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ const { hasOpenSSL3 } = require('../common/crypto');
5555
code: 'ERR_INVALID_ARG_VALUE',
5656
message: "The argument 'type' must be a supported key type. Received 'rsa2'"
5757
});
58+
59+
for (const type of ['toString', 'constructor']) {
60+
assert.throws(() => generateKeyPairSync(type, {}), {
61+
name: 'TypeError',
62+
code: 'ERR_INVALID_ARG_VALUE',
63+
message: `The argument 'type' must be a supported key type. Received '${type}'`
64+
});
65+
66+
assert.throws(() => generateKeyPair(type, {}, common.mustNotCall()), {
67+
name: 'TypeError',
68+
code: 'ERR_INVALID_ARG_VALUE',
69+
message: `The argument 'type' must be a supported key type. Received '${type}'`
70+
});
71+
}
5872
}
5973

6074
{

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.