Skip to content
Crypto Disclosed report Advanced CVE-2015-3193

BN_mod_exp may produce incorrect results on x86_64 (CVE-2015-3193)

A carry propagation bug in OpenSSL's x86_64 Montgomery squaring procedure could cause BN_mod_exp to produce incorrect results for certain inputs. This could potentially allow an attacker to recover private keys in Diffie-Hellman scenarios, though the attack is considered very difficult and requires online access to an unpatched system.

hanno Follow

Originally disclosed on HackerOne

Bounty$1,000 View original
  • Fixed in 5 hours
  • Paid in 5 hours
  • Disclosed after 8 days

Summary by the program

Severity: Moderate

There is a carry propagating bug in the x86_64 Montgomery squaring procedure. No EC algorithms are affected. Analysis suggests that attacks against RSA and DSA as a result of this defect would be very difficult to perform and are not believed likely. Attacks against DH are considered just feasible (although very difficult) because most of the work necessary to deduce information about a private key may be performed offline. The amount of resources required for such an attack would be very significant and likely only accessible to a limited number of attackers. An attacker would additionally need online access to an unpatched system using the target private key in a scenario with persistent DH parameters and a private key that is shared between multiple clients. For example this can occur by default in OpenSSL DHE based SSL/TLS ciphersuites.

This issue affects OpenSSL version 1.0.2.

OpenSSL 1.0.2 users should upgrade to 1.0.2e

This issue was reported to OpenSSL on August 13 2015 by Hanno Böck. The fix was developed by Andy Polyakov of the OpenSSL development team.

The report

For certain inputs OpenSSL's BN_mod_exp function (which is used for RSA and Diffie Hellman) can produce wrong results. The issue has been fixed by OpenSSL and rated moderate severity: https://openssl.org/news/secadv/20151203.txt

A code example is here: https://github.com/hannob/bignum-fuzz/blob/master/CVE-2015-3193-openssl-vs-gcrypt-modexp.c

Some more info: https://blog.fuzzing-project.org/31-Fuzzing-Math-miscalculations-in-OpenSSLs-BN_mod_exp-CVE-2015-3193.html

The original report as published on HackerOne, by hanno. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

A carry propagating bug in the x86_64 Montgomery squaring procedure.

Impact

Attacks against DH are considered just feasible (although very difficult) because most of the work necessary to deduce information about a private key may be performed offline, and an attacker would additionally need online access to an unpatched system using the target private key in a scenario with persistent DH parameters and a private key that is shared between multiple clients.

What the attacker needed

Unpatched OpenSSL 1.0.2 on x86_64; persistent DH parameters; private key shared between multiple clients; online access to the target system

The fix

The issue was fixed by OpenSSL; users of version 1.0.2 should upgrade to 1.0.2e.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A bug in a maths routine meant some numbers gave wrong answers. In specific DH setups an attacker with online access might work out a secret key, but this is extremely hard and needs many resources.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More by hanno

View all

13 more disclosed reports, best first.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.