Skip to content
Memory corruption Disclosed report Advanced CVE-2016-2182

OOB write in BN_bn2dec() (CVE-2016-2182)

The BN_bn2dec() function in OpenSSL did not check the return value of BN_div_word(), which could lead to an out-of-bounds write when converting an overly large BIGNUM to a decimal string. An attacker could trigger this if an application printed an oversized certificate or CRL from an untrusted source, though TLS itself was not affected because record limits reject oversized certificates before parsing.

theyarestone Follow

Originally disclosed on HackerOne

  • Fixed in 36 days
  • Paid in 36 days
  • Disclosed after 37 days

Summary by the program

The function BN_bn2dec() does not check the return value of BN_div_word(). This can cause an OOB write if an application uses this function with an overly large BIGNUM. This could be a problem if an overly large certificate or CRL is printed out from an untrusted source. TLS is not affected because record limits will reject an oversized certificate before it is parsed.

OpenSSL 1.0.2 users should upgrade to 1.0.2i OpenSSL 1.0.1 users should upgrade to 1.0.1u

This issue was reported to OpenSSL on 2nd August 2016 by Shi Lei (Gear Team, Qihoo 360 Inc.). The fix was developed by Stephen Henson of the OpenSSL development team.

The report

The function BN_bn2dec() does not check the return value of BN_div_word(). This can cause an OOB write if an application uses this function with an overly large BIGNUM. This could be a problem if an overly large certificate or CRL is printed out from an untrusted source. TLS is not affected because record limits will reject an oversized certificate before it is parsed.

refer: https://www.openssl.org/news/secadv/20160922.txt

The original report as published on HackerOne, by theyarestone. 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

Likely the code ignored the error return of BN_div_word() during decimal conversion, so a failed division left the buffer position inconsistent and caused a write beyond the allocated space.

Impact

An application that prints an overly large certificate or CRL from an untrusted source could suffer an out-of-bounds write; TLS is not affected because record limits reject oversized certificates before parsing.

What the attacker needed

Application prints untrusted cert or CRL; oversized BIGNUM value

The fix

The fix was developed by Stephen Henson; users of 1.0.2 and 1.0.1 should upgrade to 1.0.2i and 1.0.1u respectively.

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.

When OpenSSL turned a very large number into decimal text, it failed to notice an internal step had gone wrong, so it could write past the end of its buffer. This only affects programs that print huge certificates or revocation lists from untrusted sources.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by theyarestone

View all

7 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.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.