Skip to content

Commit d9825c7

Browse files
tniessentargos
authored andcommitted
crypto: prevent Sign::SignFinal from crashing
The validation logic could be tricked into assuming an option was valid using malicious getters, leading to an invalid value being passed to the C++ layer, thus crashing the process. PR-URL: #21815 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Ujjwal Sharma <[email protected]>
1 parent 576f1ea commit d9825c7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/internal/crypto/sig.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ function getSaltLength(options) {
5757

5858
function getIntOption(name, defaultValue, options) {
5959
if (options.hasOwnProperty(name)) {
60-
if (options[name] === options[name] >> 0) {
61-
return options[name];
60+
const value = options[name];
61+
if (value === value >> 0) {
62+
return value;
6263
} else {
63-
throw new ERR_INVALID_OPT_VALUE(name, options[name]);
64+
throw new ERR_INVALID_OPT_VALUE(name, value);
6465
}
6566
}
6667
return defaultValue;

0 commit comments

Comments
 (0)