CVE-2022-1343
This Vulnerability has been fixed in the Never-Ending Support (NES) version offered by HeroDevs.
Overview
Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. It uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, and it is widely used for web applications and server-side development.
An improper certificate validation vulnerability (CVE-2022-1343) has been identified in the OpenSSL library that Node.js bundles inside its own distribution, where the OCSP_basic_verify function reports a successful verification of an OCSP response even when the response signing certificate itself fails to verify. The incorrect result appears when the caller passes the non-default OCSP_NOCHECKS flag, so an application that verifies certificate revocation this way can accept a revocation answer signed by a certificate it should have rejected.
Per MITRE CWE-295, Improper Certificate Validation: "The product does not validate, or incorrectly validates, a certificate." MITRE adds that an invalid or malicious certificate "might allow an attacker to spoof a trusted entity by interfering in the communication path between the host and client."
This issue affects the Node.js release lines that bundle OpenSSL 3.0.0 through 3.0.2, which is Node.js 17.x up to and including 17.9.0 and Node.js 18.x up to and including 18.1.0. It also concerns HeroDevs Node.js NES 16.x builds below v16.20.3, the release where HeroDevs moved the Node.js NES 16 line's bundled OpenSSL from the 1.1.1 line to the OpenSSL 3.0 code base.
Details
Module Info
- Product: Node.js
- Affected packages: node (the Node.js runtime, through the OpenSSL library bundled in the distribution)
- Affected versions:
- 17.x <=17.9.0
- 18.x <=18.1.0
- Node.js NES 16.x <16.20.3
- GitHub repository: https://github.com/nodejs/node
- Published packages: https://github.com/nodejs/node/releases
- Package manager: Not applicable — Node.js ships as a runtime distribution rather than a registry package.
- Fixed in:
- Upstream in OpenSSL 3.0.3 (May 3, 2022), carried into Node.js 18.2.0 (May 17, 2022) and Node.js 17.9.1 (June 1, 2022)
- Node.js NES v16.20.3 (July 30, 2024)
Vulnerability Info
This Medium-severity vulnerability (CVSS v3.1 score of 5.3, per NVD; OpenSSL's own advisory rates it Moderate) is not in Node.js JavaScript code. It is in the OpenSSL library that ships inside the Node.js distribution, in the OCSP response verification path, so every Node.js build whose bundled OpenSSL is 3.0.0, 3.0.1, or 3.0.2 carries the affected code.
The Online Certificate Status Protocol (OCSP) lets a client ask a responder whether a certificate has been revoked. OpenSSL's OCSP_basic_verify function is the routine that checks such a reply. It verifies the signature on the response and then verifies the certificate that produced that signature, which is how an application tells a genuine responder from an impostor.
In the affected versions the function does not hold that contract when the non-default OCSP_NOCHECKS flag is set. In that case OCSP_basic_verify returns a positive result, meaning a successful verification, even where the response signing certificate fails to verify. The same defect changes the failure path for callers that do not set the flag: instead of the expected return value of 0, the function returns a negative value indicating a fatal error, which a caller that only tests for a negative result may handle differently. The bug also reaches OpenSSL's own command-line tooling: when an OCSP response is verified with the ocsp application and the -no_cert_checks option, the tool reports that verification succeeded even though it in fact failed.
Note: The Node.js project assessed its own runtime as not affected. In its May 2022 OpenSSL assessment, the project states: "Node.js doesn't call OCSP_basic_verify with the custom flag OCSP_NOCHECKS. Node.js is not affected." HeroDevs still lists this CVE against Node.js because the vulnerable OpenSSL code ships compiled into the Node.js binaries regardless of whether Node.js's own API calls trigger it, and NES customers scan their installations for the CVE ID against that bundled OpenSSL library, not against how Node.js core happens to use it.
Note: Upstream Node.js 12.x, 14.x, and 16.x are not affected. Those release lines bundle the OpenSSL 1.1.1 line, and this issue exists only in OpenSSL 3.0.0 through 3.0.2. The Node.js NES 16 line is a separate case from upstream Node.js 16: HeroDevs moved Node.js 16 NES from OpenSSL 1.1.1 to the OpenSSL 3.0 code base so the line would stay viable once OpenSSL 1.1.1 stopped receiving fixes, and the remedy for this CVE is carried in Node.js NES v16.20.3, which ships OpenSSL 3.0.13-quic1.
Mitigation
The Node.js 17.x and 18.x release lines are both past their End-of-Life dates and will not receive any further updates. The upstream fix reached each of those lines before they went End-of-Life, in Node.js 18.2.0 and 17.9.1. For more information on release support see here.
Users of the affected components should apply one of the following mitigations:
- Upgrade to a currently supported Node.js release line, all of which bundle a patched OpenSSL version.
- Migrate affected applications away from the End-of-Life Node.js release lines.
- Leverage a commercial support partner like HeroDevs for post-EOL security support, available here.
Credits
- Raul Metsma (reporter)
- Matt Caswell from OpenSSL (remediation developer)
Note: these credits are for the finders of the underlying OpenSSL issue, per the OpenSSL security advisory; no Node.js-specific finder is recorded because this is a bundled-dependency vulnerability, not a Node.js code defect.