Skip to content
Crypto Disclosed report Advanced CVE-2023-23919

Multiple OpenSSL error handling issues in nodejs crypto library

Node.js up to version 19.2.0 did not clear the OpenSSL error stack after cryptographic operations that could set it, so a stale error could be reported against a later, unrelated operation on the same thread. In the reporter's application, a failed certificate verification caused JWT signing to fail afterwards.

mjones-vsat Follow

Originally disclosed on HackerOne

Medium 4.3 View original
  • Triaged in 3 days
  • Fixed in 2 months
  • Disclosed after 2 months

Summary: NodeJS up to 19.2.0 does not clear the OpenSSL error stack after operations that may set it

Description: NodeJS up to 19.2.0 does not clear the OpenSSL error stack after operations that may set it. This may lead to false positive errors during subsequent cryptographic operations that happen to be on the same thread.

Steps To Reproduce:

The following issues have reproduction cases:

https://github.com/nodejs/node/pull/45495 https://github.com/nodejs/node/pull/45377

Upon reviewing the code in crypto_x509.cc, at least one other function lacks use of ClearErrorOnReturn - X509Certificate::CheckPrivateKey.

https://github.com/nodejs/node/blob/main/src/crypto/crypto_x509.cc#L432

Impact:

On our application, JWTs failed to sign after a certificate fails to verify on the same thread.

Impact

If the server verifies certificates using Node's X509Certificate API, it may fail to sign other users' auth tokens: if a certificate fails to verify, the error from the previous failing call is applied to the next call that should succeed. It is worth auditing all OpenSSL entry points to see if they can cause errors to be raised.

The original report as published on HackerOne, by mjones-vsat. 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, several OpenSSL entry points in Node.js's crypto bindings did not call the error-clearing helper after operations that can raise errors, leaving stale errors on the thread-local stack.

Impact

If a server verifies certificates through Node's X509Certificate API, a failed verification could make a later signing call on the same thread fail, potentially breaking auth token issuance for other users.

What the attacker needed

Server uses Node.js crypto/X509 API; a crypto call fails on a thread; later call runs on same thread

The fix

The affected functions should clear the OpenSSL error stack after each operation, and the reporter suggests auditing all OpenSSL entry points for the same gap.

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.

OpenSSL is the library Node.js uses for encryption tasks like signing tokens or checking certificates. It keeps a list of recent errors, and Node.js was not emptying that list after some calls. So when one call failed, the leftover error could be wrongly blamed on the next call, even though that call was fine.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More from Node.js

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.