Bug 1036495 (CVE-2013-6045)

Summary: CVE-2013-6045 openjpeg: heap-based buffer overflows
Product: [Other] Security Response Reporter: Murray McAllister <mmcallis>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: unspecifiedCC: dmoppert, jkurik, phracek, rdieter, security-response-team
Target Milestone: ---Keywords: Reopened, Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: openjpeg 1.5.2 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-10-06 00:51:12 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: 1038409, 1038410, 1038411, 1038415, 1038985, 1038987    
Bug Blocks: 1036502    
Attachments:
Description Flags
proposed patch 1
none
proposed patch 2
none
proposed patch 3
none
proposed patch 4
none
proposed patch 5 none

Description Murray McAllister 2013-12-02 07:01:48 UTC
Raphael Geissert discovered multiple heap-based buffer overflows in OpenJPEG. If a specially-crafted image were opened by an application linked against OpenJPEG, it could cause the application to crash or, potentially, execute arbitrary code with the privileges of the user running the application.

Comment 1 Murray McAllister 2013-12-02 07:34:01 UTC
Created attachment 831461 [details]
proposed patch 1

Comment 2 Murray McAllister 2013-12-02 07:34:46 UTC
Created attachment 831462 [details]
proposed patch 2

Comment 3 Murray McAllister 2013-12-02 07:35:30 UTC
Created attachment 831463 [details]
proposed patch 3

Comment 4 Murray McAllister 2013-12-02 07:36:13 UTC
Created attachment 831464 [details]
proposed patch 4

Comment 5 Murray McAllister 2013-12-02 07:36:49 UTC
Created attachment 831465 [details]
proposed patch 5

Comment 6 Murray McAllister 2013-12-02 14:06:24 UTC
Acknowledgements:

Red Hat would like to thank Raphael Geissert for reporting these issues during a review for EDF.

Comment 7 Murray McAllister 2013-12-05 05:07:35 UTC
Created openjpeg tracking bugs for this issue:

Affects: fedora-all [bug 1038409]

Comment 8 Murray McAllister 2013-12-05 05:07:42 UTC
Created mingw-openjpeg tracking bugs for this issue:

Affects: fedora-all [bug 1038410]

Comment 9 Murray McAllister 2013-12-05 05:11:57 UTC
Created openjpeg tracking bugs for this issue:

Affects: epel-5 [bug 1038411]

Comment 12 Fedora Update System 2013-12-15 03:27:32 UTC
mingw-openjpeg-1.5.1-5.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 13 Fedora Update System 2013-12-15 03:32:58 UTC
mingw-openjpeg-1.5.1-5.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 14 errata-xmlrpc 2013-12-17 18:42:35 UTC
This issue has been addressed in following products:

  Red Hat Enterprise Linux 6

Via RHSA-2013:1850 https://rhn.redhat.com/errata/RHSA-2013-1850.html

Comment 15 Rex Dieter 2014-01-07 20:53:55 UTC
Looks like proposed patches 3,4 are already applied upstream as part of
https://code.google.com/p/openjpeg/issues/detail?id=166

and applied in fedora packaging in openjpeg-1.5-r2033.patch

(though the upstream commit version of patch4 does the checking unconditionally, rather than in an else branch)

Comment 16 Rex Dieter 2014-01-07 20:58:42 UTC
(and patch 5 too)

Comment 17 Fedora Update System 2014-10-12 05:00:48 UTC
openjpeg-1.5.1-13.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 18 Fedora Update System 2014-10-14 04:29:31 UTC
openjpeg-1.5.1-13.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 20 Doran Moppert 2016-09-14 07:28:20 UTC
Investigating bug 1317826 uncovered a crash that seems to be introduced by patch 2 in comment #2 above.

Commentary in the patch reads:

    /* Later-on it is assumed that all components are of at least comp0size blocks */

But if the test passes, we fall through to:

    ...malloc((comp0size+3) * sizeof(int))

which allocates the smaller buffer size (comp0size) rather than the current component's computed size (should be "compcsize").

This causes a crash (visible using ASAN) with issue725.jp2 from https://github.com/uclouvain/openjpeg-data/tree/master/input/nonregression/

Note that upstream has addressed this flaw in openjpeg-1.5.2 with a different patch (hunk starting /* testcase 1336.pdf.asan.74.376 */):

    https://github.com/uclouvain/openjpeg/commit/69cd4f92

which is used in Fedora/openjpeg-1.5.1:

    http://pkgs.fedoraproject.org/cgit/rpms/openjpeg.git/tree/openjpeg-1.5.1-CVE-2013-6045.patch

This should replace openjpeg-CVE-2014-6045.patch in RHEL.

Comment 21 Doran Moppert 2016-10-06 00:51:12 UTC
New bug 1382202 created to track this.