Disable PKCS#1 v1.5 padding#58
Conversation
|
This breaks padding for RSA signatures, which do not support OAEP padding but only PSS padding for a modern and safe padding mode, excerpt from openssl's RSA signature implementation: case RSA_PKCS1_OAEP_PADDING:
/*
* OAEP padding is for asymmetric cipher only so is not compatible
* with signature use.
*/
err_extra_text = "OAEP padding not allowed for signing / verifying";
goto bad_pad;I think also that might be the underlying reason for what resulted in the pre-existing FIXME comment added in PR #53 combined with ignoring result from the calling set_rsa_padding, i.e.: Lines 972 to 973 in dbf24f4 Lines 1029 to 1030 in dbf24f4 As yes, trying to set padding modes for an operation that just cannot support them will return an error, nothing really unexpected here. Note, that this also means that the legacy PKCS1 padding will actually be used, as that is still the default in openssl, so failing to set it here will keep that default active, which makes this even more confusing for users. That "not checking the result" pattern on setting the padding–introduced in #53–is also very problematic, especially as openssl has an error stack, so if setting the padding fails the next operation that actually checks the error stack might get confused. Our application does that, and as it's async we got sporadic errors in a completely unrelated part not using any of this module for errors that very much got caused by this module. Besides, while I can see the good intentions behind this and making default behavior more secure, I find it highly questionable to straight out croak when one tries to use the older mode. What should one do if they need to verify older signatures? Or worse, decrypt data that was encrypted with an old version of this library? Sorry to be a bit grumpy here, but we had some rather hard to trivial debug fallout from both, the new default and the pre-existing missing error checking, and looking at issue #61 it seems that we're not the only ones. IMO, the steps to improvement might look like:
A colleague of mine actually looked into this already, see the three commits on top of: We will roll out parts of above points for a downstream build to fix using one of our core HTTP API daemons. |
|
At the time we were unable to find a way to protect against the marvin attack. I am away this week but I would be happy to review and test the marvin attack scripts against any PR you might generate. I will review the branch you mentioned. I do agree disabling the padding mode completely is sub-optimal. |
Take a look at the pod info. Happy to revise ...