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

EVP_EncodeUpdate overflow (CVE-2016-2105)

A length check in the EVP_EncodeUpdate() Base64 encoding function could overflow when very large amounts of input data were supplied, leading to heap corruption. An attacker able to feed large untrusted data into applications calling this API directly could trigger the overflow, though OpenSSL's own internal uses were bounded and not vulnerable.

guido Follow

Originally disclosed on HackerOne

  • Fixed in 4 hours
  • Paid in 4 hours
  • Disclosed after 7 hours

Summary by the program

Severity: Low

An overflow can occur in the EVP_EncodeUpdate() function which is used for Base64 encoding of binary data. If an attacker is able to supply very large amounts of input data then a length check can overflow resulting in a heap corruption.

Internally to OpenSSL the EVP_EncodeUpdate() function is primarly used by the PEM_write_bio* family of functions. These are mainly used within the OpenSSL command line applications. These internal uses are not considered vulnerable because all calls are bounded with length checks so no overflow is possible. User applications that call these APIs directly with large amounts of untrusted data may be vulnerable. (Note: Initial analysis suggested that the PEM_write_bio* were vulnerable, and this is reflected in the patch commit message. This is no longer believed to be the case).

OpenSSL 1.0.2 users should upgrade to 1.0.2h OpenSSL 1.0.1 users should upgrade to 1.0.1t

This issue was reported to OpenSSL on 3rd March 2016 by Guido Vranken. The fix was developed by Matt Caswell of the OpenSSL development team.

The report

https://github.com/openssl/openssl/commit/ee1e3cac2e83abc77bcc8ff98729ca1e10fcc920

The original report as published on HackerOne, by guido. 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 an integer overflow in the length calculation inside EVP_EncodeUpdate(), so a size check passed but the subsequent write exceeded the allocated heap buffer.

Impact

Applications that call EVP_EncodeUpdate() directly with large amounts of untrusted data may suffer heap corruption, though OpenSSL's internal uses were bounded and not vulnerable.

What the attacker needed

Application calls EVP_EncodeUpdate directly; attacker supplies very large input data

The fix

The issue was fixed in OpenSSL 1.0.2h and 1.0.1t, with the fix developed by Matt Caswell.

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.

Base64 encoding turns binary data into text, and OpenSSL provides a function to do this. That function did its size arithmetic in a way that could wrap around when given an enormous amount of input, so it wrote past the end of a memory buffer. Only programs that pass very large untrusted data straight into this function were at risk; OpenSSL's own tools checked sizes first.

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 guido

View all

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