You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RSA implementation in FIPS module not thread safe #4180
I have a server application in which a global SSL_CTX is used by multiple threads for creating SSL session objects. The session establishment fails randomly when FIPS mode is turned on. I debugged the issue and found that the problem is happening because the RSA key associated with the SSL_CTX object is being used by multiple threads and the RSA decryption functionality is not thread safe. I have attached sample code to reproduce this failure. rsa-op.cpp.txt
My understanding from the original post was that SSL_CTX was used in multiple threads (not SSL). This is allowed.
That is correct.
no, you are using an SSL object in multiple threads and that is also not allowed
The attached code is a simplified version of the original code I am attaching below. The SSL object is not shared between threads. A global SSL_CTX object is used to create multiple SSL objects by different threads. And I have defined locking callbacks using CRYPTO_set_locking_callback(). ssl-server-rsa.cpp.txt
Also note that neither of these sample codes fail when FIPS mode is off.
It's not entirely clear to me that this is a problem in the FIPS module. Where is the locking supposed to be happening here? In libssl or in the RSA implementation? I would have expected the former rather than the latter. If so then its not a bug in the FIPS module and can be fixed. If it is a bug in the FIPS module then you're right and we can't fix it. But until we establish that I think it should remain open.
Though just because something fails in FIPS mode doesn't necessarily mean it is a bug in the FIPS module: it could be in the glue code in OpenSSL that uses the FIPS module. Even if it is a bug in the FIPS module itself there may be a way to work around it in the glue code without modifying the FIPS module.
Right looks like the FIPS thread ID callback isn't being set. If the deprecated CRYPTO_set_id_callback() function is used then everything works as expected.
I think it's down to the fact that the defaults often work as does the deprecated id callback: it was only the newer interface that wasn't passed through.
Activity
richsalz commentedon Aug 17, 2017
yes. most OpenSSL objects are not designed for concurrent use in multiple threads.
and also this is FIPS code which we cannot change.
Sorry, closing the issue.
srahul123 commentedon Aug 17, 2017
I just want to point out that this is not a case of incorrect usage of OpenSSL API. TLS handshake is failing because of this bug.
I get that
richsalz commentedon Aug 17, 2017
no, you are using an SSL object in multiple threads and that is also not allowed
mattcaswell commentedon Aug 17, 2017
My understanding from the original post was that SSL_CTX was used in multiple threads (not SSL). This is allowed.
srahul123 commentedon Aug 17, 2017
That is correct.
The attached code is a simplified version of the original code I am attaching below. The SSL object is not shared between threads. A global SSL_CTX object is used to create multiple SSL objects by different threads. And I have defined locking callbacks using CRYPTO_set_locking_callback().
ssl-server-rsa.cpp.txt
Also note that neither of these sample codes fail when FIPS mode is off.
richsalz commentedon Aug 17, 2017
So this fails in FIPS which cannot be changed. Why is this re-opened?
mattcaswell commentedon Aug 17, 2017
It's not entirely clear to me that this is a problem in the FIPS module. Where is the locking supposed to be happening here? In libssl or in the RSA implementation? I would have expected the former rather than the latter. If so then its not a bug in the FIPS module and can be fixed. If it is a bug in the FIPS module then you're right and we can't fix it. But until we establish that I think it should remain open.
richsalz commentedon Aug 17, 2017
From the original poster: "Also note that neither of these sample codes fail when FIPS mode is off."
snhenson commentedon Aug 18, 2017
Though just because something fails in FIPS mode doesn't necessarily mean it is a bug in the FIPS module: it could be in the glue code in OpenSSL that uses the FIPS module. Even if it is a bug in the FIPS module itself there may be a way to work around it in the glue code without modifying the FIPS module.
It isn't obvious which is the case here though.
Set FIPS thread id callback.
snhenson commentedon Aug 18, 2017
Right looks like the FIPS thread ID callback isn't being set. If the deprecated CRYPTO_set_id_callback() function is used then everything works as expected.
#4192 should fix it.
Set FIPS thread id callback.
mattcaswell commentedon Aug 18, 2017
It amazes me that this hasn't been discovered before.
snhenson commentedon Aug 18, 2017
I think it's down to the fact that the defaults often work as does the deprecated id callback: it was only the newer interface that wasn't passed through.