Skip to content
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

Minerva attack on power PC architecture #24253

Open
GeorgePantelakis opened this issue Apr 24, 2024 · 10 comments
Open

Minerva attack on power PC architecture #24253

GeorgePantelakis opened this issue Apr 24, 2024 · 10 comments
Labels
branch: master Merge to master branch branch: 3.0 Merge to openssl-3.0 branch branch: 3.1 Merge to openssl-3.1 branch: 3.2 Merge to openssl-3.2 branch: 3.3 Merge to openssl-3.3 help wanted triaged: bug The issue/pr is/fixes a bug

Comments

@GeorgePantelakis
Copy link

GeorgePantelakis commented Apr 24, 2024

@tomato42 and I have tested OpenSSL in power PC architecture and we found that it may be vulnerable to a variant of the Minerva attack. We used statistical analysis to confirm the presence of side channels but we did not perform the Minerva attack against the implementation.

In the test scenario, we measure the time of signing of random messages using the EVP_DigestSign API (Init, Update, and Final) and then use the private key to extract the K value (nonce) from the signatures. Then based on the bit size of the extracted nonce we compare the signing time of full-sized nonces to signatures that used smaller nonces using statistical tests.

In our initial test, we found a side-channel in P-364 curve. The P-256 and P-521 curves are, most likely, safe. In these results we can see a clear leak: there is a dependency between the bit size of K and the size of the side channel.

For the non-deterministic path of the code:
conf_interval_plot_all_k_sizes_trim_mean_45_0-10
Results for P-256. Skilling-Mack test p-value: 1.676327e-01. The sample tested has 583,024,459 observations.

conf_interval_plot_all_k_sizes_trim_mean_45_0-10
Results for P-384. Skilling-Mack test p-value: 1.802425e-74. The sample tested has 615,444,376 observations.

conf_interval_plot_all_k_sizes_trim_mean_45_0-10
Results for P-521. Skilling-Mack test p-value: 8.632069e-01. The sample tested has 485,866,172 observations.

For the deterministic path of the code:
conf_interval_plot_all_k_sizes_trim_mean_45_0-10
Results for P-256. Skilling-Mack test p-value: 7.604963e-02. The sample tested has 388,704,249 observations.

conf_interval_plot_all_k_sizes_trim_mean_45_0-10
Results for P-384. Skilling-Mack test p-value: 1.201069e-15. The sample tested has 323,911,655 observations.

conf_interval_plot_all_k_sizes_trim_mean_45_0-10
Results for P-521. Skilling-Mack test p-value: 4.801629e-01. The sample tested has 550,642,703 observations.

@GeorgePantelakis GeorgePantelakis added the issue: bug report The issue was opened to report a bug label Apr 24, 2024
@GeorgePantelakis GeorgePantelakis changed the title Minerva attack in power PC architecture Minerva attack on power PC architecture Apr 24, 2024
@t8m t8m added branch: master Merge to master branch help wanted triaged: bug The issue/pr is/fixes a bug branch: 3.0 Merge to openssl-3.0 branch branch: 3.1 Merge to openssl-3.1 branch: 3.2 Merge to openssl-3.2 branch: 3.3 Merge to openssl-3.3 and removed issue: bug report The issue was opened to report a bug labels Apr 24, 2024
@gcwilson
Copy link

gcwilson commented May 1, 2024

Hi @t8m. Thanks to you, @tomato42, and @GeorgePantelakis for this issue. Jaroslav Reznik brought this matter to our attention. So some questions. Are you looking for help from the IBM PPC crypto team? Is this problem specific to the new P-384 implementation? Do have already have recommendations on how we should modify the ppc64/ppc64le code? How can we test for this problem in house?

@tomato42
Copy link
Contributor

tomato42 commented May 1, 2024

Are you looking for help from the IBM PPC crypto team?

yes, we don't have resources to fix it ourselves

Is this problem specific to the new P-384 implementation?

Probably, George will be able to say if any particular method is being called or not if you tell him what to look for

Do have already have recommendations on how we should modify the ppc64/ppc64le code?

No. Though at this point, the most likely reason for this leakage is a short-circuit in the scalar multiplication loop

How can we test for this problem in house?

You'll need to contact George for a the test harness and instructions how to execute it.

@gcwilson
Copy link

gcwilson commented May 7, 2024

Hi @GeorgePantelakis. Can you help with some of the questions above? Is the matter all contained to the new P-384 implementation? How can we obtain the test harness?

@davidben
Copy link
Contributor

davidben commented May 7, 2024

While not an exact match, valgrind's rules for uninitialized memory are very close to the constant-time computational model. For BoringSSL, we've found it very valuable for flagging non-constant-time code. It takes a bit of work, marking the right data is "secret" (uninitialized) and then "declassifying" (marking initialized) the right data at the right points. But it may help you all pinpoint the problem.

@GeorgePantelakis
Copy link
Author

Hello @gcwilson. Sorry for the big delay. To answer some of the questions. I do not know if it is the new implementation, we used the code for HEAD on 2024-04-16. As @tomato42 said if you tell me a specific function, I can search if it is called. Now for the test harness, sure, we will create tomorrow a toolkit so you can easily test it yourself. If there is anything else feel free to ask.

@beldmit
Copy link
Member

beldmit commented May 8, 2024

@davidben could you please provide more details?

@davidben
Copy link
Contributor

davidben commented May 8, 2024

Sure. Just tell valgrind that the secret data is "uninitialized". Then when you intentionally branch on or otherwise reveal data that is now public, you need to mark it "initialized" first.
https://boringssl.googlesource.com/boringssl/+/6ab7c1482bf4cdc91c87bc512aaf68ffb18975ec/crypto/internal.h#568

Valgrind will then do data flow analysis and flag when you index or branch based on "uninitialized" memory.

@glengillman
Copy link

glengillman commented May 8, 2024 via email

@beldmit
Copy link
Member

beldmit commented May 8, 2024

Just tell valgrind that the secret data is "uninitialized". Then when you intentionally branch on or otherwise reveal data that is now public, you need to mark it "initialized" first.

Nice trick!

@GeorgePantelakis
Copy link
Author

@gcwilson, we have created a toolkit for Minerva. For now, it has only OpenSSL in it. You can find it at https://github.com/GeorgePantelakis/minerva-toolkit. For any questions or issues feel free to reach us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
branch: master Merge to master branch branch: 3.0 Merge to openssl-3.0 branch branch: 3.1 Merge to openssl-3.1 branch: 3.2 Merge to openssl-3.2 branch: 3.3 Merge to openssl-3.3 help wanted triaged: bug The issue/pr is/fixes a bug
Projects
None yet
Development

No branches or pull requests

7 participants