Bug 1027024 (CVE-2017-6313) - VUL-1: CVE-2017-6313: gdk-pixbuf: An dangerous integer underflow in io-icns.c
Summary: VUL-1: CVE-2017-6313: gdk-pixbuf: An dangerous integer underflow in io-icns.c
Status: RESOLVED FIXED
Alias: CVE-2017-6313
Product: SUSE Security Incidents
Classification: Novell Products
Component: Incidents (show other bugs)
Version: unspecified
Hardware: Other Other
: P4 - Low : Normal
Target Milestone: ---
Assignee: Security Team bot
QA Contact: Security Team bot
URL: https://smash.suse.de/issue/180925/
Whiteboard: CVSSv2:SUSE:CVE-2017-6313:5.0:(AV:N/A...
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-27 07:28 UTC by Marcus Meissner
Modified: 2024-05-09 17:56 UTC (History)
6 users (show)

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


Attachments
infinite.icns.icns (32 bytes, image/x-icns)
2017-02-28 10:45 UTC, Marcus Meissner
Details
bad.ico.icns (518 bytes, image/x-icns)
2017-02-28 10:45 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-02-27 07:28:54 UTC
http://seclists.org/oss-sec/2017/q1/466

1. An dangerous integer underflow in io-icns.c [1]
--------------------------------------------------
io-icns.c is the source code for the loader of Macintosh icons.

An integer underflow I found allows an attacker to lead to different calls
to gdk_pixbuf_loader_write with a huge (2^32-1) count (size of buffer) that
can be bigger than the actual size of given buffer. It is possible to give
the loader any data we want so we can call any desired loader that it's
data is recognized. This may lead to various behaviors - multiple
out-of-buffer reads, infinite loops, or allocation attempt with the size.
Possibly other behaviors I did not test for (I didn't really check all
available loaders).

1.1 The bug
-----------
In the load_resources function (io-icns.c:63), inside the size switch (line
101), all the cases set plen or mlen to: blocklen - sizeof
(IcnsBlockHeader);
See lines 109, 117, 127, 134, 139, 146, 151, 158 and 163.
blocklen is set in line 95:

blocklen = GUINT32_FROM_BE (header->size);

There are no checks on the size of blocklen and if it is set to less than
sizeof (IcnsBlockHeader) (should be 8) there is an integer underflow.

This is dangerous because it's value is later passed to
gdk_pixbuf_loader_write (line 262) when size is 256. This allows an
attacker to craft a file that will end up calling to a desired loader with
a bogus size that is much larger than the actual buffer size.

Possible exploits of the bug:
1. Adding a bmp, or a an ico image data after the header will cause an
out-of-buffer read.
2. With a tiff image it would lead to an infinite loop (see bug 2).
3. With a gif, a tga or another icns after the header the code will try to
allocate as much as count bytes (and most likely fail on a size of 2^32-1).
Otherwise if the actual data size is less than 4096 there is an
out-of-bounds read.
4. With another icns it is possible to reach another out-of-bounds
4.1 If this out-of-bounds read gets zeros we will have an infinite loop
Comment 1 Marcus Meissner 2017-02-27 07:29:19 UTC
CVE-2017-6313
Comment 2 Marcus Meissner 2017-02-27 07:34:02 UTC
https://bugzilla.gnome.org/show_bug.cgi?id=779016
Comment 3 Swamp Workflow Management 2017-02-27 23:00:38 UTC
bugbot adjusting priority
Comment 4 Marcus Meissner 2017-02-28 10:45:26 UTC
Created attachment 715695 [details]
infinite.icns.icns

QA REPRODUCER:

(we will cause an infinite loop)

eog infinite.icns.icns  & 

top

BEFORE: 
eog uses 100% CPU trying to decode this ICO file

AFTER:
eog display / errors on image
Comment 5 Marcus Meissner 2017-02-28 10:45:53 UTC
Created attachment 715696 [details]
bad.ico.icns

QA REPRODUCER 2:

eog bad.ico.icns

will crash with segmentation fault
Comment 6 Marcus Meissner 2017-02-28 10:46:27 UTC
no patch upstream yet
Comment 7 Scott Reeves 2017-03-03 22:41:04 UTC
Hi Yifan, can you have someone on your team take this.
Comment 8 Yifan Jiang 2017-03-06 02:46:24 UTC
Hi Xiaoguang,

Would you help to take care of this, thank you!
Comment 13 Swamp Workflow Management 2017-09-06 19:07:41 UTC
SUSE-SU-2017:2381-1: An update that solves 5 vulnerabilities and has one errata is now available.

Category: security (important)
Bug References: 1027024,1027025,1027026,1048289,1048544,1049877
CVE References: CVE-2017-2862,CVE-2017-2870,CVE-2017-6312,CVE-2017-6313,CVE-2017-6314
Sources used:
SUSE Linux Enterprise Software Development Kit 12-SP3 (src):    gdk-pixbuf-2.34.0-19.5.1
SUSE Linux Enterprise Software Development Kit 12-SP2 (src):    gdk-pixbuf-2.34.0-19.5.1
SUSE Linux Enterprise Server for Raspberry Pi 12-SP2 (src):    gdk-pixbuf-2.34.0-19.5.1
SUSE Linux Enterprise Server 12-SP3 (src):    gdk-pixbuf-2.34.0-19.5.1
SUSE Linux Enterprise Server 12-SP2 (src):    gdk-pixbuf-2.34.0-19.5.1
SUSE Linux Enterprise Desktop 12-SP3 (src):    gdk-pixbuf-2.34.0-19.5.1
SUSE Linux Enterprise Desktop 12-SP2 (src):    gdk-pixbuf-2.34.0-19.5.1
Comment 14 Swamp Workflow Management 2017-09-08 19:07:26 UTC
openSUSE-SU-2017:2393-1: An update that solves 5 vulnerabilities and has one errata is now available.

Category: security (important)
Bug References: 1027024,1027025,1027026,1048289,1048544,1049877
CVE References: CVE-2017-2862,CVE-2017-2870,CVE-2017-6312,CVE-2017-6313,CVE-2017-6314
Sources used:
openSUSE Leap 42.3 (src):    gdk-pixbuf-2.34.0-10.1
openSUSE Leap 42.2 (src):    gdk-pixbuf-2.34.0-7.3.1
Comment 16 Hans Petter Jansson 2018-04-30 15:19:34 UTC
Closing as fixed.
Comment 21 Swamp Workflow Management 2018-08-21 16:10:13 UTC
SUSE-SU-2018:2470-1: An update that solves 5 vulnerabilities and has one errata is now available.

Category: security (moderate)
Bug References: 1027024,1027025,1027026,1039465,1048289,1048544
CVE References: CVE-2017-2862,CVE-2017-2870,CVE-2017-6312,CVE-2017-6313,CVE-2017-6314
Sources used:
SUSE Linux Enterprise Software Development Kit 11-SP4 (src):    gtk2-2.18.9-0.45.8.1
SUSE Linux Enterprise Server 11-SP4 (src):    gtk2-2.18.9-0.45.8.1
SUSE Linux Enterprise Debuginfo 11-SP4 (src):    gtk2-2.18.9-0.45.8.1
Comment 22 Marcus Meissner 2018-10-10 12:11:24 UTC
gdk-pixbuf for sle11 missing still here I think
Comment 26 Michael Gorse 2019-09-02 01:33:17 UTC
Are you sure that this applies to SLE-11 gdk-pixbuf? io-icns.c is not present there.
Comment 27 Yifan Jiang 2019-09-02 01:35:47 UTC
Hi Marcus,

Please refer to the comment immediately above.
Comment 28 Marcus Meissner 2019-09-11 13:06:51 UTC
I removed the affectedness fopr SLE11 and older.
Comment 29 Michael Gorse 2019-09-11 18:37:50 UTC
I think that gtk2 is affected on SLE-11, but not the older gdk-pixbuf.