Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 108365 - media-gfx/xloadimage, media-gfx/xli: buffer overflow (CVE-2001-0775)
Summary: media-gfx/xloadimage, media-gfx/xli: buffer overflow (CVE-2001-0775)
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Security
URL:
Whiteboard: C2 [glsa]
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-07 02:58 UTC by Thierry Carrez (RETIRED)
Modified: 2013-08-29 22:48 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
xli.patch (xli.patch,6.33 KB, patch)
2005-10-18 05:07 UTC, Thierry Carrez (RETIRED)
no flags Details | Diff
security-sprintf.patch (security-sprintf.patch,4.78 KB, patch)
2005-10-18 05:27 UTC, Thierry Carrez (RETIRED)
no flags Details | Diff
xli-gentoo.patch (xli-gentoo.patch,6.78 KB, patch)
2005-10-20 05:09 UTC, solar (RETIRED)
no flags Details | Diff
xloadimage-gentoo.patch (xloadimage-gentoo.patch,8.75 KB, patch)
2005-10-22 07:13 UTC, Thierry Carrez (RETIRED)
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thierry Carrez (RETIRED) gentoo-dev 2005-10-07 02:58:16 UTC
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 Tavis Ormandy (RETIRED) gentoo-dev 2005-10-07 05:47:26 UTC
> 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 Thierry Carrez (RETIRED) gentoo-dev 2005-10-07 06:24:21 UTC
desktop-misc: please patch
Comment 3 Thierry Carrez (RETIRED) gentoo-dev 2005-10-07 13:11:28 UTC
This is CAN-2005-3178
Comment 4 Carsten Lohrke (RETIRED) gentoo-dev 2005-10-11 18:00:54 UTC
According to DSA 859-1 media-gfx/xli is affected, too. 
Comment 5 Tavis Ormandy (RETIRED) gentoo-dev 2005-10-11 23:38:46 UTC
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 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2005-10-13 22:36:36 UTC
Patchers/desktop please apply patch. 
Comment 7 Thierry Carrez (RETIRED) gentoo-dev 2005-10-18 05:07:45 UTC
Created attachment 70925 [details, diff]
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 Thierry Carrez (RETIRED) gentoo-dev 2005-10-18 05:27:56 UTC
Created attachment 70928 [details, diff]
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 Thierry Carrez (RETIRED) gentoo-dev 2005-10-18 05:29:09 UTC
Setting to Auditing, as some more work is definitely needed on those packages.
Comment 10 solar (RETIRED) gentoo-dev 2005-10-20 05:09:46 UTC
Created attachment 71064 [details, diff]
xli-gentoo.patch

Fixes prototype in xli.h with FindImage()
Package built with -fbounds-checking and passes local regression testing.
Comment 11 Thierry Carrez (RETIRED) gentoo-dev 2005-10-21 02:35:39 UTC
ok, patch for xli is ready, some more work needed on the xloadimage patch.
Comment 12 Thierry Carrez (RETIRED) gentoo-dev 2005-10-22 07:13:06 UTC
Created attachment 71196 [details, diff]
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 Thierry Carrez (RETIRED) gentoo-dev 2005-10-22 07:14:43 UTC
desktop-misc: please patch.
Comment 14 Thierry Carrez (RETIRED) gentoo-dev 2005-10-26 08:17:41 UTC
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 Krzysztof Pawlik (RETIRED) gentoo-dev 2005-10-26 12:00:06 UTC
xloadimage-4.1-r4 in CVS.
Comment 16 Thierry Carrez (RETIRED) gentoo-dev 2005-10-27 00:35:01 UTC
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 Fabian Groffen gentoo-dev 2005-10-27 01:45:26 UTC
xli-1.17.0-r2 and xloadimage-4.1-r4 stable on ppc-macos
Comment 18 Bryan Østergaard (RETIRED) gentoo-dev 2005-10-27 02:58:35 UTC
Stable on alpha.
Comment 19 Gustavo Zacarias (RETIRED) gentoo-dev 2005-10-27 07:22:41 UTC
sparc stable.
Comment 20 Brent Baude (RETIRED) gentoo-dev 2005-10-27 07:58:05 UTC
Marked both stable. thanks
Comment 21 Simon Stelling (RETIRED) gentoo-dev 2005-10-27 13:22:42 UTC
amd64 happy
Comment 22 Mark Loeser (RETIRED) gentoo-dev 2005-10-28 00:22:59 UTC
x86 done
Comment 23 Michael Hanselmann (hansmi) (RETIRED) gentoo-dev 2005-10-29 08:44:14 UTC
Stable on ppc and hppa.
Comment 24 Bryan Østergaard (RETIRED) gentoo-dev 2005-10-29 18:47:00 UTC
Stable on ia64.
Comment 25 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2005-10-30 09:52:13 UTC
GLSA 200510-26  
 
mips don't forget to mark stable to benifit from the GLSA. 
Comment 26 Hardave Riar (RETIRED) gentoo-dev 2005-11-20 05:34:32 UTC
Stable on mips.
Comment 27 GLSAMaker/CVETool Bot gentoo-dev 2013-08-29 22:48:20 UTC
CVE-2001-0775 (http://nvd.nist.gov/nvd.cfm?cvename=CVE-2001-0775):
  Buffer overflow in xloadimage 4.1 (aka xli 1.16 and 1.17) in Linux allows
  remote attacker to execute arbitrary code via a FACES format image
  containing a long (1) Firstname or (2) Lastname field.