Bug 1020439 - (CVE-2017-5507) VUL-0: CVE-2017-5507: Imagemagick: memory leak in mpc file handling
(CVE-2017-5507)
VUL-0: CVE-2017-5507: Imagemagick: memory leak in mpc file handling
Status: RESOLVED FIXED
Classification: Novell Products
Product: SUSE Security Incidents
Classification: Novell Products
Component: Incidents
unspecified
Other Other
: P3 - Medium : Normal
: unspecified
Assigned To: Security Team bot
Security Team bot
CVSSv2:SUSE:CVE-2017-5507:4.3:(AV:N/A...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2017-01-17 17:12 UTC by Mikhail Kasimov
Modified: 2017-05-19 22:38 UTC (History)
5 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail Kasimov 2017-01-17 17:12:17 UTC
Ref: http://seclists.org/oss-sec/2017/q1/110

=============================================
coders/mpc.c: memory leak in mpc file handling

Debian Bug: https://bugs.debian.org/851382

Fixed by: https://github.com/ImageMagick/ImageMagick/commit/4493d9ca1124564da17f9b628ef9d0f1a6be9738
=============================================
Comment 1 Swamp Workflow Management 2017-01-17 23:01:35 UTC
bugbot adjusting priority
Comment 2 Petr Gajdos 2017-01-19 20:26:36 UTC
Hi Mikhail,

I am not sure how the memory leak happens and how it is fixed. Could you please elaborate?
Comment 3 Mikhail Kasimov 2017-01-20 00:50:14 UTC
(In reply to Petr Gajdos from comment #2)
> Hi Mikhail,
> 
> I am not sure how the memory leak happens and how it is fixed. Could you
> please elaborate?

Hello!

Nope, sorry.:(
Comment 4 Petr Gajdos 2017-01-23 07:29:22 UTC
security-team, could you please help us (see comment 2)?

Thanks
Comment 7 Matthias Gerstner 2017-01-25 08:52:18 UTC
I've got an explanation from the upstream developers regarding the nature of the
memory leak that's been fixed in this commit:

> The MPC image format memory maps an existing ImageMagick pixel cache in
> memory. The previous AcquireImageColormap() method call (prior to this
> commit), subsequently calls SetImageStorageClass(). This in turn calls
> SyncImagePixelCache(), which improperly allocates a new pixel cache. Next, the
> MPC coder calls PersistPixelCache() which overwrites the previous pixel cache
> causing a memory leak. Now we allocate the image colormap inside the MPC
> module which avoids the spurious call to SyncImagePixelCache(). Its so simple
> :-).

I hope this helps you better understand the issue.
Comment 9 Matthias Gerstner 2017-01-25 13:15:13 UTC
My findings so far:

ImageMagick is affected:

SUSE:SLE-12:Update/ImageMagick/ImageMagick-6.8.8-1/coders/mpc.c:843,935
SUSE:SLE-11:Update/ImageMagick/ImageMagick-6.4.3/coders/mpc.c:743,835
-> PersistPixelCache() is just PersistCache() here, but seems to do the same

GraphicsMagick is not affected:

SUSE:SLE-11:Update/GraphicsMagick/GraphicsMagick-1.2.5/coders/mpc.c:714
-> AllocateImageColormap does not call SyncPixelCache()
openSUSE:Leap:42.1:Update/GraphicsMagick/GraphicsMagick-1.3.21/coders/mpc.c:732
-> AllocateImageColormap does not call SyncPixelCache()
openSUSE:Leap:42.2:Update/GraphicsMagick/GraphicsMagick-1.3.25/coders/mpc.c:794
-> AllocateImageColormap does not call SyncPixelCache()
Comment 10 Petr Gajdos 2017-01-26 12:12:28 UTC
Okay, assuming the second hunk is not related to this CVE. Thanks for your analysis.
Comment 11 Matthias Gerstner 2017-01-26 12:48:36 UTC
Hi Petr,

(In reply to pgajdos@suse.com from comment #10)
> Okay, assuming the second hunk is not related to this CVE.

You mean the part where the call to SetImageExtent() has been replaced? I just
had a look, that's also part of the issue, because this function also calls
SyncImagePixelCache().

Please include this, too. Thank you!
Comment 12 Petr Gajdos 2017-01-26 13:29:40 UTC
Unfortunately there is nothing like WidthResource or HeightResource in older versions of ImageMagick.
Comment 13 Matthias Gerstner 2017-01-26 13:54:55 UTC
(In reply to pgajdos@suse.com from comment #12)

> Unfortunately there is nothing like WidthResource or HeightResource in older
> versions of ImageMagick.

Ah sorry! I've justed looked for function SetImageExtent, which is existing in
our ImageMagick versions, but the function isn't called at all in mpc.c.

You can ignore the second hunk then.

Too much *Magick today for me ;-)
Comment 14 Petr Gajdos 2017-01-27 10:52:03 UTC
Affected: ImageMagick
Comment 15 Petr Gajdos 2017-01-27 11:04:51 UTC
Packages submitted, I believe all fixed.
Comment 16 Swamp Workflow Management 2017-02-21 14:11:07 UTC
SUSE-SU-2017:0529-1: An update that fixes 25 vulnerabilities is now available.

Category: security (moderate)
Bug References: 1017308,1017310,1017311,1017312,1017313,1017314,1017318,1017319,1017320,1017321,1017322,1017324,1017325,1017326,1017421,1020433,1020435,1020436,1020439,1020441,1020443,1020446,1020448
CVE References: CVE-2016-10046,CVE-2016-10048,CVE-2016-10049,CVE-2016-10050,CVE-2016-10051,CVE-2016-10052,CVE-2016-10059,CVE-2016-10060,CVE-2016-10061,CVE-2016-10062,CVE-2016-10063,CVE-2016-10064,CVE-2016-10065,CVE-2016-10068,CVE-2016-10069,CVE-2016-10070,CVE-2016-10071,CVE-2016-10144,CVE-2016-10145,CVE-2016-10146,CVE-2017-5506,CVE-2017-5507,CVE-2017-5508,CVE-2017-5510,CVE-2017-5511
Sources used:
SUSE Linux Enterprise Workstation Extension 12-SP2 (src):    ImageMagick-6.8.8.1-59.1
SUSE Linux Enterprise Workstation Extension 12-SP1 (src):    ImageMagick-6.8.8.1-59.1
SUSE Linux Enterprise Software Development Kit 12-SP2 (src):    ImageMagick-6.8.8.1-59.1
SUSE Linux Enterprise Software Development Kit 12-SP1 (src):    ImageMagick-6.8.8.1-59.1
SUSE Linux Enterprise Server for Raspberry Pi 12-SP2 (src):    ImageMagick-6.8.8.1-59.1
SUSE Linux Enterprise Server 12-SP2 (src):    ImageMagick-6.8.8.1-59.1
SUSE Linux Enterprise Server 12-SP1 (src):    ImageMagick-6.8.8.1-59.1
SUSE Linux Enterprise Desktop 12-SP2 (src):    ImageMagick-6.8.8.1-59.1
SUSE Linux Enterprise Desktop 12-SP1 (src):    ImageMagick-6.8.8.1-59.1
Comment 17 Swamp Workflow Management 2017-03-01 20:12:06 UTC
SUSE-SU-2017:0586-1: An update that fixes 21 vulnerabilities is now available.

Category: security (moderate)
Bug References: 1017308,1017310,1017311,1017312,1017313,1017314,1017318,1017319,1017320,1017321,1017322,1017324,1017326,1017421,1020433,1020435,1020436,1020439,1020441,1020443,1020448
CVE References: CVE-2016-10046,CVE-2016-10048,CVE-2016-10049,CVE-2016-10050,CVE-2016-10051,CVE-2016-10052,CVE-2016-10059,CVE-2016-10060,CVE-2016-10063,CVE-2016-10064,CVE-2016-10065,CVE-2016-10068,CVE-2016-10070,CVE-2016-10071,CVE-2016-10144,CVE-2016-10145,CVE-2016-10146,CVE-2017-5506,CVE-2017-5507,CVE-2017-5508,CVE-2017-5511
Sources used:
SUSE Linux Enterprise Software Development Kit 11-SP4 (src):    ImageMagick-6.4.3.6-7.65.1
SUSE Linux Enterprise Server 11-SP4 (src):    ImageMagick-6.4.3.6-7.65.1
SUSE Linux Enterprise Debuginfo 11-SP4 (src):    ImageMagick-6.4.3.6-7.65.1
Comment 18 Swamp Workflow Management 2017-03-02 14:11:16 UTC
openSUSE-SU-2017:0587-1: An update that fixes 25 vulnerabilities is now available.

Category: security (moderate)
Bug References: 1017308,1017310,1017311,1017312,1017313,1017314,1017318,1017319,1017320,1017321,1017322,1017324,1017325,1017326,1017421,1020433,1020435,1020436,1020439,1020441,1020443,1020446,1020448
CVE References: CVE-2016-10046,CVE-2016-10048,CVE-2016-10049,CVE-2016-10050,CVE-2016-10051,CVE-2016-10052,CVE-2016-10059,CVE-2016-10060,CVE-2016-10061,CVE-2016-10062,CVE-2016-10063,CVE-2016-10064,CVE-2016-10065,CVE-2016-10068,CVE-2016-10069,CVE-2016-10070,CVE-2016-10071,CVE-2016-10144,CVE-2016-10145,CVE-2016-10146,CVE-2017-5506,CVE-2017-5507,CVE-2017-5508,CVE-2017-5510,CVE-2017-5511
Sources used:
openSUSE Leap 42.2 (src):    ImageMagick-6.8.8.1-28.1
openSUSE Leap 42.1 (src):    ImageMagick-6.8.8.1-30.1
Comment 19 Matthias Gerstner 2017-03-06 09:57:53 UTC
GM not affected. IM all codestreams released. openSUSE comes from SLE. Closing.