wolfSSL — CR/LF Injection in subjectAltName DNS, Email and URI Entries Printed by wolfSSL_X509_print
The certificate text dump in wolfSSL's OpenSSL compatibility layer prints dNSName, rfc822Name and URI subject alternative names with a plain string format and no escaping. An entry that contains CR or LF adds lines of the certificate author's choosing to the printed text. Each entry is limited to under 80 bytes. Applications that print peer certificates into line-based output are affected.
- Advisory
- BYTERAY-2026-0349
- CWE
- CWE-144
- CVSS
- 5.3 (CVSS:3.1/AV:N/AC:L/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 through 5.9.4, builds with OPENSSL_EXTRA (--enable-opensslextra) whose application prints untrusted certificates with wolfSSL_X509_print
- Fixed in
- Master commit 9600d4d895f9a1d7925d9e2682f2ceacb8fca727 (PR 11682, merged 2026-10-15). Not in a wolfSSL stable release as of 2026-12-03.
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
When wolfSSL_X509_print reaches the subject alternative name extension, it prints each entry as DNS:<name>, email:<name> or URI:<name>. The name is inserted with %s and the result is written to the output.
The names are the bytes found in the certificate. The parser does not restrict the characters of a dNSName or rfc822Name, and for a URI it only checks where the first : and / are. A name that contains CR or LF therefore puts a line break, and whatever follows it, into the dump.
The amount of injected text is small, because each formatted entry has to fit in an 80-byte buffer, but it is enough for one or more complete lines. The code is in the OpenSSL compatibility layer, which is not in a default build, and the application has to call the print function on a certificate it did not create.
Affected Products and Versions
- Component:
src/x509.c,X509_print_name_entry(), reached fromwolfSSL_X509_print_ex(),wolfSSL_X509_print()andwolfSSL_X509_print_fp(). - Required build:
OPENSSL_EXTRAwith BIO support (src/x509.c:6847-6848).--enable-opensslextrais off by default (configure.ac:3314-3318). - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- The
v5.9.2-stableandv5.9.4-stabletags contain the same format calls. - Fixed on master. No wolfSSL release contains the fix.
- A default
./configurebuild does not include this code. Earlier releases were not checked.
Technical Details
X509_print_name_entry() walks the list of alternative names and formats each one into a stack buffer of MAX_WIDTH bytes, which is 80 (src/x509.c:6850-6852). The three affected branches are at src/x509.c:7003-7005, src/x509.c:7020-7023 and src/x509.c:7033-7036:
if (entry->type == ASN_DNS_TYPE) {
len = XSNPRINTF(scratch, MAX_WIDTH, "DNS:%s", entry->name);
}
The email and URI branches use "email:%s" and "URI:%s" in the same way. The buffer is then written to the BIO (src/x509.c:7064-7065). No step looks at the content of entry->name.
How the bytes arrive:
- The extension decoder copies each GeneralName into an entry with its encoded length (
wolfcrypt/src/asn.c:15198-15204). dNSName and rfc822Name are stored without any content check (wolfcrypt/src/asn.c:20540-20547,wolfcrypt/src/asn.c:20572-20579). A URI must have a scheme followed by:before any/(wolfcrypt/src/asn.c:20585-20620); the bytes after that are not examined. rfc822Name entries are decoded only in builds with name-constraint support, that is, whenIGNORE_NAME_CONSTRAINTSis not defined. - The entries are copied to the
WOLFSSL_X509object (src/internal.c:15698-15708). - The extension printer calls
X509PrintSubjAltName()(src/x509.c:7450), which callsX509_print_name_entry()(src/x509.c:7357-7363). - Each name is formatted with
%sand written out.
Two limits apply. If a formatted entry reaches 80 bytes the whole print fails (src/x509.c:7060-7063), so an entry can carry at most about 75 bytes. %s stops at a NUL byte. Neither limit prevents a short forged line.
Reachability and Preconditions
- The application calls one of the print functions on a certificate from an untrusted source, and sends the output to a log, an audit record, a terminal or a parser. The library does not print peer certificates by itself.
- The certificate does not need to be trusted. A peer certificate is handed to the application's verify callback as a
WOLFSSL_X509whether or not verification succeeded (src/internal.c:16320-16343). The example programs shipped with wolfSSL print the peer certificate this way when built withSHOW_CERTS(wolfssl/test.h:1432-1437). - A TLS peer, client or server, can supply such a certificate with no credentials, because it chooses its own subject alternative names.
Impact
Confirmed from source: CR, LF and other control bytes in a dNSName, rfc822Name or URI entry reach the output BIO unchanged. The certificate author controls up to about 75 bytes per entry and can use several entries. The effect is limited to the printed text: forged or split lines in a log or report, and control bytes such as ESC passed to a terminal. Host name matching and certificate verification are separate code and are not changed by this issue.
ByteRay did not build a proof of concept for this issue. The analysis is from source review.
Remediation and Mitigation
Fixed on master by commit 9600d4d895f9a1d7925d9e2682f2ceacb8fca727, part of PR 11682, merged 2026-10-15. The commit adds a helper that escapes control characters and uses it for the DNS, email and URI values. A later commit in the same pull request, 944d175297fd03dc8963cd7059e03eb6dcf7f234, reworks the helper to write to the BIO in pieces. On master a control byte in these entries is printed as a backslash followed by two hex digits. The fix is on master only. No wolfSSL release contains it as of 2026-12-03; the newest release tag, v5.9.4-stable, does not. The tag rust/wolfssl-wolfcrypt/v3.0.0, which marks a version of the Rust wrapper, points at a master snapshot that includes it.
Until a release is available: print untrusted certificates into a memory BIO and escape or reject control characters before the text reaches a log or terminal.
directoryName entries are printed by a separate routine in the same function; see BYTERAY-2026-0350. Subject and issuer names are covered in BYTERAY-2026-0351.
Timeline
- 2026-09-28 — Reported to wolfSSL.
- 2026-10-07 — Pull request 11682 opened upstream.
- 2026-10-15 — Pull request 11682 merged to master.
- 2026-12-03 — Public disclosure.
Credits
Discovered and reported by Mehrun P. Hunter and Shahriyar Jalayeri of ByteRay Ltd.