VYPR
High severityNVD Advisory· Published Feb 8, 2023· Updated Nov 4, 2025

Use-after-free following BIO_new_NDEF

CVE-2023-0215

Description

The public API function BIO_new_NDEF is a helper function used for streaming ASN.1 data via a BIO. It is primarily used internally to OpenSSL to support the SMIME, CMS and PKCS7 streaming capabilities, but may also be called directly by end user applications.

The function receives a BIO from the caller, prepends a new BIO_f_asn1 filter BIO onto the front of it to form a BIO chain, and then returns the new head of the BIO chain to the caller. Under certain conditions, for example if a CMS recipient public key is invalid, the new filter BIO is freed and the function returns a NULL result indicating a failure. However, in this case, the BIO chain is not properly cleaned up and the BIO passed by the caller still retains internal pointers to the previously freed filter BIO. If the caller then goes on to call BIO_pop() on the BIO then a use-after-free will occur. This will most likely result in a crash.

This scenario occurs directly in the internal function B64_write_ASN1() which may cause BIO_new_NDEF() to be called and will subsequently call BIO_pop() on the BIO. This internal function is in turn called by the public API functions PEM_write_bio_ASN1_stream, PEM_write_bio_CMS_stream, PEM_write_bio_PKCS7_stream, SMIME_write_ASN1, SMIME_write_CMS and SMIME_write_PKCS7.

Other public API functions that may be impacted by this include i2d_ASN1_bio_stream, BIO_new_CMS, BIO_new_PKCS7, i2d_CMS_bio_stream and i2d_PKCS7_bio_stream.

The OpenSSL cms and smime command line applications are similarly affected.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

BIO_new_NDEF in OpenSSL improperly cleans up a freed filter BIO on failure, causing a use-after-free when the caller later calls BIO_pop(), leading to a crash or potentially code execution.

Root

Cause

The vulnerability lies in the function BIO_new_NDEF(), a public API designed to help stream ASN.1 data via a BIO. It prepends a BIO_f_asn1 filter BIO to a caller-supplied BIO to form a chain and returns the new head. However, if a failure occurs—for example, an invalid CMS recipient public key—the filter BIO is freed but the original BIO still holds internal pointers to the freed memory. The caller, unaware of the cleanup failure, might later call BIO_pop() on the chain, triggering a use-after-free [1][3].

Attack

Surface and Prerequisites

This scenario occurs directly in the internal function B64_write_ASN1() and, through it, in public APIs such as PEM_write_bio_ASN1_stream, SMIME_write_CMS, and the cms and smime command-line tools. Any application that calls these functions with data that can cause BIO_new_NDEF() to fail (e.g., by providing an invalid public key) is at risk. No special privileges or network access beyond the ability to supply malformed input is needed [1][2].

Impact

A successful exploit results in a use-after-free, which most likely causes a crash (denial of service). In certain memory conditions, it could be leveraged for arbitrary code execution. The flaw affects OpenSSL 3.0, 1.1.1, and 1.0.2; the attack does not require a valid signature, only that the library processes crafted ASN.1 data via the affected functions [1][2].

Mitigation

OpenSSL has released patches: 3.0.8, 1.1.1t, and 1.0.2zg (the latter for premium support customers). Users should upgrade immediately. There is no known workaround [2][4].

AI Insight generated on May 20, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
openssl-srccrates.io
< 111.25.0111.25.0
openssl-srccrates.io
>= 300.0.0, < 300.0.12300.0.12

Affected products

98

Patches

0

No patches discovered yet.

Vulnerability mechanics

AI mechanics synthesis has not run for this CVE yet.

References

15

News mentions

0

No linked articles in our index yet.