-
Notifications
You must be signed in to change notification settings - Fork 30k
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.createDecipher().end" results in an abort #38015
Comments
@EladKeyshawn First of all I'm not the one reporting the issue. Secondly, that's not how Node.js handles exceptions, as you said we usually try to throw an error that can be caught by the user in JavaScript. Here the program simply crashes (core dumped), which is why I labeled it as valid bug report. |
@aduh95 what about the fact its deprecated ? |
I agree users should not be using it, however it's still a bug in the codebase. Maybe a solution would be to remove that deprecated API (it's deprecated since v10.0.0), but I suspect it outlines a bug in the stream implementation which is worth fixing IMHO. |
@aduh95 I'm not sure it's in the stream implementation, since the error and consequently the abort is caused by the ASSERT used in |
I'm able to reproduce on master (macOS x86_64), with both the > node -e 'crypto.createDecipheriv("aes-128-ccm", Buffer.from("1ed2233fa2223ef5d7df08546049406c", "hex"), Buffer.from("7305220bca40d4c90e1791e9", "hex"), {authTagLength:10}).end("str","hex",()=>{})'
out/Release/node[57020]: ../src/string_bytes.cc:437:static Maybe<size_t> node::StringBytes::StorageSize(v8::Isolate *, Local<v8::Value>, enum encoding): Assertion `str->Length() % 2 == 0 && "invalid hex string length"' failed.
1: 0x10d6ae895 node::Abort() […/node/out/Release/node]
2: 0x10d6ae701 node::Assert(node::AssertionInfo const&) […/node/out/Release/node]
3: 0x10d76c94c node::StringBytes::StorageSize(v8::Isolate*, v8::Local<v8::Value>, node::encoding) […/node/out/Release/node]
4: 0x10d7b26ae node::StringBytes::InlineDecoder::Decode(node::Environment*, v8::Local<v8::String>, node::encoding) […/node/out/Release/node]
5: 0x10d7b41bd node::crypto::CipherBase::Update(v8::FunctionCallbackInfo<v8::Value> const&) […/node/out/Release/node]
6: 0x10d893e5a v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) […/node/out/Release/node]
7: 0x10d893438 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) […/node/out/Release/node]
8: 0x10d8929ff v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) […/node/out/Release/node]
9: 0x10e10b9b9 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit […/node/out/Release/node]
[2] 57020 abort out/Release/node -e
> node -e "crypto.createDecipher('aes-128-gcm','').end('str','hex',()=>{})"
out/Release/node[57042]: ../src/string_bytes.cc:437:static Maybe<size_t> node::StringBytes::StorageSize(v8::Isolate *, Local<v8::Value>, enum encoding): Assertion `str->Length() % 2 == 0 && "invalid hex string length"' failed.
1: 0x105773895 node::Abort() […/node/out/Release/node]
2: 0x105773701 node::Assert(node::AssertionInfo const&) […/node/out/Release/node]
3: 0x10583194c node::StringBytes::StorageSize(v8::Isolate*, v8::Local<v8::Value>, node::encoding) […/node/out/Release/node]
4: 0x1058776ae node::StringBytes::InlineDecoder::Decode(node::Environment*, v8::Local<v8::String>, node::encoding) […/node/out/Release/node]
5: 0x1058791bd node::crypto::CipherBase::Update(v8::FunctionCallbackInfo<v8::Value> const&) […/node/out/Release/node]
6: 0x105958e5a v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) […/node/out/Release/node]
7: 0x105958438 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) […/node/out/Release/node]
8: 0x1059579ff v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) […/node/out/Release/node]
9: 0x1061d09b9 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit […/node/out/Release/node]
[2] 57042 abort out/Release/node -e |
it does not reproduce on 14.x |
@EladKeyshawn what do you see when you run the above commands? FWIW I am able to reproduce on v14.16.0 and v15.13.0. |
|
fix Hash and Cipher aborting when using end with hex and specific lengths of chunks fixes: nodejs#38015
fix Hash and Cipher aborting when using end with hex and specific lengths of chunks fixes: nodejs#38015
#50973 removed these functions, resolving this issue. |
What steps will reproduce the bug?
Setup a node instance,
and run the following javascript code.
Then the node instance occurs an abort.
How often does it reproduce? Is there a required condition?
This abort can always be triggered following the steps above.
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?
Additional information
The text was updated successfully, but these errors were encountered: