← ALL ADVISORIES

MEDIUM BYTERAY-2026-0373Disclosed

wolfSSL — CRLF Injection in HTTP Request Builder via Method, Content-Type and Extra Headers

The wolfSSL HTTP request builder rejects CR and LF in the path and host but not in the method, the Content-Type value or the extra headers. An application that forwards untrusted data into the exported wolfIO_HttpBuildRequest can be made to send injected request lines and headers.

Advisory
BYTERAY-2026-0373
CWE
CWE-148
CVSS
5.0 (CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:L)
Vendor
wolfSSL
Product
wolfSSL
Reported
2026-09-28
Disclosure
2026-12-03
Affected
wolfSSL 5.9.2 (tested at master commit d95483f), builds with the HTTP client (HAVE_HTTP_CLIENT) where an application passes untrusted data to wolfIO_HttpBuildRequest
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

wolfIO_HttpBuildRequest_ex() in src/wolfio.c assembles the HTTP requests wolfSSL sends for OCSP and CRL lookups. It takes five caller-supplied strings: the method, the host, the path, the Content-Type value and optional extra headers.

The function refuses to build a request when the path or the host contains a carriage return or a line feed. It applies no such check to the method, the Content-Type value or the extra headers. Those three are copied into the request between fixed protocol tokens. A CR or LF in any of them ends the current line, and the rest of the string continues as new request lines or headers.

wolfSSL's own callers pass constant strings for the three unchecked fields, so the library on its own is not exposed. The exported wrapper wolfIO_HttpBuildRequest() forwards the method and the Content-Type unchanged. An application that passes data it does not control into those arguments, for example a proxy that forwards a client's method or Content-Type, can be made to send a split or smuggled request.

Affected Products and Versions

  • Component: src/wolfio.c, wolfIO_HttpBuildRequest_ex() and the exported wrapper wolfIO_HttpBuildRequest().
  • Required build: the wolfSSL HTTP client (HAVE_HTTP_CLIENT). No other build option gates the code.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • In a build of wolfSSL alone, every caller of the builder passes string literals for the unchecked fields. The issue is reachable only through an application that calls the exported wrapper with untrusted reqType or contentType. Other releases were not checked.

Technical Details

The delimiter check covers two of the five strings (src/wolfio.c:2143-2146):

    if (wolfIO_UrlHasCrlf(path, pathLen) ||
            wolfIO_UrlHasCrlf(domainName, (int)domainNameLen)) {
        return 0;
    }

The entry checks before it are NULL-pointer and length checks (src/wolfio.c:2130-2134). The only check after it compares the total length with the buffer size (src/wolfio.c:2164-2181). Neither looks at the content of reqType, contentType or exHdrs.

How the unchecked strings reach the wire:

  1. wolfIO_HttpBuildRequest() is declared WOLFSSL_API (wolfssl/wolfio.h:803). It forwards reqType and contentType unchanged and fixes exHdrs to an empty string (src/wolfio.c:2091-2096). The variant that takes exHdrs is WOLFSSL_LOCAL (wolfssl/wolfio.h:806).
  2. reqType is copied to the start of the buffer and becomes the head of the request line (src/wolfio.c:2183).
  3. contentType is copied after the fixed "\r\nContent-Type: " token (src/wolfio.c:2206-2210).
  4. exHdrs is copied after a bare "\r\n" (src/wolfio.c:2212-2219), ahead of the closing blank line (src/wolfio.c:2221).
  5. The finished buffer is sent with wolfIO_Send() and is not inspected again (src/wolfio.c:2534 for OCSP, src/wolfio.c:2637 for CRL).

The in-tree callers are not a vector. wolfIO_HttpBuildRequestOcsp() passes "POST", "application/ocsp-request" and a literal cache-control header (src/wolfio.c:2239-2240). wolfIO_HttpBuildRequestCrl() passes "GET", an empty Content-Type and the same literal header (src/wolfio.c:2574-2575). URLs taken from certificates go only into the path and host, which are checked here and again in wolfIO_DecodeUrl() (src/wolfio.c:1715-1716).

The API documentation states no character restriction for reqType or contentType (doc/dox_comments/header_files/wolfio.h:1178-1207). The tests cover CR and LF rejection for the path and host only (tests/api/test_ocsp.c:2882-2894). The OpenSSL-compatible OCSP request code in the same library checks every interpolated field for CR and LF (src/ocsp.c:1778-1862).

Reachability and Preconditions

  • Build: HAVE_HTTP_CLIENT.
  • An application outside wolfSSL calls wolfIO_HttpBuildRequest() and places attacker-influenced data in reqType or contentType. A proxy or gateway that forwards an upstream client's HTTP method or Content-Type header is the realistic case.
  • Attacker position: a remote user of that application, with whatever access the application requires to submit the forwarded field. exHdrs cannot be reached through the exported wrapper. It is unchecked, but only library-internal callers supply it.

Impact

Under the preconditions above, the attacker ends a protocol line early and adds request lines or headers of their choice to the request the application sends. This is HTTP request splitting or smuggling toward whichever server the application contacts, sent from the application's network position. The consequences are cache poisoning and access-control bypass on intermediaries, and interference with OCSP or CRL responses where the application uses the builder for those. The impact depends on the application forwarding untrusted data. wolfSSL as shipped does not do so.

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 apply the existing CR/LF check to reqType, contentType and exHdrs as well, and to return 0 when any of them contains CR or LF, as the function already does for the path and host. The API documentation should state the restriction, and the tests should cover the three added fields. Workaround: applications that call wolfIO_HttpBuildRequest() should reject CR and LF in the method and Content-Type before the call, or pass only constants.

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