Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto.generateKeyPairSync results in an abort in node v14.15.1 #44559

Closed
zyscoder opened this issue Sep 7, 2022 · 3 comments
Closed

crypto.generateKeyPairSync results in an abort in node v14.15.1 #44559

zyscoder opened this issue Sep 7, 2022 · 3 comments
Labels
crypto Issues and PRs related to the crypto subsystem.

Comments

@zyscoder
Copy link

zyscoder commented Sep 7, 2022

Version

v14.15.1, v14.20.0

Platform

Linux zys-lab204l 5.15.0-46-generic #49~20.04.1-Ubuntu SMP Thu Aug 4 19:15:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

crypto

What steps will reproduce the bug?

Setup a node instance,

$ node

and run the following javascript code.

crypto.generateKeyPairSync('dsa', {modulusLength:1024, divisorLength:0})

How often does it reproduce? Is there a required condition?

Always. Require no condition.

What is the expected behavior?

If any error occurs, an exception or other similar error-reporting stuff should be thrown. There is no reason to abort the whole node process.

What do you see instead?

$ node
Welcome to Node.js v14.15.1.
Type ".help" for more information.
> crypto.generateKeyPairSync('dsa', {modulusLength:1024, divisorLength:0})
node[993489]: ../src/node_crypto.cc:6334:void node::crypto::GenerateKeyPairJob::ToResult(v8::Local<v8::Value>*, v8::Local<v8::Value>*, v8::Local<v8::Value>*): Assertion `!errors_.empty()' failed.
 1: 0xa03530 node::Abort() [node]
 2: 0xa035ae  [node]
 3: 0xb3e68e node::crypto::GenerateKeyPairJob::ToResult(v8::Local<v8::Value>*, v8::Local<v8::Value>*, v8::Local<v8::Value>*) [node]
 4: 0xb32aa0 node::crypto::GenerateKeyPair(v8::FunctionCallbackInfo<v8::Value> const&, unsigned int, std::unique_ptr<node::crypto::KeyPairGenerationConfig, std::default_delete<node::crypto::KeyPairGenerationConfig> >) [node]
 5: 0xb33190 node::crypto::GenerateKeyPairDSA(v8::FunctionCallbackInfo<v8::Value> const&) [node]
 6: 0xbe369b  [node]
 7: 0xbe4c46  [node]
 8: 0xbe52c6 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node]
 9: 0x13ff259  [node]
[1]    993489 abort (core dumped)  node

Additional information

No response

@zyscoder zyscoder changed the title crypto.generateKeyPairSync results in a abort in node v14.15.1 crypto.generateKeyPairSync results in an abort in node v14.15.1 Sep 7, 2022
@VoltrexKeyva VoltrexKeyva added the crypto Issues and PRs related to the crypto subsystem. label Sep 7, 2022
@himself65
Copy link
Member

~ node
Welcome to Node.js v14.20.0.
Type ".help" for more information.
> crypto.generateKeyPairSync('dsa', {modulusLength:1024, divisorLength:0})
node[86118]: ../src/node_crypto.cc:6347:void node::crypto::GenerateKeyPairJob::ToResult(Local<v8::Value> *, Local<v8::Value> *, Local<v8::Value> *): Assertion `!errors_.empty()' failed.
 1: 0x101323535 node::Abort() (.cold.1) [/Users/himself65/.nvm/versions/node/v14.20.0/bin/node]
 2: 0x1000b65f9 node::Abort() [/Users/himself65/.nvm/versions/node/v14.20.0/bin/node]
 3: 0x1000b6461 node::Assert(node::AssertionInfo const&) [/Users/himself65/.nvm/versions/node/v14.20.0/bin/node]
 4: 0x1001c1cec node::crypto::GenerateKeyPairJob::ToResult(v8::Local<v8::Value>*, v8::Local<v8::Value>*, v8::Local<v8::Value>*) [/Users/himself65/.nvm/versions/node/v14.20.0/bin/node]
 5: 0x1001c1ad6 node::crypto::GenerateKeyPair(v8::FunctionCallbackInfo<v8::Value> const&, unsigned int, std::__1::unique_ptr<node::crypto::KeyPairGenerationConfig, std::__1::default_delete<node::crypto::KeyPairGenerationConfig> >) [/Users/himself65/.nvm/versions/node/v14.20.0/bin/node]
 6: 0x1001c23eb node::crypto::GenerateKeyPairDSA(v8::FunctionCallbackInfo<v8::Value> const&) [/Users/himself65/.nvm/versions/node/v14.20.0/bin/node]
 7: 0x100272328 v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) [/Users/himself65/.nvm/versions/node/v14.20.0/bin/node]
 8: 0x1002718bc v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/Users/himself65/.nvm/versions/node/v14.20.0/bin/node]
 9: 0x100271022 v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/Users/himself65/.nvm/versions/node/v14.20.0/bin/node]
10: 0x100a8ebb9 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit [/Users/himself65/.nvm/versions/node/v14.20.0/bin/node]
11: 0x100a25622 Builtins_InterpreterEntryTrampoline [/Users/himself65/.nvm/versions/node/v14.20.0/bin/node]
12: 0x100a1f559 Builtins_ArgumentsAdaptorTrampoline [/Users/himself65/.nvm/versions/node/v14.20.0/bin/node]
13: 0x100a25622 Builtins_InterpreterEntryTrampoline [/Users/himself65/.nvm/versions/node/v14.20.0/bin/node]
14: 0x100a25622 Builtins_InterpreterEntryTrampoline [/Users/himself65/.nvm/versions/node/v14.20.0/bin/node]
15: 0x100a2333a Builtins_JSEntryTrampoline [/Users/himself65/.nvm/versions/node/v14.20.0/bin/node]
[1]    86118 abort      node

@bnoordhuis
Copy link
Member

This is an inconsistency in EVP_PKEY_CTX_ctrl(EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS) where it doesn't push an error message onto openssl's error stack when the divisor isn't one of the approved values (160, 224, 256.)

Commit dae283d seems to have fixed that by accident in v15.0.0 and beyond but that can't be back-ported to the v14.x branch.

Can be handled by checking the divisor ourselves before passing it on to openssl. Pull request welcome.

@tniessen tniessen added the v14.x label Sep 15, 2022
@targos
Copy link
Member

targos commented May 3, 2023

Closing as v14.x is EoL.

@targos targos closed this as not planned Won't fix, can't repro, duplicate, stale May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crypto Issues and PRs related to the crypto subsystem.
Projects
None yet
Development

No branches or pull requests

6 participants