← ALL ADVISORIES

LOW BYTERAY-2026-0424Disclosed

wolfSSL — CR/LF and Embedded NUL Passed Through by wolfSSL_X509_NAME_oneline

wolfSSL_X509_NAME_oneline returns the one-line form of a certificate subject or issuer exactly as the parser assembled it, with attribute values copied in byte for byte. A value containing CR or LF puts line breaks into the returned string, and a NUL byte in a value cuts the string short. Applications that log the string can be made to write forged or misleading entries.

Advisory
BYTERAY-2026-0424
CWE
CWE-144
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 through 5.9.4, builds that keep peer certificates (KEEP_PEER_CERT, SESSION_CERTS or OPENSSL_EXTRA) whose application logs or displays the result of wolfSSL_X509_NAME_oneline; master still returns CR and LF
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

wolfSSL_X509_NAME_oneline() gives the application a text form of a certificate's subject or issuer, such as /C=US/O=Example/CN=host. It is the usual way to put a peer's identity into a log line. The string is assembled when the certificate is parsed, by appending each attribute's label and value. The value is appended as it appears in the certificate, with no escaping, and wolfSSL_X509_NAME_oneline() returns a copy of the result.

Two things follow. A value that contains a carriage return or line feed produces a string with line breaks in it, and a log written from that string contains a line chosen by the certificate's author. A value that contains a NUL byte ends the string at that point, so the name shown is shorter than the name in the certificate. The certificate does not need to be trusted: applications commonly log the name of a certificate at the moment they reject it. The function is not part of a default build.

Affected Products and Versions

  • Component: src/x509.c, wolfSSL_X509_NAME_oneline(); the string is built in wolfcrypt/src/asn.c, GetRDN(), and stored by CopyDecodedName() in src/internal.c.
  • Required build: KEEP_PEER_CERT, SESSION_CERTS, OPENSSL_EXTRA or OPENSSL_EXTRA_X509_SMALL (src/x509.c:3915-3916). The OpenSSL compatibility layer defines KEEP_PEER_CERT (wolfssl/wolfcrypt/settings.h:4999-5005), and --enable-opensslextra is off by default (configure.ac:3314-3318).
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • The v5.9.2-stable and v5.9.4-stable tags contain the same copies and the same length handling.
  • Master as of 2026-12-03 escapes an embedded NUL but still returns CR and LF.
  • A default ./configure build does not include this function. Earlier releases were not checked.

Technical Details

The function returns a copy of the stored string and looks at none of its bytes (src/x509.c:3952-3953):

    XMEMCPY(in, name->name, copySz - 1);
    in[copySz - 1] = 0;

The stored string comes from the certificate parser. For each attribute, GetRDN() appends the label and then the value (wolfcrypt/src/asn.c:15569-15572):

                XMEMCPY(&full[*idx], typeStr, typeStrLen);
                *idx += typeStrLen;
                XMEMCPY(&full[*idx], str, strLen);
                *idx += strLen;

A comment directly above these lines says that values are copied verbatim and that the display string may truncate at an embedded NUL.

The path from a certificate to the application:

  1. The parser builds the subject and issuer display strings as above; str and strLen are the encoded attribute value and its length.
  2. CopyDecodedName() copies the display string into the name object with XSTRNCPY and takes its length from XSTRLEN (src/internal.c:15174-15177, src/internal.c:15185-15187). A NUL byte inside a value ends the name here.
  3. The application calls wolfSSL_X509_get_subject_name() or wolfSSL_X509_get_issuer_name() and passes the result to wolfSSL_X509_NAME_oneline().
  4. The returned string contains every byte of the stored name, including CR and LF.

Reachability and Preconditions

  • The application calls wolfSSL_X509_NAME_oneline() on a name from a certificate it did not create and writes the result to a log, terminal, audit record or a line-based protocol.
  • A TLS peer, client or server, supplies the certificate. No credentials are needed, because the verify callback receives the peer certificate as an object even when verification has failed (src/internal.c:16320-16343). wolfSSL's example verify callback prints the one-line subject and issuer of such a certificate (wolfssl/test.h:2740-2749).
  • For the NUL case, the application uses the one-line string to show or record who the peer is.

Impact

Confirmed from source: the returned string contains CR, LF and other control bytes of the subject or issuer attribute values, and it ends at the first NUL byte in a value. With CR or LF, an application that writes the string into line-based output writes a line whose content the certificate author chose. With a NUL, the string shows only the part of the name before the NUL; later attributes are missing from it. The total length is bounded by the size of the display string buffer.

Not verified: the effect on any particular application or log consumer, and whether any application makes access decisions from the one-line string.

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). Master has changed how the display string is built: PR 11627, merged 2026-11-18, writes a NUL byte inside a value as the four characters \x00, and commit 16ffaad4fe2d4e72fde8688b9537574332b5c8e6 puts a backslash before /, + and \ in values. That closes the truncation. CR, LF and other control characters are still copied unchanged. None of these changes is in a release.

A complete fix would escape bytes below 0x20 and 0x7F when the display string is built, in the same place where NUL is now handled.

Until then: treat the result of wolfSSL_X509_NAME_oneline() as untrusted text. Escape or reject control characters before writing it to a log or terminal. Where the build has the OpenSSL compatibility layer, wolfSSL_X509_NAME_print_ex() with XN_FLAG_RFC2253 escapes control characters in 5.9.4.

Separator characters in the same string are covered by BYTERAY-2026-0449. Control characters in the names printed by the certificate text dump are covered by BYTERAY-2026-0351.

Timeline

  • 2026-09-28 — Reported to wolfSSL.
  • 2026-10-01 — Pull request 11627 opened upstream.
  • 2026-11-18 — Pull request 11627 merged to master; an embedded NUL is now written as an escape sequence.
  • 2026-12-03 — Public disclosure.

Credits

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

References