-
-
Notifications
You must be signed in to change notification settings - Fork 765
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
rust-openssl is vulnerable to the Marvin Attack #2171
Comments
This crate is a fairly minimal wrapper around OpenSSL. I'm not sure there's any way to branchless-ly handle the OpenSSL error stack. As a result, I'm not sure it makes sense to consider this project as impacted, or not. Rather the underlying OpenSSL that is used is either impacted or not. |
there is:
unfortunately no, I've tested openssl extensively, and the OpenSSL API can be used safely, it's just very hard and unintuitive to do |
|
and you base this statement on what? because I have tested it and verified that it is not |
If you think this comment in openssl is incorrect, feel free to raise an issue in openssl project: https://github.com/openssl/openssl/blob/master/crypto/rsa/rsa_pk1.c#L266-L272 but I have verified that the ERR_pop_to_mark doesn't have a side-channel leakage that depends on PKCS#1 padding being correct or not. If you don't believe me, feel free to either test, or debug it yourself. I don't have time to do it myself and explain line by line why it's not leaky, sorry. |
CVE-2024-3296 has been assigned for this issue. |
I understand a proof of concept has not yet been demonstrated for this issue, so its existence is still disputed. As such no version with a fix has been published. I believe the best next step is to wire up this function to the marvin-toolkit test suite, and the test harness for rust-crypto could serve as an example. |
@Shnatsel yes, if somebody would create a test harness for rust-openssl, I should be able to rather quickly run it and provide conclusive evidence for existence of leakage. |
This is unambiguously a problem in OpenSSL, and has apparently been fixed since 3.2.0:
|
@sfackler it's not a problem in OpenSSL. If you use OpenSSL 3.2 with a PKCS#11 module you still have a problem |
Surely that's a problem in the PKCS#11 module then? As I've expressed before, this problem cannot be properly solved external to OpenSSL, because all of these APIs involving manipulating the error stack, for which there are no constant time APIs. |
You have provided no evidence what so ever that this is actually happening. I have tested it in practice, and have found that openssl does manipulate error stack in a way that is safe. So, it being an issue in applications that call the API is not just my opinion about it, it's also OpenSSL's official stance. |
Notwithstanding your inability to measure it, the branches exist. If the standard is "can it be measured", that's fine. But no one has measured this issue with rust-openssl! |
@alex in fairness every other user like rust-openssl we measured does show a leak, I do not think there are rel doubts we can show it. |
if a branch does not depend on secret data, then it does not matter. The standard is not "can it be measured", as I'm measuring it to precision of individual clock cycles. If I see that there is no data dependence larger than 0.2 ns and I'm running the test on a machine with a 2GHz CPU, then there is no side-channel leakage. |
My view is that the point of fixing this in OpenSSL was to avoid every single consumer needing to attempt to mitigate it. That's the approach we took in pyca/cryptography, and IMO it's the only reasonable approach for a general purpose cryptography library. I do not understand why that's insufficient. |
Then your view is incorrect. That's not why I proposed the fix. The reason why I proposed the fix was to protect as many users as possible with reasonable amount of effort.
pyca/cryptography recognised it as a bug in pyca/cryptography, with the design of the API being the cause of the issue, and documented the API as insecure I see no attempt to do the same here. |
I'd personally be fine documenting that PKCS1v15 decryption may be vulnerable to timing variability, and that no one should use PKCS1v15 encryption/decryption in 2024. |
I'd be ok with the fix being "document the API as insecure, with recommendation against its use, and recommendation to use OpenSSL with implicit rejection as a workaround for deployments that absolutely require support for PKCS#1v1.5 decryption still" |
The API can also be marked as deprecated so that a warning about it is surfaced to the API users. |
We are not deprecating EVP_Decrypt. That is what literally all EVP-based decryption with any key/padding type use. |
@Shnatsel if you use it for OAEP then it's fine, it's the PKCS#1v1.5 decryption that's problematic |
Is there a way to warn users of the PKCS#1v1.5 alone? Perhaps a |
I'm pretty sure that PKCS#1v1.5 is the default (it is for the openssl itself) |
There's a small subtly, which is that PKCS1v15 is usable for signing and
encryption, and this issue is only relevant to the encryption use case.
…On Fri, Apr 5, 2024 at 1:29 PM Shnatsel ***@***.***> wrote:
Is there a way to warn users of the PKCS#1v1.5 alone? Perhaps a
#[deprecated] attribute on the Padding enum variant? Rust reference
<https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-deprecated-attribute>
states that #[deprecated] can be applied to enum variants.
—
Reply to this email directly, view it on GitHub
<#2171 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAAGBCM7BYJX2OSVXLJHLDY33NQJAVCNFSM6AAAAABDIHJKUWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBQGMYDKNRQHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
All that is necessary for evil to succeed is for good people to do nothing.
|
I suppose a |
The goal of this crate is to implement direct, memory safe bindings to OpenSSL APIs. Some of those APIs are poorly designed, but that is frankly OpenSSL's problem, not my problem. |
I've proposed changes to the OpenSSL documentation to make some of my statements here part of official documentation: openssl/openssl#24159 |
I've reviewed the code responsible for doing RSA PKCS#1v1.5 decryption:
rust-openssl/openssl/src/encrypt.rs
Lines 440 to 453 in a644ec2
and I'm pretty sure that it is vulnerable to the Marvin Attack as it will perform a jump/branch based on the error value returned from OpenSSL.
If you'd like to perform actual test for the leakage (to confirm the review and measure the size of the side-channel), I can run the test, but I'd like to ask for help in writing a test harness. Example test harnesses are available in the marvin-toolkit repo, the one for rust-crypto would most likely be the easiest one to adapt for this package.
May I also ask for assigning a CVE to this issue? As a repo owner you can create a security issue here in github and ask for a CVE assignment.
The text was updated successfully, but these errors were encountered: