wolfSSL — Delimiter Injection in subjectAltName Certificate Printing
The wolfSSL certificate print functions render subjectAltName entries as one list separated by ", " and copy each value unescaped. A certificate with a SAN value that contains ", DNS:" or CR/LF is printed with entries or lines that are not in the certificate.
- Advisory
- BYTERAY-2026-0450
- CWE
- CWE-140
- CVSS
- 3.7 (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:N)
- Vendor
- wolfSSL
- Product
- wolfSSL
- Reported
- 2026-09-28
- Disclosure
- 2026-12-03
- Affected
- wolfSSL 5.9.2 (tested at master commit d95483f), builds with OPENSSL_EXTRA and BIO support whose application prints certificates with wolfSSL_X509_print or its variants
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
wolfSSL_X509_print() and related functions write a human-readable dump of a certificate to a BIO. The subjectAltName extension is printed as a single list: each entry is written as a label and a value, such as DNS:host.example.com, with , between entries.
The values are taken from the certificate and formatted with %s. Directory name entries are assembled by a helper that copies the raw string bytes. No character is escaped on either route. The string types involved allow commas, colons, equals signs and control characters.
A certificate with a DNS entry of a.example.com, DNS:evil.example is printed as two DNS entries. A value that contains CR and LF adds lines to the dump. Someone reading the output, or a tool that parses it for audit or monitoring, sees entries the certificate does not contain. The bounds checks in this code hold, so this is forged display and log text and not memory corruption. The print functions are part of the OpenSSL compatibility layer, which is not in a default build.
Affected Products and Versions
- Component:
src/x509.c,X509_print_name_entry()and its helperX509PrintDirType(). Reached fromwolfSSL_X509_print(),wolfSSL_X509_print_ex(),wolfSSL_X509_print_fp(),wolfSSL_X509_ACERT_print()andwolfSSL_X509_REQ_print(). - Required build:
OPENSSL_EXTRAwithoutNO_BIO(src/x509.c:6847-6848). - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- A default build is not affected. The OpenSSL compatibility layer is disabled by default (
configure.ac:3315). - Other releases were not checked.
Technical Details
X509_print_name_entry() (src/x509.c:6973) loops over the list of alternative names. Before every entry after the first it writes the separator (src/x509.c:6996-7001), then formats the entry by type:
if (entry->type == ASN_DNS_TYPE) {
len = XSNPRINTF(scratch, MAX_WIDTH, "DNS:%s", entry->name);
}
The IP Address:%s, email:%s and URI:%s branches have the same shape (src/x509.c:7003-7054). The formatted entry is written to the BIO at src/x509.c:7064-7065.
For a directory name entry the loop calls X509PrintDirType() (src/x509.c:7025). That helper:
- Walks the encoded name and looks for known attribute types.
- Writes
,before each matched field after the first (src/x509.c:6913-6918). - Accepts a value whose tag is PrintableString, IA5String or UTF8String (
src/x509.c:6929-6936). This is a check on the type, not on the characters. - Copies the value bytes into the output with
XMEMCPY(src/x509.c:6960).
The existing checks are about size. X509PrintDirType() tracks the bytes left in its buffer, and the loop aborts when a formatted entry reaches MAX_WIDTH (src/x509.c:7060). None of them looks for ,, :, =, CR or LF in a value. The path from the certificate to the output is short: the alternative names are decoded from the certificate into a list, X509PrintSubjAltName() (src/x509.c:7357) passes the list to X509_print_name_entry(), and the result goes to the caller's BIO.
Reachability and Preconditions
- Build with
OPENSSL_EXTRAand BIO support. - The application prints a certificate it received with one of the print functions above, and a person or a tool then reads the output as a comma-separated, line-oriented record.
- The attacker supplies a certificate with a chosen subjectAltName value, typically by presenting it in a TLS handshake. If the application prints only verified certificates, the attacker needs an accepted CA to issue the value. Applications that dump unverified certificates for diagnostics accept any certificate.
- No other privilege is needed.
Impact
The printed certificate can show subjectAltName entries and whole lines that are not in the certificate. Operators and audit or monitoring tools that rely on the dump can be misled about which names a certificate covers. Nothing inside wolfSSL parses this output as structured data. Each entry is limited by the MAX_WIDTH check. There is no memory-safety impact.
ByteRay did not build a proof of concept for this issue. The analysis is from source review.
Remediation and Mitigation
ByteRay has not confirmed a fixed wolfSSL release for this issue as of 2026-12-03, and has not checked it against wolfSSL changes made after the tested commit.
The fix direction is to escape or encode delimiter and control characters in every value written into the record: at least the comma, semicolon, equals sign, colon, NUL, CR and LF. Backslash escaping in the style of RFC 4514 suits directory strings; values with control characters can be hex-encoded. The same escaping belongs in X509PrintDirType(). Printing each entry on its own line with a fixed label is an alternative. The existing bounds checks should stay. Applications should not make decisions from the printed text. Read alternative names through the structured accessors, and treat the dump as untrusted when it is logged or shown.
Timeline
- 2026-09-28 — Reported to wolfSSL.
- 2026-12-03 — Public disclosure.
Credits
Discovered and reported by Mehrun P. Hunter and Shahriyar Jalayeri of ByteRay Ltd.