Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 108365
Alias:
Product:
Component:
Status: RESOLVED
Resolution: FIXED
Assigned To: Gentoo Security <security@gentoo.org>
Hardware:
OS:
Version:
Priority:
Severity:
Reporter: Thierry Carrez (RETIRED) <koon@gentoo.org>
Add CC:
CC:
Remove selected CCs
URL:
Summary:
Status Whiteboard:
Keywords:
Flags: Requestee:
 
 
  ()

Filename Description Type Creator Created Size Actions
xli.patch xli.patch patch Thierry Carrez (RETIRED) 2005-10-18 05:07 0000 6.33 KB Details | Diff
security-sprintf.patch security-sprintf.patch patch Thierry Carrez (RETIRED) 2005-10-18 05:27 0000 4.78 KB Details | Diff
xli-gentoo.patch xli-gentoo.patch patch solar 2005-10-20 05:09 0000 6.78 KB Details | Diff
xloadimage-gentoo.patch xloadimage-gentoo.patch patch Thierry Carrez (RETIRED) 2005-10-22 07:13 0000 8.75 KB Details | Diff
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 108365 depends on: Show dependency tree
Bug 108365 blocks:

Additional Comments: (this is where you put emerge --info)


Not eligible to see or edit group visibility for this bug.






View Bug Activity   |   Format For Printing   |   XML   |   Clone This Bug


Description:   Opened: 2005-10-07 02:58 0000
From a Bugtraq mail by Ariel Berkman :

==============================
While creating a stripped down version of xloadimage, I have discovered
three buffer overflows in xloadimage when handling the image title name.

Unlike most of the supported image formats in xloadimage, the NIFF image
format can store a title name of arbitrary length as part of the image file.

When xloadimage is processing a loaded image, it is creating a new Image
object and then writing the processed image to it. At that point, it will
also copy the title from the old image to the newly created image.

The 'zoom', 'reduce', and 'rotate' functions are using a fixed length buffer
to construct the new title name when an image processing is done. Since the
title name in a NIFF format is of varying length, and there are insufficient
buffer size validations, the buffer can be overflowed.

A malicious user can construct a NIFF file that when viewed and processed
(with either zoom, reduce or rotate) by xloadimage, will cause the program
to overwrite the return address and execute arbitrary code.

Proof of concept for the 'zoom' image processing bug, tested on a x86
computer running Gentoo Linux:

emerge xloadimage
xloadimage -zoom 20 small.niff			(small.niff is attached)

This will execute '/bin/sh'.

Note: some systems may have the (/proc/sys/kernel/)randomize_va_space option
enabled, which will cause the program to crash instead of executing /bin/sh
in most cases. Using a larger NIFF file (large.niff.gz [800KB unzipped]), it
is possible to execute arbitrary code even when the random address space
option is enabled (with about 33% success rate).

The 'reduce' and 'rotate' bugs are similar, but require a slightly different
NIFF file and different ( processing options.

The bugs are in :

zoom.c, zoom() writes an arbitrarily large buffer into a 8192 bytes sized
buffer buf[].

reduce.c, reduce() writes an arbitrarily large buffer into a 8192 bytes
sized buffer buf[].

rotate.c, rotate() writes an arbitrarily large buffer into a 8192 bytes
sized buffer buf[].

The bugs discussed above exist in the latest xloadimage package that Gentoo
provides (xloadimage.4.1-r3), and the latest xloadimage source package from
debian I could find (xloadimage_4.1-14.2). I haven't tested xloadimage
packages from other sources.
=========================

Auditors: looks real, please doublecheck...

------- Comment #1 From Tavis Ormandy (RETIRED) 2005-10-07 05:47:26 0000 -------
> zoom.c, zoom() writes an arbitrarily large buffer into a 8192 bytes sized
buffer buf[].

confirmed, just needs s/sprintf/snprintf/

> reduce.c, reduce() writes an arbitrarily large buffer into a 8192 bytes
sized buffer buf[].

confirmed, same again.

> rotate.c, rotate() writes an arbitrarily large buffer into a 8192 bytes
sized buffer buf[].

yup.

note that these attacks requires the user to process (ie zoom, reduce) the image 
with xloadimage, just viewing it is not enough.

------- Comment #2 From Thierry Carrez (RETIRED) 2005-10-07 06:24:21 0000 -------
desktop-misc: please patch

------- Comment #3 From Thierry Carrez (RETIRED) 2005-10-07 13:11:28 0000 -------
This is CAN-2005-3178

------- Comment #4 From Carsten Lohrke 2005-10-11 18:00:54 0000 -------
According to DSA 859-1 media-gfx/xli is affected, too. 

------- Comment #5 From Tavis Ormandy (RETIRED) 2005-10-11 23:38:46 0000 -------
xli does not support niff iages, however the same code is in there and is 
exploitable via xpm images. the fix is the same, -sprintf +snprintf

------- Comment #6 From Sune Kloppenborg Jeppesen 2005-10-13 22:36:36 0000 -------
Patchers/desktop please apply patch. 

------- Comment #7 From Thierry Carrez (RETIRED) 2005-10-18 05:07:45 0000 -------
Created an attachment (id=70925) [details]
xli.patch

Patch for xli from solar.

Patches additional problems of format string bug in debug macro, unchecked
pathname length in path.c, and an unchecked strcat in zoom.c (forgotten in the
Debian patch ?).

------- Comment #8 From Thierry Carrez (RETIRED) 2005-10-18 05:27:56 0000 -------
Created an attachment (id=70928) [details]
security-sprintf.patch

Patch for xloadimage from Debian.

This patch is sufficient to patch what this vulnerability is about. However,
there are some other things:
- path overflow in config.c (same as xli's path.c)
- format string in debug macro in rle.c (same as xli's rlelib.c)

------- Comment #9 From Thierry Carrez (RETIRED) 2005-10-18 05:29:09 0000 -------
Setting to Auditing, as some more work is definitely needed on those packages.

------- Comment #10 From solar 2005-10-20 05:09:46 0000 -------
Created an attachment (id=71064) [details]
xli-gentoo.patch

Fixes prototype in xli.h with FindImage()
Package built with -fbounds-checking and passes local regression testing.

------- Comment #11 From Thierry Carrez (RETIRED) 2005-10-21 02:35:39 0000 -------
ok, patch for xli is ready, some more work needed on the xloadimage patch.

------- Comment #12 From Thierry Carrez (RETIRED) 2005-10-22 07:13:06 0000 -------
Created an attachment (id=71196) [details]
xloadimage-gentoo.patch

Here's my patch for xloadimage (= patch from Debian + adaptation of solar's
patch)
Compiles ok and seems to work.

------- Comment #13 From Thierry Carrez (RETIRED) 2005-10-22 07:14:43 0000 -------
desktop-misc: please patch.

------- Comment #14 From Thierry Carrez (RETIRED) 2005-10-26 08:17:41 0000 -------
xli-1.17.0-r2 in portage thx to Taviso.
nelchael said he will handle xloadimage, let's wait for that before calling the
arch testers.

------- Comment #15 From Krzysiek Pawlik 2005-10-26 12:00:06 0000 -------
xloadimage-4.1-r4 in CVS.

------- Comment #16 From Thierry Carrez (RETIRED) 2005-10-27 00:35:01 0000 -------
Thx Nelchael, arch testers please test and mark stable...

Target KEYWORDS:
xli-1.17.0-r2 "alpha amd64 arm hppa ia64 ~mips ppc ppc-macos ppc64 sparc x86"
xloadimage-4.1-r4 "alpha amd64 arm hppa ia64 mips ppc ppc64 ppc-macos sparc x86"

------- Comment #17 From Fabian Groffen 2005-10-27 01:45:26 0000 -------
xli-1.17.0-r2 and xloadimage-4.1-r4 stable on ppc-macos

------- Comment #18 From Bryan Østergaard (RETIRED) 2005-10-27 02:58:35 0000 -------
Stable on alpha.

------- Comment #19 From Gustavo Zacarias (RETIRED) 2005-10-27 07:22:41 0000 -------
sparc stable.

------- Comment #20 From Brent Baude 2005-10-27 07:58:05 0000 -------
Marked both stable. thanks

------- Comment #21 From Simon Stelling (RETIRED) 2005-10-27 13:22:42 0000 -------
amd64 happy

------- Comment #22 From Mark Loeser 2005-10-28 00:22:59 0000 -------
x86 done

------- Comment #23 From Michael Hanselmann (hansmi) (RETIRED) 2005-10-29 08:44:14 0000 -------
Stable on ppc and hppa.

------- Comment #24 From Bryan Østergaard (RETIRED) 2005-10-29 18:47:00 0000 -------
Stable on ia64.

------- Comment #25 From Sune Kloppenborg Jeppesen 2005-10-30 09:52:13 0000 -------
GLSA 200510-26  
 
mips don't forget to mark stable to benifit from the GLSA. 

------- Comment #26 From Hardave Riar (RETIRED) 2005-11-20 05:34:32 0000 -------
Stable on mips.

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug