# CVE-2022-0778: Infinite loop in BN_mod_sqrt() reachable when parsing certificates

> Attackers can cause a denial of service via infinite loop in OpenSSL by crafting malicious certificates with invalid elliptic curve parameters.

- **Severity:** High 7.5 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 15 Mar 2022
- **Updated:** 14 Oct 2026
- **Also known as:** ALPINE-CVE-2022-0778, ALSA-2022:1065, ALSA-2022:5326, AZL-9051, BIT-mariadb-2022-0778, BIT-mariadb-min-2022-0778, BIT-mysql-client-2022-0778, BIT-node-2022-0778, BIT-node-min-2022-0778, CLEANSTART-2026-OI68179, CLEANSTART-2026-SV91559, CLSA-2022-1647550273, CLSA-2022-1647550569, CLSA-2022-1647550603, CLSA-2022-1647550812, CLSA-2022-1647550873, DEBIAN-CVE-2022-0778, DLA-2953-1, GHSA-x3mh-jvjw-3xwx, JLSEC-2026-227, MGASA-2022-0113, OESA-2022-1603, OESA-2022-1924, RHSA-2022:1065, RHSA-2022:1066, RHSA-2022:1071, RHSA-2022:1073, RHSA-2022:1076, RHSA-2022:1077, RHSA-2022:1078, RHSA-2022:1082, RHSA-2022:1091, RHSA-2022:1112, RHSA-2022:1519, RHSA-2022:4899, RHSA-2022:5326, RLSA-2022:1065, RLSA-2022:4899, RLSA-2022:5326, RUSTSEC-2022-0014, SUSE-RU-2022:0861-1, SUSE-SU-2022:0851-1, SUSE-SU-2022:0853-1, SUSE-SU-2022:0854-1, SUSE-SU-2022:0856-1, SUSE-SU-2022:0857-1, SUSE-SU-2022:0859-1, SUSE-SU-2022:0860-1, SUSE-SU-2022:0861-1, SUSE-SU-2022:0935-1, SUSE-SU-2022:14915-1, SUSE-SU-2022:14916-1, UBUNTU-CVE-2022-0778, USN-5328-1, USN-5328-2, openSUSE-SU-2022:0856-1, openSUSE-SU-2024:11927-1, openSUSE-SU-2024:11933-1, openSUSE-SU-2024:11944-1, openSUSE-SU-2024:11953-1, openSUSE-SU-2024:12444-1, openSUSE-SU-2025:14965-1

## What is CVE-2022-0778?

CVE-2022-0778 is a high-severity denial of service vulnerability in Debian Debian Linux, published on 15 Mar 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

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).

Weakness: CWE-835 (Loop with Unreachable Exit Condition)

## Which versions are affected by CVE-2022-0778?

