Bug 1704762 (CVE-2019-10131)

Summary: CVE-2019-10131 ImageMagick: off-by-one read in formatIPTCfromBuffer function in coders/meta.c
Product: [Other] Security Response Reporter: Riccardo Schirone <rschiron>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: low Docs Contact:
Priority: low    
Version: unspecifiedCC: apmukher, fedora, jhorak, jss, klember, mike, pahan
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: ImageMagick 7.0.7-28, ImageMagick 6.9.9-40 Doc Type: If docs needed, set a value
Doc Text:
An off-by-one read vulnerability was discovered in ImageMagick in the formatIPTCfromBuffer function in coders/meta.c. A local attacker may use this flaw to read beyond the end of the buffer or to crash the program.
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-31 22:33:58 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: 1708634, 1708635    
Bug Blocks: 1704783    

Description Riccardo Schirone 2019-04-30 13:06:48 UTC
An off-by-one read vulnerability was discovered in ImageMagick in the formatIPTCfromBuffer() function in coders/meta.c. A local attacker may use this flaw to read beyond the end of the buffer or to crash the program.

Upstream patch:
https://github.com/ImageMagick/ImageMagick/commit/cb1214c124e1bd61f7dd551b94a794864861592e

Comment 1 Riccardo Schirone 2019-04-30 13:28:29 UTC
Acknowledgments:

Name: Riccardo Schirone (Red Hat Product Security)

Comment 2 Riccardo Schirone 2019-04-30 13:31:51 UTC
Valgrind output:

$ valgrind -- convert ./poc /dev/null
==17934== Memcheck, a memory error detector
==17934== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==17934== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==17934== Command: convert ./poc /dev/null
==17934==
==17934== Invalid read of size 1
==17934==    at 0xF8D850D: formatIPTCfromBuffer (meta.c:2084)
==17934==    by 0xF8D850D: format8BIM (meta.c:2227)
==17934==    by 0xF8D8E36: WriteMETAImage (meta.c:2317)
==17934==    by 0x4EC23CE: WriteImage (constitute.c:1229)
==17934==    by 0x4EC2C91: WriteImages (constitute.c:1382)
==17934==    by 0x5320FCA: ConvertImageCommand (convert.c:3051)
==17934==    by 0x5388D2E: MagickCommandGenesis (mogrify.c:161)
==17934==    by 0x400896: ConvertMain (convert.c:81)
==17934==    by 0x400896: main (convert.c:92)
==17934==  Address 0x9048feb is 0 bytes after a block of size 11 alloc'd
==17934==    at 0x4C29BC3: malloc (vg_replace_malloc.c:299)
==17934==    by 0xF8D8357: format8BIM (meta.c:2196)
==17934==    by 0xF8D8E36: WriteMETAImage (meta.c:2317)
==17934==    by 0x4EC23CE: WriteImage (constitute.c:1229)
==17934==    by 0x4EC2C91: WriteImages (constitute.c:1382)
==17934==    by 0x5320FCA: ConvertImageCommand (convert.c:3051)
==17934==    by 0x5388D2E: MagickCommandGenesis (mogrify.c:161)
==17934==    by 0x400896: ConvertMain (convert.c:81)
==17934==    by 0x400896: main (convert.c:92)
==17934==

Comment 3 Riccardo Schirone 2019-04-30 13:32:48 UTC
The buffer is allocated in format8BIM() in coders/meta.c and but the invalid read of 1 byte happens in formatIPTCfromBuffer().

Comment 7 Riccardo Schirone 2019-05-10 12:39:08 UTC
Created ImageMagick tracking bugs for this issue:

Affects: fedora-all [bug 1708634]

Comment 10 John 2020-03-27 02:27:07 UTC
About time.

Comment 11 errata-xmlrpc 2020-03-31 19:32:12 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7

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

Comment 12 Product Security DevOps Team 2020-03-31 22:33:58 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-2019-10131