# CVE-2026-31789: Heap Buffer Overflow in Hexadecimal Conversion

> Heap buffer overflow in OpenSSL on 32-bit platforms allows code execution or crashes when logging large X.509 certificates.

- **Severity:** Medium 5.8 (`CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 7 Apr 2026
- **Updated:** 12 May 2026
- **Also known as:** ALPINE-CVE-2026-31789, AZL-81944, BELL-CVE-2026-31789, CLSA-2026-1786493710, CLSA-2026-1789474528, CLSA-2026-1789474778, CLSA-2026-1789474979, DEBIAN-CVE-2026-31789, ECHO-f779-bf6a-ba8e, GHSA-j79m-9jxq-788r, JLSEC-2026-276, MINI-gq4x-m265-2qrp, MINI-mfv7-rxr2-4gv7, MINI-pxxf-6g45-6962, ROOT-OS-ALPINE-317-CVE-2026-31789, UBUNTU-CVE-2026-31789

## What is CVE-2026-31789?

CVE-2026-31789 is a medium-severity vulnerability in Openssl Openssl, published on 7 Apr 2026. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

### Official description

Issue summary: Converting an excessively large OCTET STRING value to
a hexadecimal string leads to a heap buffer overflow on 32 bit platforms.

Impact summary: A heap buffer overflow may lead to a crash or possibly
an attacker controlled code execution or other undefined behavior.

If an attacker can supply a crafted X.509 certificate with an excessively
large OCTET STRING value in extensions such as the Subject Key Identifier
(SKID) or Authority Key Identifier (AKID) which are being converted to hex,
the size of the buffer needed for the result is calculated as multiplication
of the input length by 3. On 32 bit platforms, this multiplication may overflow
resulting in the allocation of a smaller buffer and a heap buffer overflow.

Applications and services that print or log contents of untrusted X.509
certificates are vulnerable to this issue. As the certificates would have
to have sizes of over 1 Gigabyte, printing or logging such certificates
is a fairly unlikely operation and only 32 bit platforms are affected,
this issue was assigned Low severity.

The FIPS modules in 3.6, 3.5, 3.4, 3.3 and 3.0 are not affected by this
issue, as the affected code is outside the OpenSSL FIPS module boundary.

Weakness: CWE-787 (Out-of-bounds Write)

## Which versions are affected by CVE-2026-31789?

It affects 1 product.


Products: Openssl Openssl.

## How do I fix CVE-2026-31789?

Apply the vendor's patch.

## Is CVE-2026-31789 being exploited?

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

## Other vulnerabilities in Openssl Openssl

- [CVE-2009-3245](https://insights.sbomify.com/CVE-2009-3245/): Null dereference in n/a (critical 10.0)
- [CVE-2006-3738](https://insights.sbomify.com/CVE-2006-3738/): Memory corruption in n/a (critical 10.0)
- [CVE-2026-63073](https://insights.sbomify.com/CVE-2026-63073/): Untrusted Sender DN Used as Format String in CMP Response Validation (critical 9.8)
- [CVE-2016-6309](https://insights.sbomify.com/CVE-2016-6309/): Use after free in n/a (critical 9.8)
- [CVE-2016-0799](https://insights.sbomify.com/CVE-2016-0799/): Integer overflow in n/a (critical 9.8)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2026-31789 and fix it if it is affected.

What it is: CVE-2026-31789 is a medium-severity vulnerability in Openssl Openssl, published on 7 Apr 2026. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2026-31789 in the wild and no public exploit code.

Affected product: Openssl Openssl. No package-level version data is available, so check the vendor advisory linked from the reference page.

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-2026-31789/ (Markdown: https://insights.sbomify.com/CVE-2026-31789/index.md)
```

## Sources

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

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