Patchfirst
CVE-2022-0778 Public exploit High · 7.5 EPSS 73.2%

Infinite loop in BN_mod_sqrt() reachable when parsing certificates

OpenSSL · OpenSSL

Summary

A flaw in OpenSSL's BN_mod_sqrt() function, which computes modular square roots for non-prime moduli, causes it to loop forever when it is reached while parsing certificates with compressed-form elliptic curve public keys or explicit curve parameters, and also when parsing crafted private keys. An attacker who can supply a crafted certificate or key to any process that parses it, such as a TLS endpoint or certificate authority, can trigger the hang over the network with no authentication or user interaction, since parsing occurs before signature verification.

Official description · CVE.org

The BN_mod_sqrt() function, which computes a modular square root, contains a bug that can cause it to loop forever for non-prime moduli. Internally this function is used when parsing certificates that contain elliptic curve public keys in compressed form or explicit elliptic curve parameters with a base point encoded in compressed form. It is possible to trigger the infinite loop by crafting a certificate that has invalid explicit curve parameters. Since certificate parsing happens prior to verification of the certificate signature, any process that parses an externally supplied certificate may thus be subject to a denial of service attack. The infinite loop can also be reached when parsing crafted private keys as they can contain explicit elliptic curve parameters. Thus vulnerable situations include: - TLS clients consuming server certificates - TLS servers consuming client certificates - Hosting providers taking certificates or private keys from customers - Certificate authorities parsing certification requests from subscribers - Anything else which parses ASN.1 elliptic curve parameters Also any other applications that use the BN_mod_sqrt() where the attacker can control the parameter values are vulnerable to this DoS issue. In the OpenSSL 1.0.2 version the public key is not parsed during initial parsing of the certificate which makes it slightly harder to trigger the infinite loop. However any operation which requires the public key from the certificate will trigger the infinite loop. In particular the attacker can use a self-signed certificate to trigger the loop during verification of the certificate signature. This issue affects OpenSSL versions 1.0.2, 1.1.1 and 3.0. It was addressed in the releases of 1.1.1n and 3.0.2 on the 15th March 2022. Fixed in OpenSSL 3.0.2 (Affected 3.0.0,3.0.1). Fixed in OpenSSL 1.1.1n (Affected 1.1.1-1.1.1m). Fixed in OpenSSL 1.0.2zd (Affected 1.0.2-1.0.2zc).

Breakdown
33.1 / 100
Exploited
Not confirmed
Reports
0
Tactics
0/15

Public exploit code (PoC-in-GitHub) was available the same day.

  1. DisclosedPublic exploit codePoC-in-GitHubday 0

8 fixes in openssl-src over 10 months. The latest fix listed for openssl-src is 300.0.9.

Fixes in openssl-srcCargo package, by fixed version. Earlier and later fixes in the same package, not necessarily the same bug.

  1. 111.16.0CVE-2021-371124 Aug 2021
  2. 111.16.0CVE-2021-371224 Aug 2021
  3. 300.0.4CVE-2021-404414 Dec 2021
  4. 300.0.5CVE-2022-077815 Mar 2022
  5. 300.0.6CVE-2022-13433 May 2022
  6. 300.0.6CVE-2022-14343 May 2022
  7. 300.0.6CVE-2022-14733 May 2022
  8. 300.0.9CVE-2022-20975 Jul 2022Latest listed

techniques

No techniques linked

No ATT&CK techniques are linked to this CVE yet. MITRE CTID has not mapped it, and no report passage in the corpus ties it to a technique.

Am I affected? What do I upgrade to?

From GitHub Security Advisories and OSV

1 package in 1 ecosystem. Main package: openssl-src.

Upgrade to 300.0.12 or later

Fixes this CVE and 3 other known vulnerabilities in this package (CVE-2022-3602, CVE-2022-3786, +1).

Cargocargo update -p openssl-src --precise 300.0.12

First fixed in 300.0.5 for CVE-2022-0778.

Affected versions, by release line

If you runUpgrade to
300.0.0 up to 300.0.5300.0.12first fix for this CVE: 300.0.5
All versions before 111.18.0111.25.0first fix for this CVE: 111.18.0

“Up to” means the second version is the fix and is not affected.

Check your lockfile against all CVEs

What security researchers reported

Not named in any threat report yet

References

34 links, grouped by NVD tag
↑ ↓ chooseEnter openEsc close