Bug 1055434 - (CVE-2017-13648) VUL-1: CVE-2017-13648: GraphicsMagick,ImageMagick: In GraphicsMagick 1.3.26, a memory leak vulnerability was found in thefunction ReadMATImage in coders/mat.c.
(CVE-2017-13648)
VUL-1: CVE-2017-13648: GraphicsMagick,ImageMagick: In GraphicsMagick 1.3.26, ...
Status: RESOLVED FIXED
Classification: Novell Products
Product: SUSE Security Incidents
Classification: Novell Products
Component: Incidents
unspecified
Other Other
: P4 - Low : Normal
: ---
Assigned To: Security Team bot
Security Team bot
https://smash.suse.de/issue/190938/
CVSSv3:SUSE:CVE-2017-13648:5.3:(AV:N/...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2017-08-24 07:24 UTC by Marcus Meissner
Modified: 2018-01-31 20:27 UTC (History)
1 user (show)

See Also:
Found By: Security Response Team
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
gm_memory_leak_in_ReadMATImage.mat (284 bytes, application/octet-stream)
2017-08-24 07:25 UTC, Marcus Meissner
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marcus Meissner 2017-08-24 07:24:39 UTC
CVE-2017-13648

https://sourceforge.net/p/graphicsmagick/bugs/433/


A memory leak vulnerability was found in function ReadMATImage in coders/mat.c,which allow attackers to cause a denial of service via a crafted file.

#./gm identify $FILE
Comment 1 Marcus Meissner 2017-08-24 07:25:49 UTC
Created attachment 738135 [details]
gm_memory_leak_in_ReadMATImage.mat

QA REPRODUCER:

ImageMagick:
valgrind --leak-check=full identify gm_memory_leak_in_ReadMATImage.mat

GraphicsMagick:
valgrind --leak-check=full gm identify gm_memory_leak_in_ReadMATImage.mat

should not show leak like:

==31985== 46,940 (13,488 direct, 33,452 indirect) bytes in 1 blocks are definitely lost in loss record 38 of 38
==31985==    at 0x4C2C08F: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==31985==    by 0x4F46B6F: AcquireImage (in /usr/lib64/libMagickCore-7.Q16HDRI.so.3.0.0)
==31985==    by 0x907DB20: ???
==31985==    by 0x4EBA590: ReadImage (in /usr/lib64/libMagickCore-7.Q16HDRI.so.3.0.0)
Comment 2 Marcus Meissner 2017-08-24 07:26:16 UTC
GraphicsMagick on SLE11 seems not to leak. On Leap/Factory it does.

ImageMagick on SLE11,SLE12,Factory is affected too.
Comment 3 Petr Gajdos 2018-01-08 08:45:17 UTC
12/ImageMagick

BEFORE


$ valgrind -q --leak-check=full identify gm_memory_leak_in_ReadMATImage.mat
identify: improper image header `gm_memory_leak_in_ReadMATImage.mat' @ error/mat.c/ReadMATImage/686.
==17970== 7,152 bytes in 1 blocks are definitely lost in loss record 25 of 29
==17970==    at 0x4C29110: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17970==    by 0x6A47EB2: inflateInit2_ (in /lib64/libz.so.1.2.8)
==17970==    by 0x84187EA: ???
==17970==    by 0x4EBFE1A: ReadImage (constitute.c:601)
==17970==    by 0x4FD1658: ReadStream (stream.c:974)
==17970==    by 0x4EBF960: PingImage (constitute.c:278)
==17970==    by 0x4EBFB9A: PingImages (constitute.c:373)
==17970==    by 0x535850B: IdentifyImageCommand (identify.c:322)
==17970==    by 0x5385C52: MagickCommandGenesis (mogrify.c:166)
==17970==    by 0x400891: IdentifyMain (identify.c:80)
==17970==    by 0x400891: main (identify.c:93)
==17970== 
==17970== 23,240 (13,232 direct, 10,008 indirect) bytes in 1 blocks are definitely lost in loss record 28 of 29
==17970==    at 0x4C29110: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17970==    by 0x4F4C9AC: AcquireImage (image.c:164)
==17970==    by 0x841891B: ???
==17970==    by 0x4EBFE1A: ReadImage (constitute.c:601)
==17970==    by 0x4FD1658: ReadStream (stream.c:974)
==17970==    by 0x4EBF960: PingImage (constitute.c:278)
==17970==    by 0x4EBFB9A: PingImages (constitute.c:373)
==17970==    by 0x535850B: IdentifyImageCommand (identify.c:322)
==17970==    by 0x5385C52: MagickCommandGenesis (mogrify.c:166)
==17970==    by 0x400891: IdentifyMain (identify.c:80)
==17970==    by 0x400891: main (identify.c:93)
==17970== 
==17970== 26,216 (16,792 direct, 9,424 indirect) bytes in 1 blocks are definitely lost in loss record 29 of 29
==17970==    at 0x4C29110: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17970==    by 0x4F48E1F: AcquireImageInfo (image.c:334)
==17970==    by 0x4F4AB3D: CloneImageInfo (image.c:936)
==17970==    by 0x8418267: ???
==17970==    by 0x4EBFE1A: ReadImage (constitute.c:601)
==17970==    by 0x4FD1658: ReadStream (stream.c:974)
==17970==    by 0x4EBF960: PingImage (constitute.c:278)
==17970==    by 0x4EBFB9A: PingImages (constitute.c:373)
==17970==    by 0x535850B: IdentifyImageCommand (identify.c:322)
==17970==    by 0x5385C52: MagickCommandGenesis (mogrify.c:166)
==17970==    by 0x400891: IdentifyMain (identify.c:80)
==17970==    by 0x400891: main (identify.c:93)
==17970== 
$

AFTER

$ valgrind -q --leak-check=full identify gm_memory_leak_in_ReadMATImage.mat
identify: UnsupportedCellTypeInTheMatrix `gm_memory_leak_in_ReadMATImage.mat' @ error/mat.c/ReadMATImage/1155.
$
Comment 5 Petr Gajdos 2018-01-08 11:03:59 UTC
11/ImageMagick

BEFORE

$ valgrind -q --leak-check=full identify gm_memory_leak_in_ReadMATImage.mat
identify: Improper image header `gm_memory_leak_in_ReadMATImage.mat'.
==10945== Syscall param unlink(pathname) points to unaddressable byte(s)
==10945==    at 0x8442807: unlink (in /lib64/libc-2.9.so)
==10945==    by 0x83DD0B8: remove (in /lib64/libc-2.9.so)
==10945==    by 0x4F58158: DestroyTemporaryResources (resource.c:292)
==10945==    by 0x4F67033: DestroySplayTree (splay-tree.c:723)
==10945==    by 0x4F58D80: DestroyMagickResources (resource.c:464)
==10945==    by 0x4F1DF84: MagickCoreTerminus (magick.c:1241)
==10945==    by 0x400E04: main (identify.c:117)
==10945==  Address 0x90641f0 is 0 bytes inside a block of size 21 free'd
==10945==    at 0x4C243AF: free (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so)
==10945==    by 0x4F1E6FE: RelinquishMagickMemory (memory.c:645)
==10945==    by 0x4F67001: DestroySplayTree (splay-tree.c:719)
==10945==    by 0x4F58D80: DestroyMagickResources (resource.c:464)
==10945==    by 0x4F1DF84: MagickCoreTerminus (magick.c:1241)
==10945==    by 0x400E04: main (identify.c:117)
==10945== 
==10945== 
==10945== 9,552 bytes in 1 blocks are definitely lost in loss record 6 of 9
==10945==    at 0x4C256AE: malloc (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so)
==10945==    by 0x675B604: inflateInit2_ (in /lib64/libz.so.1.2.3)
==10945==    by 0x9F09B25: ???
==10945==    by 0x4E94D87: ReadImage (constitute.c:441)
==10945==    by 0x52D0C14: IdentifyImageCommand (identify.c:297)
==10945==    by 0x400DA7: main (identify.c:101)
==10945== 
==10945== 
==10945== 16,784 bytes in 1 blocks are definitely lost in loss record 7 of 9
==10945==    at 0x4C256AE: malloc (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so)
==10945==    by 0x4F0AF9E: AcquireImageInfo (image.c:368)
==10945==    by 0x4F0B05D: CloneImageInfo (image.c:1223)
==10945==    by 0x9F09180: ???
==10945==    by 0x4E94D87: ReadImage (constitute.c:441)
==10945==    by 0x52D0C14: IdentifyImageCommand (identify.c:297)
==10945==    by 0x400DA7: main (identify.c:101)
==10945== 
==10945== 
==10945== 41,520 (13,192 direct, 28,328 indirect) bytes in 1 blocks are definitely lost in loss record 8 of 9
==10945==    at 0x4C256AE: malloc (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so)
==10945==    by 0x4F0B420: AcquireImage (image.c:152)
==10945==    by 0x9F09C55: ???
==10945==    by 0x4E94D87: ReadImage (constitute.c:441)
==10945==    by 0x52D0C14: IdentifyImageCommand (identify.c:297)
==10945==    by 0x400DA7: main (identify.c:101)
$

AFTER

$ valgrind -q --leak-check=full identify gm_memory_leak_in_ReadMATImage.mat
identify: UnsupportedCellTypeInTheMatrix `gm_memory_leak_in_ReadMATImage.mat'.
==10951== Syscall param unlink(pathname) points to unaddressable byte(s)
==10951==    at 0x8442807: unlink (in /lib64/libc-2.9.so)
==10951==    by 0x83DD0B8: remove (in /lib64/libc-2.9.so)
==10951==    by 0x4F58158: DestroyTemporaryResources (resource.c:292)
==10951==    by 0x4F67033: DestroySplayTree (splay-tree.c:723)
==10951==    by 0x4F58D80: DestroyMagickResources (resource.c:464)
==10951==    by 0x4F1DF84: MagickCoreTerminus (magick.c:1241)
==10951==    by 0x400E04: main (identify.c:117)
==10951==  Address 0x9305fc0 is 0 bytes inside a block of size 21 free'd
==10951==    at 0x4C243AF: free (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so)
==10951==    by 0x4F1E6FE: RelinquishMagickMemory (memory.c:645)
==10951==    by 0x4F67001: DestroySplayTree (splay-tree.c:719)
==10951==    by 0x4F58D80: DestroyMagickResources (resource.c:464)
==10951==    by 0x4F1DF84: MagickCoreTerminus (magick.c:1241)
==10951==    by 0x400E04: main (identify.c:117)
==10951== 
==10951== Syscall param unlink(pathname) points to unaddressable byte(s)
==10951==    at 0x8442807: unlink (in /lib64/libc-2.9.so)
==10951==    by 0x83DD0B8: remove (in /lib64/libc-2.9.so)
==10951==    by 0x4F58158: DestroyTemporaryResources (resource.c:292)
==10951==    by 0x4F670DF: DestroySplayTree (splay-tree.c:751)
==10951==    by 0x4F58D80: DestroyMagickResources (resource.c:464)
==10951==    by 0x4F1DF84: MagickCoreTerminus (magick.c:1241)
==10951==    by 0x400E04: main (identify.c:117)
==10951==  Address 0x90641f0 is 0 bytes inside a block of size 21 free'd
==10951==    at 0x4C243AF: free (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so)
==10951==    by 0x4F1E6FE: RelinquishMagickMemory (memory.c:645)
==10951==    by 0x4F670B9: DestroySplayTree (splay-tree.c:746)
==10951==    by 0x4F58D80: DestroyMagickResources (resource.c:464)
==10951==    by 0x4F1DF84: MagickCoreTerminus (magick.c:1241)
==10951==    by 0x400E04: main (identify.c:117)
$
Comment 7 Petr Gajdos 2018-01-08 13:36:40 UTC
42.x/GraphicsMagick

BEFORE

vgql gm identify gm_memory_leak_in_ReadMATImage.mat 
$ valgrind -q --leak-check=full gm identify gm_memory_leak_in_ReadMATImage.mat
gm identify: Unsupported cell type in the matrix (gm_memory_leak_in_ReadMATImage.mat).
gm identify: Request did not return an image.
==1701== 13,136 (6,864 direct, 6,272 indirect) bytes in 1 blocks are definitely lost in loss record 23 of 23
==1701==    at 0x4C29110: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==1701==    by 0x4EF11D6: AllocateImage (image.c:336)
==1701==    by 0x79CF86E: ???
==1701==    by 0x4EC0EF7: ReadImage (constitute.c:1607)
==1701==    by 0x4EC1D11: PingImage (constitute.c:1370)
==1701==    by 0x4E8DF3C: IdentifyImageCommand (command.c:8375)
==1701==    by 0x4E8F884: MagickCommand (command.c:8865)
==1701==    by 0x4E9099D: GMCommandSingle (command.c:17379)
==1701==    by 0x4EB40AD: GMCommand (command.c:17432)
==1701==    by 0x54426E4: (below main) (in /lib64/libc-2.22.so)
==1701== 
$

AFTER

$ vgql gm identify gm_memory_leak_in_ReadMATImage.mat 
$ valgrind -q --leak-check=full gm identify gm_memory_leak_in_ReadMATImage.mat
gm identify: Unsupported cell type in the matrix (gm_memory_leak_in_ReadMATImage.mat).
gm identify: Request did not return an image.
$

11/GraphicsMagick:

BEFORE

$ valgrind -q --leak-check=full gm identify gm_memory_leak_in_ReadMATImage.mat
gm identify: Request did not return an image.
$
[not reproducible]

Similarly to bug 1052720 and bug 1055065, considering unaffected.
Comment 8 Petr Gajdos 2018-01-08 13:38:06 UTC
(In reply to Petr Gajdos from comment #7)
> Similarly to bug 1052720 and bug 1055065, considering unaffected.

(E. g. 15125:91b707030bda refers to image2, which does not exist in this version.)
Comment 9 Petr Gajdos 2018-01-08 13:38:55 UTC
Will submit for 12/ImageMagick, 11/ImageMagick and 42.x/GraphicsMagick.
Comment 10 Petr Gajdos 2018-01-08 15:26:51 UTC
I believe all fixed.
Comment 11 Swamp Workflow Management 2018-01-08 15:50:36 UTC
This is an autogenerated message for OBS integration:
This bug (1055434) was mentioned in
https://build.opensuse.org/request/show/562562 42.3 / GraphicsMagick
https://build.opensuse.org/request/show/562563 42.2 / GraphicsMagick
Comment 12 Swamp Workflow Management 2018-01-09 13:10:36 UTC
This is an autogenerated message for OBS integration:
This bug (1055434) was mentioned in
https://build.opensuse.org/request/show/562871 42.3 / GraphicsMagick
https://build.opensuse.org/request/show/562872 42.2 / GraphicsMagick
Comment 14 Swamp Workflow Management 2018-01-15 14:09:12 UTC
openSUSE-SU-2018:0087-1: An update that solves 13 vulnerabilities and has one errata is now available.

Category: security (moderate)
Bug References: 1047044,1049373,1050129,1051412,1052468,1052710,1052720,1052731,1055065,1055434,1058640,1067177,1074123,1074975
CVE References: CVE-2017-10800,CVE-2017-11449,CVE-2017-11532,CVE-2017-12564,CVE-2017-12670,CVE-2017-12672,CVE-2017-12675,CVE-2017-13060,CVE-2017-13648,CVE-2017-14326,CVE-2017-16547,CVE-2017-17881,CVE-2017-18022
Sources used:
openSUSE Leap 42.3 (src):    GraphicsMagick-1.3.25-57.1
openSUSE Leap 42.2 (src):    GraphicsMagick-1.3.25-11.60.1
Comment 15 Swamp Workflow Management 2018-01-18 14:09:38 UTC
SUSE-SU-2018:0130-1: An update that fixes 21 vulnerabilities is now available.

Category: security (moderate)
Bug References: 1047044,1047898,1050120,1050606,1051446,1052468,1052550,1052710,1052720,1052731,1052732,1055065,1055323,1055434,1055855,1058640,1059751,1074123,1074969,1074973,1074975
CVE References: CVE-2017-10800,CVE-2017-11141,CVE-2017-11529,CVE-2017-11644,CVE-2017-11724,CVE-2017-12434,CVE-2017-12564,CVE-2017-12667,CVE-2017-12670,CVE-2017-12672,CVE-2017-12675,CVE-2017-13060,CVE-2017-13146,CVE-2017-13648,CVE-2017-13658,CVE-2017-14326,CVE-2017-14533,CVE-2017-17881,CVE-2017-18022,CVE-2018-5246,CVE-2018-5247
Sources used:
SUSE Linux Enterprise Workstation Extension 12-SP3 (src):    ImageMagick-6.8.8.1-71.26.1
SUSE Linux Enterprise Workstation Extension 12-SP2 (src):    ImageMagick-6.8.8.1-71.26.1
SUSE Linux Enterprise Software Development Kit 12-SP3 (src):    ImageMagick-6.8.8.1-71.26.1
SUSE Linux Enterprise Software Development Kit 12-SP2 (src):    ImageMagick-6.8.8.1-71.26.1
SUSE Linux Enterprise Server for Raspberry Pi 12-SP2 (src):    ImageMagick-6.8.8.1-71.26.1
SUSE Linux Enterprise Server 12-SP3 (src):    ImageMagick-6.8.8.1-71.26.1
SUSE Linux Enterprise Server 12-SP2 (src):    ImageMagick-6.8.8.1-71.26.1
SUSE Linux Enterprise Desktop 12-SP3 (src):    ImageMagick-6.8.8.1-71.26.1
SUSE Linux Enterprise Desktop 12-SP2 (src):    ImageMagick-6.8.8.1-71.26.1
Comment 16 Swamp Workflow Management 2018-01-18 14:14:37 UTC
SUSE-SU-2018:0132-1: An update that fixes 31 vulnerabilities is now available.

Category: security (moderate)
Bug References: 1042948,1047044,1047898,1049373,1050120,1050606,1051412,1051446,1052252,1052468,1052550,1052710,1052720,1052731,1052732,1052771,1055065,1055323,1055434,1055855,1058082,1058640,1059751,1072902,1074122,1074123,1074425,1074610,1074969,1074973,1074975
CVE References: CVE-2017-1000445,CVE-2017-1000476,CVE-2017-10800,CVE-2017-11141,CVE-2017-11449,CVE-2017-11529,CVE-2017-11644,CVE-2017-11724,CVE-2017-11751,CVE-2017-12430,CVE-2017-12434,CVE-2017-12564,CVE-2017-12642,CVE-2017-12667,CVE-2017-12670,CVE-2017-12672,CVE-2017-12675,CVE-2017-13060,CVE-2017-13146,CVE-2017-13648,CVE-2017-13658,CVE-2017-14249,CVE-2017-14326,CVE-2017-14533,CVE-2017-17680,CVE-2017-17881,CVE-2017-17882,CVE-2017-18022,CVE-2017-9409,CVE-2018-5246,CVE-2018-5247
Sources used:
SUSE Linux Enterprise Software Development Kit 11-SP4 (src):    ImageMagick-6.4.3.6-7.78.22.1
SUSE Linux Enterprise Server 11-SP4 (src):    ImageMagick-6.4.3.6-7.78.22.1
SUSE Linux Enterprise Debuginfo 11-SP4 (src):    ImageMagick-6.4.3.6-7.78.22.1
Comment 17 Swamp Workflow Management 2018-01-20 17:13:54 UTC
openSUSE-SU-2018:0155-1: An update that fixes 21 vulnerabilities is now available.

Category: security (moderate)
Bug References: 1047044,1047898,1050120,1050606,1051446,1052468,1052550,1052710,1052720,1052731,1052732,1055065,1055323,1055434,1055855,1058640,1059751,1074123,1074969,1074973,1074975
CVE References: CVE-2017-10800,CVE-2017-11141,CVE-2017-11529,CVE-2017-11644,CVE-2017-11724,CVE-2017-12434,CVE-2017-12564,CVE-2017-12667,CVE-2017-12670,CVE-2017-12672,CVE-2017-12675,CVE-2017-13060,CVE-2017-13146,CVE-2017-13648,CVE-2017-13658,CVE-2017-14326,CVE-2017-14533,CVE-2017-17881,CVE-2017-18022,CVE-2018-5246,CVE-2018-5247
Sources used:
openSUSE Leap 42.3 (src):    ImageMagick-6.8.8.1-49.1
openSUSE Leap 42.2 (src):    ImageMagick-6.8.8.1-30.21.1
Comment 18 Andreas Stieger 2018-01-31 20:27:55 UTC
releasing for Leap,done