← ALL ADVISORIES

LOW BYTERAY-2026-0503Disclosed

wolfSSL — Time-of-Check to Time-of-Use Race in CRL Directory Loading

LoadCRL lists the CRL directory, accepts entries that were regular files at listing time, and later opens each one by name. The open follows symlinks and does not recheck the object. A local process with write access to the directory can make the loader read a file it never checked.

Advisory
BYTERAY-2026-0503
CWE
CWE-363
CVSS
3.6 (CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/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 with HAVE_CRL and filesystem and directory support, where the application loads CRLs from a directory or runs the CRL monitor
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

LoadCRL() loads every CRL file in a directory. It runs when the application calls wolfSSL_CertManagerLoadCRL() or one of its wrappers, and again on every directory change when the CRL monitor is enabled. For each entry it relies on a regular-file test made while the directory is listed, filters on the file name extension, and then hands the name to ProcessFile(), which opens it by name.

The regular-file test and the open are separate path resolutions. The test is a stat that follows symlinks, so a symlink to a file elsewhere passes it with no race. An entry can also be replaced between the listing and the open. In both cases the loader parses an object that was not the one it checked.

The effect is bounded. A process that can modify the CRL directory can already place a CRL there, and every CRL loaded on this path must pass issuer signature verification before it is installed. CRL support is not part of a default build.

Affected Products and Versions

  • Component: src/crl.c, LoadCRL().
  • Required build: HAVE_CRL, without NO_FILESYSTEM or NO_WOLFSSL_DIR (src/crl.c:2267). The reload path also needs HAVE_CRL_MONITOR.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • CRL support is off in a default ./configure build (configure.ac:9144-9148), so a default build does not include this code.
  • Other releases were not checked.

Technical Details

LoadCRL() walks the directory with wc_ReadDirFirst() and wc_ReadDirNext() (src/crl.c:2284, src/crl.c:2319). The directory reader returns a name only when wc_FileExists() succeeds on it (wolfcrypt/src/wc_port.c:1557). That is an XSTAT plus a regular-file test, and it describes the entry at the moment of the stat.

The loop then looks at the name string only (src/crl.c:2288-2298) and loads the entry (src/crl.c:2303-2304):

        if (!skip && ProcessFile(NULL, name, type, CRL_TYPE, NULL, 0, crl,
                                 VERIFY) != WOLFSSL_SUCCESS) {

Data flow:

  1. The application configures a CRL directory. wolfSSL_CertManagerLoadCRL() calls LoadCRL() (src/ssl_certman.c:2142). wolfSSL_LoadCRL() and wolfSSL_CTX_LoadCRL() reach the same call (src/ssl_api_crl_ocsp.c:157, src/ssl_api_crl_ocsp.c:332).
  2. The directory reader stats each entry and returns the names of regular files (wolfcrypt/src/wc_port.c:1557).
  3. The extension filter accepts .pem, or .der and .crl, by substring match on the name (src/crl.c:2288-2298).
  4. ProcessFile() is called with the name (src/crl.c:2303, or src/crl.c:2309 when load errors are reported). Earlier entries are fully loaded in between.
  5. The file is opened by name with XFOPEN(fname, "rb") (src/ssl_misc.c:485). There is no O_NOFOLLOW and no fstat on the opened file.
  6. The content is parsed as a CRL and added to the list used for revocation decisions.

With the monitor enabled, SwapLists() calls LoadCRL() again on every change notification (src/crl.c:1715, src/crl.c:1725). Each change the local process makes to the directory opens the window again. By default a failed entry is logged and skipped, and the function returns success (src/crl.c:2302-2306, src/crl.c:2324), so a failed load caused by tampering is not reported to the caller.

Reachability and Preconditions

  • Build with CRL support and directory loading, and an application that loads CRLs from a directory or enables the CRL monitor.
  • A local process with permission to write, rename or link in that directory, directly or through a shared or staging mount. No remote input selects the file names on this path.
  • For the race variant, the swap has to land between the directory listing and the open. The symlink variant needs no timing.

Impact

A local process can influence which CRL content reaches the parser and the revocation list. The content still has to verify against the issuer's signature (VERIFY at src/crl.c:2303-2304). A stale but validly signed CRL can be substituted. Switching an entry to an object that blocks on read can stall the loading thread. The race confers no capability beyond write access to the directory, which already permits the same end state.

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 bind the opened object to the checked one: open each entry by descriptor without following symlinks where supported, fstat the descriptor to confirm a regular file, and read from that descriptor. Symlinks should be rejected explicitly during enumeration. Load failures should be reported to the operator, and monitor-driven reloads can be rate limited. Issuer signature verification of loaded CRLs must stay in place. As a mitigation, make the CRL directory writable only by the identity that loads the CRLs.

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