Bug 1300257 (CVE-2016-0758)

Summary: CVE-2016-0758 kernel: tags with indefinite length can corrupt pointers in asn1_find_indefinite_length()
Product: [Other] Security Response Reporter: Adam Mariš <amaris>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: unspecifiedCC: agordeev, aquini, bhu, carnil, dhoward, dhowells, esammons, fhrbata, iboverma, jkacur, joelsmith, jross, kernel-mgr, kstutsma, lgoncalv, lwang, matt, mcressma, mguzik, nmurray, osoukup, pholasek, plougher, pmatouse, rvrbovsk, security-response-team, slawomir, vdronov, williams, wmealing
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
A flaw was found in the way the Linux kernel's ASN.1 DER decoder processed certain certificate files with tags of indefinite length. A local, unprivileged user could use a specially crafted X.509 certificate DER file to crash the system or, potentially, escalate their privileges on the system.
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-05-12 10:35:16 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1303981, 1308814, 1308815, 1325957, 1325958, 1325959, 1325960, 1335386    
Bug Blocks: 1302159    

Description Adam Mariš 2016-01-20 11:15:44 UTC
An issue with ASN.1 DER decoder was reported that could lead to memory corruptions, possible privilege escalation, or complete local denial of service via x509 certificate DER files.

Tags with indefinite length can be used to corrupt the _dp and _len pointers in asn1_find_indefinite_length() in lib/asn1_decoder.c

Vulnerable code:

...
next_tag:
        if (unlikely(datalen - dp < 2)) {
                if (datalen == dp)
                        goto missing_eoc;
                goto data_overrun_error;
        }
...
        n = len - 0x80;
        if (unlikely(n > sizeof(size_t) - 1))
                goto length_too_long;
        if (unlikely(n > datalen - dp))
                goto data_overrun_error;
        for (len = 0; n > 0; n--) {
                len <<= 8;
                len |= data[dp++];
        }
        dp += len;
        goto next_tag;
...

dp can be corrupted and the check at next_tag is not sufficient to prevent this.

Upstream fix:
https://lkml.org/lkml/2016/5/12/270

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=23c8a812dc3c621009e4f0e5342aa4e2ede1ceaa

Comment 6 Wade Mealing 2016-04-11 11:57:22 UTC
Statement:

This issue does not affect the Linux kernel packages as shipped with Red Hat Enterprise Linux 5 and 6.

This issue affects the Linux kernel packages as shipped with Red Hat Enterprise Linux 7 and Red Hat Enterprise MRG 2.

Comment 10 Petr Matousek 2016-05-12 07:06:58 UTC
Created kernel tracking bugs for this issue:

Affects: fedora-all [bug 1335386]

Comment 11 errata-xmlrpc 2016-05-12 07:59:15 UTC
This issue has been addressed in the following products:

  MRG for RHEL-6 v.2

Via RHSA-2016:1055 https://rhn.redhat.com/errata/RHSA-2016-1055.html

Comment 12 errata-xmlrpc 2016-05-12 10:00:32 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7

Via RHSA-2016:1033 https://rhn.redhat.com/errata/RHSA-2016-1033.html

Comment 13 errata-xmlrpc 2016-05-12 10:06:09 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7

Via RHSA-2016:1051 https://rhn.redhat.com/errata/RHSA-2016-1051.html

Comment 14 David Howells 2016-05-12 12:01:24 UTC
Posted upstream: https://lkml.org/lkml/2016/5/12/270

Comment 15 Fedora Update System 2016-05-24 18:02:28 UTC
kernel-4.5.5-300.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.

Comment 16 Fedora Update System 2016-05-25 00:52:28 UTC
kernel-4.4.10-200.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.

Comment 17 Fedora Update System 2016-06-02 14:57:17 UTC
kernel-4.5.5-201.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.