Skip to content
Crypto Disclosed report Advanced CVE-2026-82208

CVE-2026-82208: wolfSSL CA-cache hit overrides callback

When curl uses the wolfSSL backend with CA caching enabled, a callback that replaces the trust store can be silently overridden by the cached store being reinstalled. An attacker with a certificate trusted by the cached store but rejected by the callback's store can then impersonate the server.

giant_anteater Follow

Originally disclosed on HackerOne

  • Triaged in 22 hours
  • Fixed in 6 days
  • Disclosed after 7 days

Summary

With the wolfSSL backend, when CA caching is enabled and an CURLOPT_SSL_CTX_FUNCTION callback replaces the trust store, curl can silently reinstall the cached store after the callback returns. A certificate trusted by the cached store but rejected by the callback-selected store is then incorrectly accepted.

Root cause

Curl_wssl_setup_x509_store() in lib/vtls/wolfssl.c installs a cached X509 store but does not set wssl->x509_store_setup = TRUE. That flag is only set inside wssl_populate_x509_store(), which runs on cache misses.

The sequence on a cache hit:

  1. Before invoking the callback, wssl_connect_step1() calls Curl_wssl_setup_x509_store() — cached store A is installed, flag stays false.
  2. The CURLOPT_SSL_CTX_FUNCTION callback runs and replaces store A with store B.
  3. During the handshake, the still-false flag causes Curl_wssl_setup_x509_store() to run again. It finds CTX_get_cert_store() != cached_store (the callback changed it), so it reinstalls cached store A.

Affected versions

Introduced in commit 0f2876b2c33f (Jul 2024, "wolfSSL: CA store share fix" for #14278). Present in releases 8.9.1 through 8.21.0.

Impact

An application that uses CURLOPT_SSL_CTX_FUNCTION to restrict trust (e.g. pin to a private CA) has that restriction silently bypassed when CA caching is active. A MITM presenting a certificate valid under the cached store but rejected by the callback's store succeeds.

Prerequisites: wolfSSL backend, CURLOPT_CA_CACHE_TIMEOUT != 0, a callback that replaces the store, and differing trust between the two stores.

Reproduction

  1. Build an affected curl release (8.9.1 through 8.21.0) against wolfSSL and configure curl without a compiled-in default CA path so that a CA file is eligible for caching.
  2. Create two independent certificate authorities, called CA A and CA B.
  3. Create a TLS server certificate for the test hostname, including a matching subject alternative name, and sign it with CA A.
  4. Start an HTTPS server on the test hostname using that certificate.
  5. Write a small libcurl client that uses the same multi handle for two transfers, sets CURLOPT_CAINFO to CA A, and sets a nonzero CURLOPT_CA_CACHE_TIMEOUT.
  6. Make the first transfer without an SSL-context callback. Confirm that it succeeds and thereby populates curl's CA cache with the trust store containing CA A.
  7. For the second transfer, use a fresh connection and register CURLOPT_SSL_CTX_FUNCTION. In the callback, replace the wolfSSL context's certificate store with a newly created store containing only CA B.
  8. Disable connection reuse and TLS session caching for both transfers so that the second transfer performs a new TLS handshake and certificate verification.
  9. Make the second transfer to the same HTTPS server. On a vulnerable build, it incorrectly succeeds even though the callback-selected store contains only CA B and the server certificate chains only to CA A.
  10. Repeat the sequence with CURLOPT_CA_CACHE_TIMEOUT set to zero. The second transfer should now fail certificate verification, demonstrating that the unexpected acceptance depends on the CA-cache path.
  11. As a fixed-version check, repeat the cached sequence on a build containing commit ed0338befd or a later release. The second transfer should fail because curl no longer reinstalls CA A after the callback selects CA B.

The callback-selected trust store must remain authoritative. The transfer using store B should reject the server certificate regardless of whether curl's CA cache was previously populated.

Suggested fix

Set wssl->x509_store_setup = TRUE in Curl_wssl_setup_x509_store() itself (before returning), rather than only inside wssl_populate_x509_store(). This ensures the flag is set on both cache hits and misses, preventing the second invocation from overwriting the callback's store.

Impact

Summary:

An attacker able to present a hostname-valid certificate trusted by curl’s cached CA store—but rejected by the application-selected store—can impersonate the intended TLS endpoint. This bypasses the application’s trust policy and may allow interception or modification of encrypted traffic.

The original report as published on HackerOne, by giant_anteater. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Curl_wssl_setup_x509_store() installs a cached X509 store without setting wssl->x509_store_setup = TRUE, so the setup runs again during the handshake and reinstalls the cached store over the callback's store.

Impact

An application that uses the callback to restrict trust has that restriction bypassed when CA caching is active, so a man-in-the-middle with a certificate valid under the cached store but rejected by the callback's store could intercept or modify encrypted traffic.

What the attacker needed

WolfSSL backend; CA caching enabled (timeout nonzero); callback replaces the trust store; stores differ in trust

The fix

The flag should be set inside Curl_wssl_setup_x509_store() itself so it is set on both cache hits and misses, and the text notes a build containing commit ed0338befd or a later release no longer reinstalls the cached store.

How it was found

  1. Build an affected curl release against wolfSSL without a compiled-in default CA path so a CA file can be cached.
  2. Create two independent certificate authorities, CA A and CA B.
  3. Create a TLS server certificate for the test hostname signed by CA A and start an HTTPS server with it.
  4. Write a libcurl client using one multi handle, CURLOPT_CAINFO set to CA A and a nonzero CURLOPT_CA_CACHE_TIMEOUT.
  5. Make a first transfer without an SSL-context callback to populate the CA cache with CA A.
  6. Make a second transfer on a fresh connection with a callback that replaces the store with one containing only CA B, and observe it incorrectly succeeds.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

curl is a tool for downloading things over the internet, and it can be told to trust only certain certificate authorities (organisations that vouch for websites). A callback is a small piece of code the application supplies to swap that trust list. Because of a flag that was not set, curl put the old trust list back after the callback ran, so a certificate the application meant to reject was accepted.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More by giant_anteater

View all

93 more disclosed reports, best first.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.