Skip to content
DoS Disclosed report Intermediate CVE-2023-30588

node.js process aborts when processing x509 certs with invalid public key information

Node.js's CreateAsymmetric function assumes a valid public key in X.509 certificates, but a malformed certificate can trigger an assertion failure and abort the process. An attacker could cause a denial of service by supplying such a certificate to an application that reads its public key.

m_r_beauchamp Follow

Originally disclosed on HackerOne

Medium 5.3 View original
  • Triaged in 6 hours
  • Fixed in 4 months
  • Disclosed after 5 months

Summary: The code for the CreateAsymmetric method in src/crypto/crypto_keys.cc: assumes that the certificate includes a valid public key. However, malicious actors could construct x509 certificates that can break this assumption.

Description:

When we run the attached reproducer, the node process aborts with the following message:

/usr/local/bin/node loadcert_poc.js v18.14.2 valid:Feb 21 23:59:59 2015 GMT /usr/local/bin/node[392068]: ../src/crypto/crypto_keys.cc:869:static std::shared_ptrnode::crypto::KeyObjectData node::crypto::KeyObjectData::CreateAsymmetric(node::crypto::KeyType, const node::crypto::ManagedEVPPKey&): Assertion `pkey' failed. 1: 0xb7b3f0 node::Abort() [/usr/local/bin/node] 2: 0xb7b46e [/usr/local/bin/node] 3: 0xd11002 node::crypto::KeyObjectData::CreateAsymmetric(node::crypto::KeyType, node::crypto::ManagedEVPPKey const&) [/usr/local/bin/node] 4: 0xd29626 node::crypto::X509Certificate::PublicKey(v8::FunctionCallbackInfov8::Value const&) [/usr/local/bin/node] 5: 0xdc12a0 [/usr/local/bin/node] 6: 0xdc27df v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node] 7: 0x1700679 [/usr/local/bin/node] Aborted

Same outcome with 19.7.0

The CHECK(pkey) in method CreateAsymmetric [1] could be made more aware of the invalid state of the provided x509 certificate to gracefully handle the situation.

std::shared_ptr<KeyObjectData> KeyObjectData::CreateAsymmetric( KeyType key_type, const ManagedEVPPKey& pkey) { ===> CHECK(pkey); return std::shared_ptr<KeyObjectData>(new KeyObjectData(key_type, pkey)); }

Steps To Reproduce:

/usr/local/bin/node loadcert_poc.js v19.7.0 [1] valid:Feb 21 23:59:59 2015 GMT /usr/local/bin/node[4119272]: ../src/crypto/crypto_keys.cc:869:static std::shared_ptrnode::crypto::KeyObjectData node::crypto::KeyObjectData::CreateAsymmetric(node::crypto::KeyType, const node::crypto::ManagedEVPPKey&): Assertion `pkey' failed. [..] Aborted

Impact:

There are various use cases where an application may want to access the public key info of a client-provided certificate. Developer may assume that the crypto code is safe to feed with arbitrary x509 material.

Supporting Material/References:

[1] https://github.com/nodejs/node/blob/5fad0b93667ffc6e4def52996b9529ac99b26319/src/crypto/crypto_keys.cc#L881

Impact

The attacker could force interruptions of application processing, as the process terminates when accessing public key info of provided certificates from user code. The current context of the users will be gone, and that will cause a DoS scenario, downtime, reputation and potential revenue loss.

The original report as published on HackerOne, by m_r_beauchamp. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the code uses an assertion (CHECK) that aborts the process when the public key is missing, instead of returning an error or handling the invalid certificate gracefully.

Impact

The attacker could force interruptions of application processing, as the process terminates when accessing public key info of provided certificates from user code.

What the attacker needed

Application reads public key from user-supplied certificate

How it was found

  1. Run the provided reproducer script with Node.js.
  2. The script loads a certificate and accesses its public key.
  3. The process aborts with an assertion failure.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When a program reads a certificate, it expects the certificate to contain a public key. If the certificate is malformed and lacks a valid key, the program crashes instead of handling the error. An attacker can send such a bad certificate to make the program stop working.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More from Node.js

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.