CVE-2026-42327
Executive Summary
CVE-2026-42327 is a critical memory safety vulnerability in the rust-openssl crate (versions 0.9.7 to before 0.10.79). The flaw resides in the X509Ref::ocsp_responders method, which returns OCSP responder URLs from a certificate’s Authority Information Access (AIA) extension. The function uses OpensslString and its Deref<Target = str> implementation, which calls str::from_utf8_unchecked on raw bytes from OpenSSL. Since OpenSSL does not enforce that the underlying IA5String is valid ASCII, a certificate containing non-UTF-8 bytes in the accessLocation field causes safe Rust code to construct a &str that violates the UTF-8 invariant. This leads to undefined behavior (UB) in Rust, potentially enabling memory corruption, denial of service, or arbitrary code execution.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability affects the rust-openssl crate, a widely used Rust package providing OpenSSL bindings. The crate is distributed via crates.io and is a dependency for thousands of Rust projects. Attackers could exploit this by crafting a malicious X.509 certificate with non-UTF-8 OCSP responder URLs. When a vulnerable application processes such a certificate (e.g., during TLS handshake or certificate validation), the UB can be triggered. The supply chain risk is high because the vulnerability is in a low-level cryptographic binding, and patching requires updating the crate version to 0.10.79 or later.
CVSS Breakdown & Threat Level
- Attack Vector (AV): Network (N) – The attacker can deliver the malicious certificate over the network.
- Attack Complexity (AC): Low (L) – No special conditions required beyond receiving a crafted certificate.
- Privileges Required (PR): None (N) – No authentication needed.
- User Interaction (UI): None (N) – No user action required.
- Scope (S): Unchanged (U) – The vulnerability does not cross trust boundaries.
- Confidentiality (C): None (N) – No direct data exposure.
- Integrity (I): None (N) – No direct data modification.
- Availability (A): High (H) – UB can cause crashes or memory corruption, leading to denial of service.
CVSS Score: 7.5 (High) – The potential for memory corruption and undefined behavior makes this a serious threat, though exploitation complexity may vary.
Deep Dive & Mechanics
The vulnerability stems from the interaction between Rust’s strict memory safety guarantees and OpenSSL’s lenient handling of string encodings.
AIA Extension: X.509 certificates can include an Authority Information Access (AIA) extension containing OCSP responder URLs. These URLs are stored as
IA5String, which is a subset of ASCII but OpenSSL does not validate that the bytes are valid ASCII or UTF-8.OpensslString: The
rust-opensslcrate providesOpensslStringas a wrapper around OpenSSL’sASN1_STRING. ItsDerefimplementation callsstr::from_utf8_uncheckedon the raw bytes, assuming they are valid UTF-8.The Bug: When a certificate contains non-UTF-8 bytes in the
accessLocationfield,str::from_utf8_uncheckedcreates a&strthat violates Rust’s UTF-8 invariant. This is undefined behavior in Rust, which can lead to:- Memory corruption (e.g., buffer overflows)
- Logic errors (e.g., incorrect string comparisons)
- Arbitrary code execution (if the UB is leveraged by an attacker)
Trigger: Any code that calls
X509Ref::ocsp_responders()on a certificate with a malformed AIA extension will trigger the UB. This includes TLS clients and servers that validate certificates.
Vulnerable vs. Patched Code
Vulnerable Code (rust-openssl < 0.10.79):
// In openssl/src/x509.rs (simplified)
impl Deref for OpensslString {
type Target = str;
fn deref(&self) -> &str {
unsafe { str::from_utf8_unchecked(self.as_bytes()) }
}
}
Patched Code (rust-openssl >= 0.10.79):
// In openssl/src/x509.rs (simplified)
impl Deref for OpensslString {
type Target = str;
fn deref(&self) -> &str {
// Validate UTF-8 before returning
str::from_utf8(self.as_bytes()).expect("OpensslString must be valid UTF-8")
}
}
The patch replaces from_utf8_unchecked with from_utf8, which returns a Result and panics on invalid UTF-8. This prevents UB but may cause panics in applications processing malformed certificates. A more robust fix would handle the error gracefully (e.g., returning an Option or Result).
Exploitation & Lab Setup
Red Team
Prerequisites:
- A target application using
rust-openssl< 0.10.79 that processes X.509 certificates (e.g., a TLS server or client). - Ability to deliver a crafted certificate to the target.
Exploitation Steps:
- Craft a Malicious Certificate: Use OpenSSL or a custom tool to generate an X.509 certificate with a non-UTF-8 OCSP responder URL. For example, set the
accessLocationfield to bytes0xFF 0xFE 0x00(invalid UTF-8). - Deliver the Certificate: Present the certificate during a TLS handshake or via a file upload that triggers certificate parsing.
- Trigger the Vulnerability: The target application calls
X509Ref::ocsp_responders()on the certificate, causing UB. Depending on the memory layout, this could crash the application or allow code execution.
Example Certificate Generation (using OpenSSL command line):
# Generate a self-signed certificate with a malformed AIA extension
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes \
-addext "authorityInfoAccess = OCSP;URI:http://\xff\xfe\x00.example.com"
Note: No public exploit code is available for this CVE. The above is a conceptual demonstration.
Blue Team
Detection:
- Monitor for certificates with non-ASCII or non-UTF-8 characters in the AIA extension.
- Use network monitoring to detect OCSP responder URLs containing invalid byte sequences.
- Enable application logging for panics or crashes related to string processing.
Mitigation:
- Update
rust-opensslto version 0.10.79 or later. - If patching is not immediately possible, implement input validation for certificate extensions before processing.
- Use a Web Application Firewall (WAF) to inspect TLS handshakes for malformed certificates.
Indicators of Compromise (IOCs)
- Network: TLS handshakes containing certificates with non-UTF-8 bytes in the AIA
accessLocationfield. - Logs: Application crashes or panics with messages like
"calledResult::unwrap()on anErrvalue: Utf8Error { valid_up_to: ... }"(if patched) or memory corruption errors (if unpatched). - File: X.509 certificates with hex bytes
FF FE 00or other non-ASCII sequences in the OCSP responder URL.
Detection Engineering
YARA Rule
rule CVE_2026_42327_Malformed_OCSP_URL {
meta:
description = "Detects X.509 certificates with non-UTF-8 bytes in OCSP responder URLs"
author = "Valters IT"
date = "2025-04-10"
cve = "CVE-2026-42327"
strings:
$aia_oid = { 2B 06 01 05 05 07 30 01 01 } // AIA OID (1.3.6.1.5.5.7.48.1)
$non_utf8 = { [80-FF] [80-FF] [00-7F] } // Non-UTF-8 byte sequences
condition:
$aia_oid and $non_utf8
}
Sigma Rule
title: Detection of Malformed OCSP Responder URLs in X.509 Certificates
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects network traffic containing X.509 certificates with non-UTF-8 bytes in the AIA extension
author: Valters IT
date: 2025-04-10
logsource:
category: network
product: tls
detection:
selection:
- certificate.extensions: "*authorityInfoAccess*"
- certificate.extensions|contains: "OCSP;URI:http://"
- certificate.extensions|re: "\\x[89A-Fa-f][0-9A-Fa-f]"
condition: selection
falsepositives:
- Rare legitimate use of non-ASCII characters in URLs
level: high
Suricata Rule
alert tls any any -> any any (msg:"CVE-2026-42327 - Malformed OCSP Responder URL in Certificate"; flow:to_client; tls.certificate.extensions; content:"|2B 06 01 05 05 07 30 01 01|"; content:"|80|"; within:100; sid:1000001; rev:1;)
Remediation & Mitigation
- Immediate Patch: Update
rust-opensslto version 0.10.79 or later. Runcargo update -p opensslin your Rust project. - Workaround: If patching is delayed, implement a wrapper that validates UTF-8 before calling
ocsp_responders():fn safe_ocsp_responders(cert: &X509) -> Result<Vec<String>, Utf8Error> { cert.ocsp_responders().iter().map(|s| { std::str::from_utf8(s.as_bytes()).map(|u| u.to_string()) }).collect() } - Network Defense: Deploy TLS inspection to reject certificates with non-ASCII characters in extensions.
- Monitoring: Enable crash dumps and monitor for panics in Rust applications processing certificates.
Report generated by Valters IT DevSecOps AI. For questions, contact security@valters-it.com.