10 open source packages ship an affected version, including openssl-src, mariadb and mariadb-min. It affects 13 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `openssl-src` | crates.io | All versions | 111.18.0 |
| `openssl-src` | crates.io | All versions | 111.18.0 |
| `openssl-src` | crates.io | From 0.0.0-0 | 111.18.0, 300.0.5 |
| `openssl-src` | crates.io | From 300.0.0 | 300.0.5 |
| `openssl-src` | crates.io | From 300.0.0 | 300.0.5 |
| `mariadb` | Bitnami | From 10.2.0 | 10.2.42, 10.3.33, 10.4.23, 10.5.14, 10.6.6, 10.7.2 |
| `mariadb-min` | Bitnami | From 10.2.0 | 10.2.42, 10.3.33, 10.4.23, 10.5.14, 10.6.6, 10.7.2 |
| `mysql-client` | Bitnami | From 10.2.0 | 10.2.42, 10.3.33, 10.4.23, 10.5.14, 10.6.6, 10.7.2 |
| `node` | Bitnami | From 12.0.0 | 12.12.1, 12.22.11, 14.14.1, 14.19.1, 16.12.1, 16.14.2, 17.7.2 |
| `node-min` | Bitnami | From 12.0.0 | 12.12.1, 12.22.11, 14.14.1, 14.19.1, 16.12.1, 16.14.2, 17.7.2 |
| `compat-openssl10` | AlmaLinux:8 | All versions | 1:1.0.2o-4.el8_6 |
| `openssl` | AlmaLinux:8 | All versions | 1:1.1.1k-6.el8_5 |
| `openssl-devel` | AlmaLinux:8 | All versions | 1:1.1.1k-6.el8_5 |
| `openssl-libs` | AlmaLinux:8 | All versions | 1:1.1.1k-6.el8_5 |
| `openssl-perl` | AlmaLinux:8 | All versions | 1:1.1.1k-6.el8_5 |
| `openssl` | Red Hat:enterprise_linux:7::client | All versions | 1:1.0.2k-25.el7_9 |
| `openssl-debuginfo` | Red Hat:enterprise_linux:7::client | All versions | 1:1.0.2k-25.el7_9 |
| `openssl-devel` | Red Hat:enterprise_linux:7::client | All versions | 1:1.0.2k-25.el7_9 |
| `openssl-libs` | Red Hat:enterprise_linux:7::client | All versions | 1:1.0.2k-25.el7_9 |
| `openssl-perl` | Red Hat:enterprise_linux:7::client | All versions | 1:1.0.2k-25.el7_9 |
| `openssl-static` | Red Hat:enterprise_linux:7::client | All versions | 1:1.0.2k-25.el7_9 |
| `openssl-debuginfo` | Red Hat:enterprise_linux:7::computenode | All versions | 1:1.0.2k-25.el7_9 |
| `openssl-devel` | Red Hat:enterprise_linux:7::computenode | All versions | 1:1.0.2k-25.el7_9 |
| `openssl-perl` | Red Hat:enterprise_linux:7::computenode | All versions | 1:1.0.2k-25.el7_9 |
| `openssl-static` | Red Hat:enterprise_linux:7::computenode | All versions | 1:1.0.2k-25.el7_9 |
| `openssl` | Red Hat:enterprise_linux:7::server | All versions | 1:1.0.2k-25.el7_9 |
| `openssl-debuginfo` | Red Hat:enterprise_linux:7::server | All versions | 1:1.0.2k-25.el7_9 |
| `openssl-devel` | Red Hat:enterprise_linux:7::server | All versions | 1:1.0.2k-25.el7_9 |
| `openssl-libs` | Red Hat:enterprise_linux:7::server | All versions | 1:1.0.2k-25.el7_9 |
| `openssl-perl` | Red Hat:enterprise_linux:7::server | All versions | 1:1.0.2k-25.el7_9 |
| `openssl-static` | Red Hat:enterprise_linux:7::server | All versions | 1:1.0.2k-25.el7_9 |
| `openssl` | Red Hat:enterprise_linux:7::workstation | All versions | 1:1.0.2k-25.el7_9 |
| `openssl-debuginfo` | Red Hat:enterprise_linux:7::workstation | All versions | 1:1.0.2k-25.el7_9 |
| `openssl-devel` | Red Hat:enterprise_linux:7::workstation | All versions | 1:1.0.2k-25.el7_9 |
| `openssl-libs` | Red Hat:enterprise_linux:7::workstation | All versions | 1:1.0.2k-25.el7_9 |
| `openssl-perl` | Red Hat:enterprise_linux:7::workstation | All versions | 1:1.0.2k-25.el7_9 |
| `openssl-static` | Red Hat:enterprise_linux:7::workstation | All versions | 1:1.0.2k-25.el7_9 |
| `compat-openssl10` | Red Hat:enterprise_linux:8::appstream | All versions | 1:1.0.2o-4.el8_6 |
| `compat-openssl10-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 1:1.0.2o-4.el8_6 |
| `compat-openssl10-debugsource` | Red Hat:enterprise_linux:8::appstream | All versions | 1:1.0.2o-4.el8_6 |

Products: Debian Debian Linux, Fedoraproject Fedora, Mariadb Mariadb, Netapp 500f Firmware, Netapp A250 Firmware, Netapp Cloud Volumes Ontap Mediator, Netapp Clustered Data Ontap, Netapp Clustered Data Ontap Antivirus Connector, Netapp Santricity Smi-S Provider, Netapp Storagegrid, Nodejs Node.js, Openssl Openssl, Tenable Nessus.

## How do I fix CVE-2022-0778?

Upgrade openssl-src to a fixed version for your release line: 111.18.0 or 300.0.5.

## Is CVE-2022-0778 being exploited?

There is no known exploitation of CVE-2022-0778 in the wild and no public exploit code.

Public exploit code:

- Proof of concept for CVE-2022-0778, which triggers an infinite loop in parsing X.509 certificates due to a bug in BN_mod_sqrt (github_poc): https://github.com/drago-96/CVE-2022-0778
- https://github.com/jkakavas/CVE-2022-0778-POC (github_poc): https://github.com/jkakavas/CVE-2022-0778-POC
- https://github.com/yywing/cve-2022-0778 (github_poc): https://github.com/yywing/cve-2022-0778
- Proof of concept for CVE-2022-0778 in P12 and PEM format (github_poc): https://github.com/0xUhaw/CVE-2022-0778
- https://github.com/jeongjunsoo/CVE-2022-0778 (github_poc): https://github.com/jeongjunsoo/CVE-2022-0778
- https://github.com/Trinadh465/openssl-1.1.1g_CVE-2022-0778 (github_poc): https://github.com/Trinadh465/openssl-1.1.1g_CVE-2022-0778

## Other vulnerabilities in Debian Debian Linux

- [CVE-2015-3306](https://insights.sbomify.com/CVE-2015-3306/): ProFTPD Improper Access Control (critical 10.0, exploited in the wild)
- [CVE-2025-49113](https://insights.sbomify.com/CVE-2025-49113/): RoundCube Webmail Deserialization of Untrusted Data (critical 9.9, exploited in the wild)
- [CVE-2026-24061](https://insights.sbomify.com/CVE-2026-24061/): GNU InetUtils Argument Injection (critical 9.8, exploited in the wild)
- [CVE-2025-39682](https://insights.sbomify.com/CVE-2025-39682/): Linux Kernel Improper Check for Unusual or Exceptional Conditions (critical 9.8, exploited in the wild)
- [CVE-2024-9680](https://insights.sbomify.com/CVE-2024-9680/): Mozilla Firefox Use-After-Free (critical 9.8, exploited in the wild)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2022-0778 and fix it if it is affected.

What it is: CVE-2022-0778 is a high-severity denial of service vulnerability in Debian Debian Linux, published on 15 Mar 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2022-0778 in the wild and no public exploit code.

Affected packages and fixed versions:
- openssl-src (crates.io): affected all versions; fixed in 111.18.0
- openssl-src (crates.io): affected all versions; fixed in 111.18.0
- openssl-src (crates.io): affected from 0.0.0-0; fixed in 111.18.0, 300.0.5
- openssl-src (crates.io): affected from 300.0.0; fixed in 300.0.5
- openssl-src (crates.io): affected from 300.0.0; fixed in 300.0.5
- mariadb (Bitnami): affected from 10.2.0; fixed in 10.2.42, 10.3.33, 10.4.23, 10.5.14, 10.6.6, 10.7.2
- mariadb-min (Bitnami): affected from 10.2.0; fixed in 10.2.42, 10.3.33, 10.4.23, 10.5.14, 10.6.6, 10.7.2
- mysql-client (Bitnami): affected from 10.2.0; fixed in 10.2.42, 10.3.33, 10.4.23, 10.5.14, 10.6.6, 10.7.2
- node (Bitnami): affected from 12.0.0; fixed in 12.12.1, 12.22.11, 14.14.1, 14.19.1, 16.12.1, 16.14.2, 17.7.2
- node-min (Bitnami): affected from 12.0.0; fixed in 12.12.1, 12.22.11, 14.14.1, 14.19.1, 16.12.1, 16.14.2, 17.7.2

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2022-0778/ (Markdown: https://insights.sbomify.com/CVE-2022-0778/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2022-0778
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2022-0778
- OSV: https://osv.dev/vulnerability/CVE-2022-0778

---
From sbomify Insights: https://insights.sbomify.com/CVE-2022-0778/
Summaries are generated and may contain mistakes; the official description above is the record.
