CVE-2016-2108: Buffer Overflow
A flaw was found in the way OpenSSL encoded certain ASN.1 data structures. An attacker could use this flaw to create a specially crafted certificate which, when verified or re-encoded by OpenSSL, could cause it to crash, or execute arbitrary code using the permissions of the user running an application compiled against the OpenSSL library.
Other sources
Quoting form the draft of OpenSSL upstream advisory:
Memory corruption in the ASN.1 encoder (CVE-2016-2108) ======================================================
Severity: High
This issue affected versions of OpenSSL prior to April 2015. The bug causing the vulnerability was fixed on April 18th 2015, and released as part of the June 11th 2015 security releases. The security impact of the bug was not known at the time.
In previous versions of OpenSSL, ASN.1 encoding the value zero represented as a negative integer can cause a buffer underflow with an out-of-bounds write in i2cASN1INTEGER. The ASN.1 parser does not normally create "negative zeroes" when parsing ASN.1 input, and therefore, an attacker cannot trigger this bug.
However, a second, independent bug revealed that the ASN.1 parser (specifically, d2iASN1TYPE) can misinterpret a large universal tag as a negative zero value. Large universal tags are not present in any common ASN.1 structures (such as X509) but are accepted as part of ANY structures.
Therefore, if an application deserializes untrusted ASN.1 structures containing an ANY field, and later reserializes them, an attacker may be able to trigger an out-of-bounds write. This has been shown to cause memory corruption that is potentially exploitable with some malloc implementations.
Applications that parse and re-encode X509 certificates are known to be vulnerable. Applications that verify RSA signatures on X509 certificates may also be vulnerable; however, only certificates with valid signatures trigger ASN.1 re-encoding and hence the bug. Specifically, since OpenSSL's default TLS X509 chain verification code verifies the certificate chain from root to leaf, TLS handshakes could only be targeted with valid certificates issued by trusted Certification Authorities.
OpenSSL 1.0.2 users should upgrade to 1.0.2c OpenSSL 1.0.1 users should upgrade to 1.0.1o
This vulnerability is a combination of two bugs, neither of which individually has security impact. The first bug (mishandling of negative zero integers) was reported to OpenSSL by Huzaifa Sidhpurwala (Red Hat) and independently by Hanno Böck in April 2015. The second issue (mishandling of large universal tags) was found using libFuzzer, and reported on the public issue tracker on March 1st 2016. The fact that these two issues combined present a security vulnerability was reported by David Benjamin (Google) on March 31st 2016. The fixes were developed by Steve Henson of the OpenSSL development team, and David Benjamin. The OpenSSL team would also like to thank Mark Brand and Ian Beer from the Google Project Zero team for their careful analysis of the impact.
The fix for the "negative zero" memory corruption bug can be identified by commits
3661bb4e7934668bd99ca777ea8b30eedfafa871 (1.0.2) and 32d3b0f52f77ce86d53f38685336668d47c5bdfe (1.0.1)
End of quote.
Links to the mentioned commits correcting the "negative zero" memory corruption bug:
1.0.2: https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff;h=3661bb4e7934668bd99ca777ea8b30eedfafa871 1.0.1: https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff;h=32d3b0f52f77ce86d53f38685336668d47c5bdfe
The report of the additional problem - mishandling of large universal tags:
https://rt.openssl.org/Ticket/Display.html?id=4364&user=guest&pass=guest
Includes proposed fix and the matching fix that was applied to BoringSSL:
https://boringssl.googlesource.com/boringssl/+/fb2c6f8c8565e1e2d85c24408050c96521acbcdc%5E!/
— Red Hat
The ASN.1 implementation in OpenSSL before 1.0.1o and 1.0.2 before 1.0.2c allows remote attackers to execute arbitrary code or cause a denial of service (buffer underflow and memory corruption) via an ANY field in crafted serialized data, aka the "negative zero" issue.
Affected Software
Event History
Parent advisories
This vulnerability appears in the following advisories.
Frequently Asked Questions
What is the severity of CVE-2016-2108?
CVE-2016-2108 has a severity rating of High due to the potential for an attacker to execute arbitrary code.
How do I fix CVE-2016-2108?
To fix CVE-2016-2108, update the affected OpenSSL packages to the latest version as specified by your vendor.
Which versions of OpenSSL are affected by CVE-2016-2108?
CVE-2016-2108 affects OpenSSL versions prior to 1.0.2h and 1.0.1n.
What types of applications are impacted by CVE-2016-2108?
Applications that use vulnerable versions of OpenSSL for certificate handling may be impacted by CVE-2016-2108.
Is CVE-2016-2108 a remote code execution vulnerability?
Yes, CVE-2016-2108 can lead to remote code execution if exploited.