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: impact=important,public=20131204,reported=20131126,source=distros,cvss2=6.8/AV:N/AC:M/Au:N/C:P/I:P/A:P,cvss3=7.5/CVSS:3.0/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H,cwe=CWE-122[auto],fedora-all/openjpeg=affected,fedora-all/mingw-openjpeg=affected,epel-5/openjpeg=affected,rhel-6/openjpeg=affected,rhel-7/openjpeg=notaffected
Fixed In Version: openjpeg 1.5.2 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-10-05 20:51:12 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On: 1038409, 1038410, 1038411, 1038415, 1038985, 1038987    
Bug Blocks: 1036502    
Description Flags
proposed patch 1
proposed patch 2
proposed patch 3
proposed patch 4
proposed patch 5 none

Description Murray McAllister 2013-12-02 02:01:48 EST
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 02:34:01 EST
Created attachment 831461 [details]
proposed patch 1
Comment 2 Murray McAllister 2013-12-02 02:34:46 EST
Created attachment 831462 [details]
proposed patch 2
Comment 3 Murray McAllister 2013-12-02 02:35:30 EST
Created attachment 831463 [details]
proposed patch 3
Comment 4 Murray McAllister 2013-12-02 02:36:13 EST
Created attachment 831464 [details]
proposed patch 4
Comment 5 Murray McAllister 2013-12-02 02:36:49 EST
Created attachment 831465 [details]
proposed patch 5
Comment 6 Murray McAllister 2013-12-02 09:06:24 EST

Red Hat would like to thank Raphael Geissert for reporting these issues during a review for EDF.
Comment 7 Murray McAllister 2013-12-05 00:07:35 EST
Created openjpeg tracking bugs for this issue:

Affects: fedora-all [bug 1038409]
Comment 8 Murray McAllister 2013-12-05 00:07:42 EST
Created mingw-openjpeg tracking bugs for this issue:

Affects: fedora-all [bug 1038410]
Comment 9 Murray McAllister 2013-12-05 00:11:57 EST
Created openjpeg tracking bugs for this issue:

Affects: epel-5 [bug 1038411]
Comment 12 Fedora Update System 2013-12-14 22:27:32 EST
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-14 22:32:58 EST
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 13:42:35 EST
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 15:53:55 EST
Looks like proposed patches 3,4 are already applied upstream as part of

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 15:58:42 EST
(and patch 5 too)
Comment 17 Fedora Update System 2014-10-12 01:00:48 EDT
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 00:29:31 EDT
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 03:28:20 EDT
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 */):


which is used in Fedora/openjpeg-1.5.1:


This should replace openjpeg-CVE-2014-6045.patch in RHEL.
Comment 21 Doran Moppert 2016-10-05 20:51:12 EDT
New bug 1382202 created to track this.