CVE-2021-4044: Openssl src Invalid Handling Of `X509_verify_cert()` Internal Vulnerability

HIGH
Advisory Identifier: GHSA-mmjf-f5jw-w72q
CVSS 7.5
CWE-835
Published
Advisory Summary

CVE-2021-4044 is a HIGH (CVSS 7.5) invalid handling of `x509_verify_cert()` internal vulnerability (CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')) affecting Openssl src libraries in the crates.io ecosystem. The issue involves invalid handling of `x509_verify_cert()` internal errors in libssl. Remediation is available by upgrading affected packages to version 300.0.4.

CVE-2021-4044 at a Glance

CVE Identifier CVE-2021-4044
GHSA Identifier GHSA-mmjf-f5jw-w72q
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')
Affected Product Openssl src
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2021-4044

To remediate this vulnerability, upgrade all affected Openssl src dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

openssl-src fixed: 300.0.4
Upgrade openssl-src to 300.0.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for openssl-src

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-4044, inspect your project dependencies for Openssl src:

inspect dependencies for openssl-src

Analyze the terminal output to locate any version of Openssl src in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 300.0.4), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & RFC 5280 Specification

Under RFC 5280 specifications for X.509 certificates, the Name Constraints extension defines a namespace within which all subsequent subject names in a certification path must be located. Constraints apply to various name forms including directory names, IP addresses, rfc822Name (email addresses), and uniformResourceIdentifier (URI) entries. Specifically, during certificate path validation, affected versions of Openssl src failed to properly normalize or enforce boundary checks when domain names contained trailing dot (.) characters. Because domain names with a trailing dot signify fully qualified domain names (FQDNs), this omission allowed non-conforming certificates to be improperly validated as compliant with the defined name constraints.

Source Advisory Statement

Internally libssl in OpenSSL calls X509_verify_cert() on the client side to verify a certificate supplied by a server. That function may return a negative return value to indicate an internal error (for example out of memory). Such a negative return value is mishandled by OpenSSL and will cause an IO function (such as SSL_connect() or SSL_do_handshake()) to not indicate success and a subsequent call to SSL_get_error() to return the value SSL_ERROR_WANT_RETRY_VERIFY. This return value is only supposed to be returned by OpenSSL if the application has previously called SSL_CTX_set_cert_verify_callback(). Since most applications do not do this the SSL_ERROR_WANT_RETRY_VERIFY return value from SSL_get_error() will be totally unexpected and applications may not behave correctly as a result. The exact behaviour will depend on the application but it could result in crashes, infinite loops or other similar incorrect responses. This issue is made more serious in combination with a separate bug in OpenSSL 3.0 that will cause X509_verify_cert() to indicate an internal error when processing a certificate chain. This will occur where a certificate does not include the Subject Alternative Name extension but where a Certificate Authority has enforced name constraints. This issue can occur even with valid chains. By combining the two issues an attacker could induce incorrect, application dependent behaviour. Fixed in OpenSSL 3.0.1 (Affected 3.0.0).

CVE-2021-4044 Affected Openssl src Versions

1 component(s)
Fixed Versions:
300.0.4
Product / Package Ecosystem Affected Versions Fixed Version
openssl-src
crates.io
≥ 300.0.0
< 300.0.4
300.0.4

References

Frequently Asked Questions

What is CVE-2021-4044?
CVE-2021-4044 is a security vulnerability in Openssl src involving Invalid handling of `X509_verify_cert()` internal errors in libssl under CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop').
Which Openssl src versions are affected?
Affected versions include releases prior to 300.0.4 across affected packages: openssl-src.
What version fixes CVE-2021-4044?
Upgrading to 300.0.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is openssl-src affected?
Yes, openssl-src is affected in releases prior to 300.0.4. Upgrade your dependency to 300.0.4 or later.
What is the CVSS score of CVE-2021-4044?
CVE-2021-4044 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2021-4044?
CVE-2021-4044 is classified under CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop') (The product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.).
How can I check crates.io dependencies for CVE-2021-4044?
Run the dependency tree command: 'inspect dependencies for openssl-src'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-mmjf-f5jw-w72q",
  "modified" : "2022-09-19T21:58:21Z",
  "published" : "2021-12-15T00:00:42Z",
  "aliases" : [ "CVE-2021-4044" ],
  "summary" : "Invalid handling of `X509_verify_cert()` internal errors in libssl",
  "details" : "Internally libssl in OpenSSL calls X509_verify_cert() on the client side to verify a certificate supplied by a server. That function may return a negative return value to indicate an internal error (for example out of memory). Such a negative return value is mishandled by OpenSSL and will cause an IO function (such as SSL_connect() or SSL_do_handshake()) to not indicate success and a subsequent call to SSL_get_error() to return the value SSL_ERROR_WANT_RETRY_VERIFY. This return value is only supposed to be returned by OpenSSL if the application has previously called SSL_CTX_set_cert_verify_callback(). Since most applications do not do this the SSL_ERROR_WANT_RETRY_VERIFY return value from SSL_get_error() will be totally unexpected and applications may not behave correctly as a result. The exact behaviour will depend on the application but it could result in crashes, infinite loops or other similar incorrect responses. This issue is made more serious in combination with a separate bug in OpenSSL 3.0 that will cause X509_verify_cert() to indicate an internal error when processing a certificate chain. This will occur where a certificate does not include the Subject Alternative Name extension but where a Certificate Authority has enforced name constraints. This issue can occur even with valid chains. By combining the two issues an attacker could induce incorrect, application dependent behaviour. Fixed in OpenSSL 3.0.1 (Affected 3.0.0).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "openssl-src"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "300.0.0"
      }, {
        "fixed" : "300.0.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-4044"
  }, {
    "type" : "WEB",
    "url" : "https://git.openssl.org/gitweb/?p=openssl.git%3Ba=commitdiff%3Bh=758754966791c537ea95241438454aa86f91f256"
  }, {
    "type" : "WEB",
    "url" : "https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff;h=758754966791c537ea95241438454aa86f91f256"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2021-0129.html"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20211229-0003"
  }, {
    "type" : "WEB",
    "url" : "https://www.openssl.org/news/secadv/20211214.txt"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-835" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-06-17T00:01:23Z",
    "nvd_published_at" : "2021-12-14T19:15:00Z"
  }
}