# EVP_EncodeUpdate overflow (CVE-2016-2105)

Integer overflow in OpenSSL EVP_EncodeUpdate() Base64 encoding lets large untrusted input corrupt the heap in applications calling the API directly.

- Payout: hidden
- Severity: low
- Program: Internet Bug Bounty
- Found by: guido
- Disclosed: 2016-05-03
- CVE: CVE-2016-2105
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/135944
- Library page: https://bugbountylibrary.com/r/h1%3A135944
- Tags: area:oss domain:oss impact:dos impact:integrity kind:bounty platform:hackerone sev:low technique:source-review vuln:memory-corruption

**Target:** EVP_EncodeUpdate() Base64 encoding API in libcrypto
**Root cause:** A length check in EVP_EncodeUpdate() can overflow when very large amounts of input data are supplied, leading to a heap buffer overflow during Base64 encoding.
**Steps:**
1. Call EVP_EncodeUpdate() directly from a user application with very large attacker-controlled input length.
2. The internal length check overflows, so the output buffer is undersized.
3. Encoding writes past the allocated heap buffer, corrupting heap memory.
**How found:** Initial analysis flagged the PEM_write_bio* family as vulnerable, but further review showed those callers bound lengths; the flaw only affects direct API callers with large untrusted input.
**Exploitation:** Requires an application that passes large untrusted data directly to EVP_EncodeUpdate(); internal PEM_write_bio* uses are bounded and not exploitable. No end-to-end exploit described.
**Insight:** When auditing crypto encoding helpers, check whether length arithmetic (e.g. 4/3 expansion) can wrap for huge inputs, and verify whether internal callers actually bound lengths before assuming exploitability.

