CVE-2026-107493

Use-After-Free in PEM_X509_INFO_read_bio_ex() when appending to a caller-supplied stack fails

Published Nov 17, 2026 CVSS n/a EPSS n/a KEV · Not listed
Description
Issue summary: When an application passes a stack to
PEM_X509_INFO_read_bio_ex() to add entries to, and reading fails,
OpenSSL frees every entry in the stack, both the old ones and any new
ones, but leaves them in the stack.

Impact summary: An application that passes an existing stack to
PEM_X509_INFO_read_bio_ex() and keeps using it after a failed read may
use memory that was already freed. This can cause a crash or, in
principle, memory corruption. Malformed PEM data can make the read fail,
but only applications that pass an existing stack are affected, and
OpenSSL itself does not do this.

CWE: CWE-416: Use After Free

Description: PEM_X509_INFO_read_bio_ex() reads certificates, CRLs and
private keys from PEM data and adds them to a stack of X509_INFO
structures. If the application passes a stack that is not NULL, the
function adds the new entries to it and must leave the entries that are
already there unchanged.

If reading fails, the function frees every entry in the stack. This
includes the entries that were there before the call, and the entries
added by the call. It does not remove these entries from the stack, so
the stack keeps pointers to freed memory. The failure can happen at any
point, even before any entry was added. A PEM item with invalid content
is enough. This also happens if the stack was empty: entries added
before the failure are freed but stay in the stack.

An application that then reads or frees the stack will use memory that
was already freed. This can crash the application or, in principle,
corrupt memory.

Only applications that pass a stack that is not NULL are affected.
OpenSSL itself never does this. Its own callers, including the code that
TLS uses to load CA certificates, always pass NULL. When the stack is
NULL, the function frees only the entries that it created itself, which
is safe. We expect that very few applications pass an existing stack. An
attacker can make the read fail with malformed PEM data, but cannot make
an application pass an existing stack.

The same problem affects PEM_X509_INFO_read_bio(), PEM_X509_INFO_read()
and PEM_X509_INFO_read_ex(), which use the same code. OpenSSL 1.1.1 and
1.0.2 have only the first two of these functions.

FIPS impact: no
The affected code is outside the FIPS module boundary.

Analysis

AI-generated

Technical impact

A function in OpenSSL, PEM_X509_INFO_read_bio_ex(), attempts to add certificates, CRLs and keys from PEM data to a caller-supplied stack. If the read fails, the function frees every node in the stack—including those previously present—yet leaves the freed pointers in the stack. Subsequent accesses to the stack can therefore use memory that has already been freed, causing a crash or, in principle, memory corruption. The flaw is a classic use‑after‑free condition (CWE‑416).

Affected Systems

The issue exists in any OpenSSL build that exposes the PEM_X509_INFO_read_bio_ex() family of functions and allows callers to provide an existing stack (i.e., a non‑NULL stack pointer). The vulnerability also applies to the older PEM_X509_INFO_read_bio(), PEM_X509_INFO_read() and PEM_X509_INFO_read_ex() variants found in OpenSSL 1.1.1 and 1.0.2. The problem does not affect OpenSSL’s internal callers, which always pass NULL, nor any deployment that never supplies an existing stack. Applications that load PEM data into a pre‑built list of X509_INFO structures for reuse are the only ones potentially impacted.

Risk and Exploitability

Because the attacker must supply malformed PEM data to trigger the failure and the target must be executing code that passes a pre‑existing stack, the attack vector is limited to a small subset of applications. The precise attack path is inferred from the description: an application that calls the affected function with a non‑null stack and then continues to use or free that stack after a failure may experience a use‑after‑free scenario. No EPSS score is available and the vulnerability is not listed in CISA’s KEV catalog, indicating no well‑known exploitation at this time. Nevertheless, the flaw could lead to program termination or, if exploited carefully, memory corruption that might be leveraged for further compromise in sensitive deployments.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade to the latest OpenSSL release that includes the commit fixing the stack handling bug (see commits 0486dfad, c57a5ccf, c8f6d04f).
  • If an upgrade cannot be performed immediately, modify the application so that it passes NULL to PEM_X509_INFO_read_bio_ex() and associated functions instead of a pre‑existing stack.
  • Validate or sanitize PEM input to prevent malformed data from triggering the failure path; limit the size and content of PEM buffers to avoid unintended read failures.

Generated by OpenCVE AI on November 17, 2026 at 09:21 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories available
History
Type Values Removed Values Added
First Time appeared Openssl
Openssl openssl
Vendors & Products Openssl
Openssl openssl
Type Values Removed Values Added
Description Issue summary: When an application passes a stack to PEM_X509_INFO_read_bio_ex() to add entries to, and reading fails, OpenSSL frees every entry in the stack, both the old ones and any new ones, but leaves them in the stack. Impact summary: An application that passes an existing stack to PEM_X509_INFO_read_bio_ex() and keeps using it after a failed read may use memory that was already freed. This can cause a crash or, in principle, memory corruption. Malformed PEM data can make the read fail, but only applications that pass an existing stack are affected, and OpenSSL itself does not do this. CWE: CWE-416: Use After Free Description: PEM_X509_INFO_read_bio_ex() reads certificates, CRLs and private keys from PEM data and adds them to a stack of X509_INFO structures. If the application passes a stack that is not NULL, the function adds the new entries to it and must leave the entries that are already there unchanged. If reading fails, the function frees every entry in the stack. This includes the entries that were there before the call, and the entries added by the call. It does not remove these entries from the stack, so the stack keeps pointers to freed memory. The failure can happen at any point, even before any entry was added. A PEM item with invalid content is enough. This also happens if the stack was empty: entries added before the failure are freed but stay in the stack. An application that then reads or frees the stack will use memory that was already freed. This can crash the application or, in principle, corrupt memory. Only applications that pass a stack that is not NULL are affected. OpenSSL itself never does this. Its own callers, including the code that TLS uses to load CA certificates, always pass NULL. When the stack is NULL, the function frees only the entries that it created itself, which is safe. We expect that very few applications pass an existing stack. An attacker can make the read fail with malformed PEM data, but cannot make an application pass an existing stack. The same problem affects PEM_X509_INFO_read_bio(), PEM_X509_INFO_read() and PEM_X509_INFO_read_ex(), which use the same code. OpenSSL 1.1.1 and 1.0.2 have only the first two of these functions. FIPS impact: no The affected code is outside the FIPS module boundary.
Title Use-After-Free in PEM_X509_INFO_read_bio_ex() when appending to a caller-supplied stack fails
Weaknesses CWE-416
References
Weaknesses

Sources

Status
PUBLISHED
Assigner
openssl
Published
Updated
Nov 17, 2026, 8:14 AM
Reserved
Oct 8, 2026, 8:31 AM
Status
Received
Published
Nov 17, 2026, 9:17 AM
Modified
Nov 17, 2026, 9:17 AM