Bug 1874712 (CVE-2020-14382)

Summary: CVE-2020-14382 cryptsetup: Out-of-bounds write when validating segments
Product: [Other] Security Response Reporter: Huzaifa S. Sidhpurwala <huzaifas>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: agk, gmazyland, guazhang, jbrassow, lvm-team, mbroz, okozina, prajnoha, security-response-team
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: cryptsetup 2.3.4 Doc Type: If docs needed, set a value
Doc Text:
A flaw was found in the way cryptsetup parses encrypted images with invalid segments. This flaw allows a local attacker to crash an application compiled with cryptsetup, or in some cases, cause arbitrary code execution when parsing specially crafted encrypted images. The highest threat from this vulnerability is to confidentiality, integrity, as well as system availability.
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-04 02:26:40 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: 1872294, 1874714, 1875199, 1877370, 1877845    
Bug Blocks: 1872428    

Description Huzaifa S. Sidhpurwala 2020-09-02 04:33:37 UTC
As per the reporter:

There's a bug in LUKS2 format validation code, that is effectively invoked on every device/image presenting itself as LUKS2 container. The bug is in segments validation code in file 'lib/luks2/luks2_json_metadata.c' in function hdr_validate_segments(struct crypt_device *cd, json_object *hdr_jobj) where the code does not check for possible overflow on memory allocation used for intervals array (see statement "intervals = malloc(first_backup * sizeof(*intervals));"). Due to the bug, library can be *tricked* to expect such allocation was successful but for far less memory then originally expected. Later it may read data FROM image crafted by an attacker and actually write such data BEYOND allocated memory!

Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1872294
Upstream commit: https://gitlab.com/cryptsetup/cryptsetup/-/commit/52f5cb8cedf22fb3e14c744814ec8af7614146c7

Comment 1 Huzaifa S. Sidhpurwala 2020-09-02 04:33:41 UTC
Acknowledgments:

Name: Tobias Stoeckmann

Comment 4 Huzaifa S. Sidhpurwala 2020-09-03 02:11:45 UTC
Created cryptsetup tracking bugs for this issue:

Affects: fedora-all [bug 1875199]

Comment 5 Huzaifa S. Sidhpurwala 2020-09-03 03:01:16 UTC
Upstream merge-request: https://gitlab.com/cryptsetup/cryptsetup/-/merge_requests/102

Comment 6 Huzaifa S. Sidhpurwala 2020-09-07 03:42:24 UTC
External References:

https://gitlab.com/cryptsetup/cryptsetup/-/blob/master/docs/v2.3.4-ReleaseNotes

Comment 8 guazhang@redhat.com 2020-09-16 04:07:41 UTC
Hello

Any update for the bug?  the bug has added to errata[1] and it block the errata testing.

https://errata.devel.redhat.com/advisory/55325

Comment 17 errata-xmlrpc 2020-11-04 01:50:55 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8

Via RHSA-2020:4542 https://access.redhat.com/errata/RHSA-2020:4542

Comment 18 Product Security DevOps Team 2020-11-04 02:26:40 UTC
This bug is now closed. Further updates for individual products will be reflected on the CVE page(s):

https://access.redhat.com/security/cve/cve-2020-14382

Comment 22 errata-xmlrpc 2020-11-04 12:30:48 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8.1 Extended Update Support

Via RHSA-2020:4900 https://access.redhat.com/errata/RHSA-2020:4900

Comment 23 RaTasha Tillery-Smith 2020-12-17 13:18:23 UTC
Statement:

This flaw was introduced in upstream release cryptsetup-2.2.0, with the inclusion of the LUKS2 re-encryption code. This feature is not available in Red Hat Enterprise Linux 7, therefore it is not affected by this flaw.

Comment 24 errata-xmlrpc 2021-01-26 11:18:43 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8.2 Extended Update Support

Via RHSA-2021:0258 https://access.redhat.com/errata/RHSA-2021:0258