Bug 1492121 (CVE-2017-14348)

Summary: CVE-2017-14348 libraw: Heap-based 1 byte buffer over-write in processCanonCameraInfo function in internal/dcraw_common.cpp
Product: [Other] Security Response Reporter: Pedro Sampaio <psampaio>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED WONTFIX QA Contact:
Severity: low Docs Contact:
Priority: low    
Version: unspecifiedCC: alekcejk, carnil, extras-orphan, gwync, hobbes1069, jreznik, jridky, kde-sig, manisandro, mattdm, mattia.verga, nphilipp, rdieter, sebastian, siddharth.kde, than, thibault.north
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: libraw 0.18.4 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-06-08 03:25:32 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: 1492122, 1492124, 1492125, 1492126, 1492127, 1494406    
Bug Blocks:    

Description Pedro Sampaio 2017-09-15 14:05:39 UTC
LibRaw before 0.18.4 has a heap-based Buffer Overflow in the
processCanonCameraInfo function via a crafted file.

Upstream bug:

https://github.com/LibRaw/LibRaw/issues/100

Upstream patch:

https://github.com/LibRaw/LibRaw/commit/d13e8f6d1e987b7491182040a188c16a395f1d21

References:

https://bugzilla.novell.com/show_bug.cgi?id=1058467

Comment 1 Pedro Sampaio 2017-09-15 14:06:27 UTC
Created LibRaw tracking bugs for this issue:

Affects: epel-6 [bug 1492125]
Affects: fedora-all [bug 1492122]


Created dcraw tracking bugs for this issue:

Affects: fedora-all [bug 1492123]


Created libkdcraw tracking bugs for this issue:

Affects: fedora-all [bug 1492126]


Created mingw-LibRaw tracking bugs for this issue:

Affects: fedora-all [bug 1492127]


Created rawtherapee tracking bugs for this issue:

Affects: fedora-all [bug 1492124]

Comment 2 Salvatore Bonaccorso 2017-09-15 19:34:23 UTC
Hi

I think the upstream commit referenced is not the correct one. For CVE-2017-14348 it should be https://github.com/LibRaw/LibRaw/commit/8303e74b0567806dd5f16fc39aab70fe928de1a2

Regards,
Salvatore

Comment 3 Gwyn Ciesla 2017-09-20 16:58:58 UTC
The patch I have includes those changes, except for this, which doesn't apply.

--- dcraw/dcraw.c
+++ dcraw/dcraw.c
@@ -7071,6 +7071,7 @@ void CLASS setCanonBodyFeatures (unsigned id)
 void CLASS processCanonCameraInfo (unsigned id, uchar *CameraInfo, unsigned maxlen)
 {
   ushort iCanonLensID = 0, iCanonMaxFocal = 0, iCanonMinFocal = 0, iCanonLens = 0, iCanonCurFocal = 0, iCanonFocalType = 0;
+  if(maxlen<16) return; // too short, so broken
   CameraInfo[0] = 0;
   CameraInfo[1] = 0;
   switch (id) {
@@ -8631,7 +8632,7 @@ void CLASS parse_makernote_0xc634(int base, int uptag, unsigned dng_writer)
       {
         if (tag == 0x000d && len < 256000) // camera info
           {
-            CanonCameraInfo = (uchar*)malloc(len);
+            CanonCameraInfo = (uchar*)malloc(MAX(16,len));
             fread(CanonCameraInfo, len, 1, ifp);
             lenCanonCameraInfo = len;
           }
@@ -9496,7 +9497,7 @@ void CLASS parse_makernote (int base, int uptag)
       {
         if (tag == 0x000d && len < 256000)     // camera info
           {
-            CanonCameraInfo = (uchar*)malloc(len);
+            CanonCameraInfo = (uchar*)malloc(MAX(16,len));
             fread(CanonCameraInfo, len, 1, ifp);
             lenCanonCameraInfo = len;
           }

Comment 4 Andrej Nemec 2017-09-22 08:26:05 UTC
Created LibRaw tracking bugs for this issue:

Affects: epel-6 [bug 1494406]