← ALL ADVISORIES

MEDIUM BYTERAY-2026-0344Disclosed

wolfSSL — CR/LF Passed Through by wolfSSL_ASN1_STRING_print in Subject Alternative Name Output

wolfSSL_ASN1_STRING_print replaces control bytes with dots but leaves carriage return and line feed as they are. wolfSSL_GENERAL_NAME_print uses it for the email, DNS and URI names of a certificate, so a subject alternative name containing CR or LF adds lines of the certificate author's choosing to the printed output.

Advisory
BYTERAY-2026-0344
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_ALL (--enable-opensslall) whose application prints certificate alternative names with wolfSSL_GENERAL_NAME_print, and OPENSSL_EXTRA builds that call wolfSSL_ASN1_STRING_print directly
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

wolfSSL_ASN1_STRING_print() writes an ASN.1 string to a BIO and shows unprintable bytes as .. Its test for "unprintable" covers the control range but makes an exception for carriage return and line feed. Those two bytes are written through.

wolfSSL_GENERAL_NAME_print() prints one entry of a certificate's subject alternative name extension. For email, DNS and URI entries it writes a label and then hands the value to wolfSSL_ASN1_STRING_print(). The value is whatever the certificate contains. A name such as a DNS entry with an embedded line feed is printed as two lines, and the text after the line feed is chosen by whoever made the certificate. Where the output goes to a log, an audit record or another line-based consumer, that text reads as a separate entry. Other control bytes in the same value are turned into dots, so the output looks sanitized. Both functions are part of the OpenSSL compatibility layer, which a default build does not include, and wolfSSL does not call them on its own.

Affected Products and Versions

  • Component: src/ssl_asn1.c, wolfssl_unprintable_char() and wolfSSL_ASN1_STRING_print(); src/x509.c, wolfSSL_GENERAL_NAME_print().
  • Required build: wolfSSL_ASN1_STRING_print() needs OPENSSL_EXTRA with BIO support (src/ssl_asn1.c:3428-3431). wolfSSL_GENERAL_NAME_print() needs OPENSSL_ALL (src/x509.c:5847). --enable-opensslextra and --enable-opensslall are off by default (configure.ac:3314-3318, configure.ac:3294-3298); several application-compatibility options turn OPENSSL_ALL on (configure.ac:3299-3311).
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • The v5.9.2-stable and v5.9.4-stable tags contain the same classifier and the same calls.
  • Partly fixed on master: wolfSSL_GENERAL_NAME_print() no longer uses this function. wolfSSL_ASN1_STRING_print() itself still passes CR and LF. See Remediation.
  • A default ./configure build does not include this code. Earlier releases were not checked.

Technical Details

The classifier (src/ssl_asn1.c:3438-3445):

static int wolfssl_unprintable_char(char c)
{
    const unsigned char last_unprintable = 31;
    const unsigned char LF = 10;               /* Line Feed */
    const unsigned char CR = 13;               /* Carriage Return */

    return (c <= last_unprintable) && (c != LF) && (c != CR);
}

wolfSSL_ASN1_STRING_print() replaces each byte the classifier reports with . (src/ssl_asn1.c:3469-3473) and writes the buffer to the BIO (src/ssl_asn1.c:3475). Bytes 10 and 13 are never reported.

How a certificate value reaches it:

  1. The certificate parser stores each subjectAltName entry with its encoded length and does not inspect the characters (wolfcrypt/src/asn.c:15187-15204). dNSName and rfc822Name values are stored as found (wolfcrypt/src/asn.c:20540-20547, wolfcrypt/src/asn.c:20572-20579). A URI is only checked for the position of its first : and / (wolfcrypt/src/asn.c:20585-20620).
  2. The entries are copied to the WOLFSSL_X509 object (src/internal.c:15698-15708).
  3. The application asks for the extension. wolfSSL_X509_get_ext_d2i() copies each entry into a GENERAL_NAME string with its stored length (src/x509.c:2653-2660).
  4. The application calls wolfSSL_GENERAL_NAME_print(). The email, DNS and URI branches print a label and call wolfSSL_ASN1_STRING_print() (src/x509.c:5890-5895, src/x509.c:5898-5903, src/x509.c:5925-5931).
  5. CR and LF in the value are written to the BIO unchanged.

The certificate text dump (wolfSSL_X509_print and related functions) does not use this path; its alternative name output is covered by BYTERAY-2026-0349.

Reachability and Preconditions

  • The application calls wolfSSL_GENERAL_NAME_print() on names taken from an untrusted certificate, or calls wolfSSL_ASN1_STRING_print() directly on such a string. No library code calls wolfSSL_GENERAL_NAME_print().
  • The output goes to a log, terminal, audit record or other place where line structure carries meaning.
  • The certificate does not have to be trusted. A peer certificate that fails verification is still handed to the application's verify callback as an object it can inspect (src/internal.c:16320-16343). A TLS peer, client or server, can supply it with no credentials.

Impact

Confirmed from source: CR and LF inside an email, DNS or URI alternative name reach the output BIO unchanged, and the certificate author controls the text that follows. In a line-based log this allows forged or split entries. The whole name is written, so the injected text can be as long as the name allows. Certificate verification and hostname matching are not affected.

Not verified: the effect on any particular application or log consumer.

ByteRay did not build a proof of concept for this issue. The analysis is from source review.

Remediation and Mitigation

Not fixed on wolfSSL master as of commit e4b0841b32e7 (2026-12-03) for direct callers of wolfSSL_ASN1_STRING_print(): the classifier still exempts CR and LF, and the function still writes them out.

The path through wolfSSL_GENERAL_NAME_print() is closed on master. Commit 944d175297fd03dc8963cd7059e03eb6dcf7f234, merged with PR 11682 on 2026-10-15, makes the email, DNS and URI branches print through a helper that writes each control byte as a backslash and two hex digits. No release contains that change as of 2026-12-03.

A complete fix would stop wolfSSL_ASN1_STRING_print() from writing CR and LF, or document that it does and give callers an escaping alternative.

Until then: write the output of these functions to a memory BIO and escape or reject CR, LF and other control bytes before the text reaches a log or terminal.

The same function also modified the string it printed; see BYTERAY-2026-0422. The directoryName branch of wolfSSL_GENERAL_NAME_print() is BYTERAY-2026-0345.

Timeline

  • 2026-09-28 — Reported to wolfSSL.
  • 2026-10-07 — Pull request 11682 opened upstream.
  • 2026-10-15 — Pull request 11682 merged to master. It changes wolfSSL_GENERAL_NAME_print().
  • 2026-12-03 — Public disclosure.

Credits

Discovered and reported by Mehrun P. Hunter and Shahriyar Jalayeri of ByteRay Ltd.

References