-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wolfSSL X509_STORE use after free due to CA caching #14278
Comments
If I read the wolfSSL code corectly, this depends on OPENSSL_EXTRA defined in the wolfSSL build? Our CI jobs seem to build wolfSSL always with Have you built wolfSSL yourself? Can you check if |
This patch fixes the issue:
@bagder - should I make a PR? |
I'm not building it from configure / make, in any case this can be resolved by creating a X509_STORE right after creating SSL_CTX so the store is always dynamic, alternatively we can do this right before calling |
I think a PR would be great, if it preserves the sharing. If you are not sure, I can have a go at it later. |
When sharing the x509 store in wolfSSL, always use an explicitly constructed one, as the SSLCTX might have "only" an internal one which is not obeying reference count lifetimes. - refs curl#14278
Please see #14279 for my proposed fix. Would be nice if you could verify. Thanks. |
Yeah, that works |
QQ: How does this suppose to work in the presence of |
Good point. I think this is currently not really defined and needs some thought. First of all, I think my wolfssl PR needs to trigger the x509 setup if a CURLOPT_SSL_CTX_FUNCTION is set. The openssl backend does the same. This has been missing. Second, some users might not want to manipulate the store, but other things in the SSLCTX. Other users might want to override the store for just this one transfer, so sharing should not happen. The safe thing is to auto-disable sharing when CURLOPT_SSL_CTX_FUNCTION is set, I believe. OTOH, overriding things in the callback that can be set via |
@bagder, feel free to chime in here when you return from your vacation. |
It is enough to just set CURLOPT_CAINFO to trigger this bug, the ssl ctx thing is just a possible issue I thought of. But yeah, I agree that ssl ctx callback should disable caching as we have no control of what the callback will do or add a CURLOPT_SSL_CTX_CALLBACK_WILL_NOT_MODIFY_X509_STORE |
I think this makes sense. Users using the ctx callback sort of take more charge over the handshake and we should then probably not complicate those further by doing caching as well. |
Yeah, this thing also got broken in 8.9.0 as the ssl ctx callback I was setting wasn't getting called (it's a separate issue I got in a different program - we use libcurl in a bunch of apps). @icing - In your diff stack we also require:
|
I did this
Tried upgrading curl to 8.9.0 which triggered a use-after-free bug in wolfssl X509_STORE caching code (added in 80aa519):
The issue here being that X509_STORE in question is actually embedded in wolfSSL_CTX here as we get it from wolfSSL_CTX_get_cert_store here.
The point here is that we need to check whether
WOLFSSL_X509_STORE->isDynamic == TRUE
before we can do this (isDynamic is defined here but is under an ifdef). In any case, is it possible to disable this CA caching thing via some API call?I expected the following
No response
curl/libcurl version
curl 8.9.0 with wolfSSL
operating system
Linux
The text was updated successfully, but these errors were encountered: