← ALL ADVISORIES

LOW BYTERAY-2026-0449Disclosed

wolfSSL — Delimiter Injection in X509_NAME_oneline Distinguished Name Output

wolfSSL builds the one-line form of a certificate name by joining fields with "/" and "=" and copies each value from the certificate unescaped. wolfSSL_X509_NAME_oneline returns that string as it is, so a value containing "/", "=" or a NUL makes the name show fields that are not in the certificate or end early.

Advisory
BYTERAY-2026-0449
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 that provide wolfSSL_X509_NAME_oneline (KEEP_PEER_CERT, SESSION_CERTS, OPENSSL_EXTRA or OPENSSL_EXTRA_X509_SMALL) whose application parses the returned string field by field
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

wolfSSL keeps a display string for each certificate subject and issuer in the form /C=US/O=Example/CN=host.example.com. wolfSSL_X509_NAME_oneline() returns that string to the application.

Two code paths build the string, one in the certificate decoder and one in the OpenSSL compatibility layer. Both copy the attribute values from the certificate as raw bytes. Neither escapes the / that separates fields or the = that separates a type from its value. A certificate whose common name is evil.com/OU=Trusted CA is rendered as /CN=evil.com/OU=Trusted CA, which reads as a common name followed by an organisational unit. A NUL byte in a value ends the stored string at that point.

An application that splits this string into fields, for example to extract the common name or to match name components against a list, can be shown fields the issuer never encoded. Inside wolfSSL the string is compared only as a whole or written to logs, so the exposure there is misleading display and log content. The decoder path is the one used without the compatibility layer; the getter itself is compiled only when one of the build options listed below is set.

Affected Products and Versions

  • Component: src/x509.c, wolfSSL_X509_NAME_oneline(). The string is built in GetRDN() in wolfcrypt/src/asn.c and in AddAllEntry() in src/x509.c.
  • Required build: any of KEEP_PEER_CERT, SESSION_CERTS, OPENSSL_EXTRA or OPENSSL_EXTRA_X509_SMALL (src/x509.c:3915-3916). Required use: an application that parses the returned /type=value string field by field. No such consumer exists in the wolfSSL tree.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • Other releases were not checked.

Technical Details

wolfSSL_X509_NAME_oneline() (src/x509.c:3921-3956) limits the copy to the caller's buffer and copies name->name out (src/x509.c:3952-3953):

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

The size clamp at src/x509.c:3947 prevents an overrun. It does not change the content. The content is produced earlier, on one of two paths:

  1. Decoder path, build. GetRDN() appends the type string and then the value bytes to the display buffer (wolfcrypt/src/asn.c:15569-15572). The comment above the copy says binary values are copied verbatim and that the display string may truncate at an embedded NUL.
  2. Decoder path, store. CopyDecodedName() copies the decoded subject or issuer string into name->name and takes its size with XSTRLEN() (src/internal.c:15175-15187). An embedded NUL therefore shortens both the stored name and its recorded size.
  3. Compatibility path. Under OPENSSL_EXTRA, AddAllEntry() writes /, the short name, = and then the entry's value bytes (src/x509.c:14716-14727). The result becomes name->name.
  4. On either path, wolfSSL_X509_NAME_oneline() returns the string to the application.

No step escapes /, =, NUL, CR or LF. The library has an RFC 2253 escaper, wolfssl_x509_name_esc_value() (src/x509.c:15617-15672), but it is used only by wolfSSL_X509_NAME_print_ex() (src/x509.c:15700).

The consumers inside wolfSSL bound the impact. wolfSSL_X509_check_issued() compares the size and then the full bytes of the two names (src/x509.c:16386-16387). A whole-string comparison of that kind cannot be turned into a false match by adding delimiters. The remaining uses in the tree display or log the string.

Reachability and Preconditions

  • A build that includes wolfSSL_X509_NAME_oneline().
  • The application calls it on the subject or issuer of a certificate it received and parses the result by splitting on / and =.
  • The attacker presents a certificate with a chosen attribute value, as a TLS server or as a client in mutual TLS. If the application renders the name only after chain verification, the attacker needs a certificate from an accepted CA that carries the value. If it renders names of unverified certificates, any certificate works.
  • No other privilege is needed.

Impact

The returned name can contain /type=value components that the certificate does not have as separate fields, and it can stop at a point the certificate's author chose. An application that extracts fields from it can be misled about the common name or other components, and logs or audit records can show a name that differs from the certificate. Whole-name comparisons inside wolfSSL are not affected. 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 values wherever the display string is built, in GetRDN() and in AddAllEntry(), or in wolfSSL_X509_NAME_oneline() before the copy. The existing escaper can be extended to this format so that it also covers /, =, NUL, CR and LF. The stored size should come from an explicit byte count and not from XSTRLEN(), so that an embedded NUL does not shorten the name. Applications should not split the one-line string to make decisions. Read individual entries with wolfSSL_X509_NAME_get_entry() where the build provides it, and sanitise names before logging them.

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.

References