Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 75191 - app-text/xpdf: New buffer overflow (CAN-2004-1125)
Summary: app-text/xpdf: New buffer overflow (CAN-2004-1125)
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All All
: High major (vote)
Assignee: Gentoo Security
URL: http://www.idefense.com/application/p...
Whiteboard: A2 [glsa]
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-21 08:44 UTC by Thierry Carrez (RETIRED)
Modified: 2006-03-23 19:21 UTC (History)
1 user (show)

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


Attachments
xpdf-3.00pl2.patch (xpdf-3.00pl2.patch,1.61 KB, patch)
2004-12-21 08:51 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 2004-12-21 08:44:11 UTC
Multiple Vendor xpdf PDF Viewer Buffer Overflow Vulnerability 

iDEFENSE Security Advisory 12.21.04
www.idefense.com/application/poi/display?id=172&type=vulnerabilities
December 21, 2004

I. BACKGROUND

Xpdf is an open-source viewer for Portable Document Format (PDF) files.

II. DESCRIPTION

Remote exploitation of a buffer overflow vulnerability in the xpdf PDF 
viewer, as included in multiple Linux distributions, could allow 
attackers to execute arbitrary code as the user viewing a PDF file. The 
offending code can be found in the Gfx::doImage() function in the source

file xpdf/Gfx.cc. 

void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
  Dict *dict;
  int width, height;
  int bits;
  GBool mask;
  GBool invert;
  GfxColorSpace *colorSpace;
  GfxImageColorMap *colorMap;
  Object maskObj;
  GBool haveMask;
  int maskColors[2*gfxColorMaxComps];
  Object obj1, obj2;
  int i;

  ...
    // get the mask
    haveMask = gFalse;
    dict->lookup("Mask", &maskObj);
        if (maskObj.isArray()) {
          for (i = 0; i < maskObj.arrayGetLength(); ++i) {
        maskObj.arrayGet(i, &obj1);
[!]         maskColors[i] = obj1.getInt();
            obj1.free();
          }
          haveMask = gTrue;
        }
  ...
}  


Due to the fact that the loop boundaries are not less than the storage 
area, the maskColors array is eventually filled up. After that, local 
variables and other stack memory is overwritten. This ultimately leads 
to control of program flow and arbitrary code execution.

III. ANALYSIS

The severity of this issue is mitigated by the fact that several of the 
local overwritten variables in doImage() are referenced prior to EIP 
being restored; therefore, before the attack gains control of the target

process. However, an attacker with knowledge of the remote operating 
system can construct and validate a malicious payload before attempting 
exploitation, thus increasing the chances of success. An attacker must 
convince a target user to open the malicious file to exploit this 
vulnerability.

IV. DETECTION

iDEFENSE has confirmed the existence of this vulnerability in version 
3.00 of xpdf. It is suspected previous versions are also vulnerable. 

The following Linux distributions are affected by this vulnerability:

	SUSE Linux 
	Redhat Linux 
	Fedora Linux 
	Debian Linux 
	Gentoo Linux 
	FreeBSD (ports) 
	OpenBSD 

V. WORKAROUND

Only open PDF files from trusted individuals.

VI. VENDOR RESPONSE

A patch to address this vulnerability is available from:

    ftp://ftp.foolabs.com/pub/xpdf/xpdf-3.00pl2.patch

Updated binaries (version 3.00pl2) are available from:

    http://www.foolabs.com/xpdf/download.html

VII. CVE INFORMATION

The Common Vulnerabilities and Exposures (CVE) project has assigned the
names CAN-2004-1125 to these issues. This is a candidate for inclusion
in the CVE list (http://cve.mitre.org), which standardizes names for
security problems.

VIII. DISCLOSURE TIMELINE

11/23/2004  Initial vendor notification
11/29/2004  Initial vendor response
12/21/2004  Coordinated public disclosure

IX. CREDIT

The discoverer of this vulnerability wishes to remain anonymous.

Get paid for vulnerability research
http://www.idefense.com/poi/teams/vcp.jsp

X. LEGAL NOTICES

Copyright (c) 2004 iDEFENSE, Inc.

Permission is granted for the redistribution of this alert
electronically. It may not be edited in any way without the express
written consent of iDEFENSE. If you wish to reprint the whole or any
part of this alert in any other medium other than electronically, please
email customerservice@idefense.com for permission.

Disclaimer: The information in the advisory is believed to be accurate
at the time of publishing based on currently available information. Use
of the information constitutes acceptance for use in an AS IS condition.
There are no warranties with regard to this information. Neither the
author nor the publisher accepts any liability for any direct, indirect,
or consequential loss or damage arising from use of, or reliance on,
this information.
Comment 1 Thierry Carrez (RETIRED) gentoo-dev 2004-12-21 08:50:45 UTC
The hideous security bug with multiple tentacles in other packages is back...
printing : please bump xpdf using provided patch.
Comment 2 Thierry Carrez (RETIRED) gentoo-dev 2004-12-21 08:51:33 UTC
Created attachment 46548 [details, diff]
xpdf-3.00pl2.patch

patch from upstream, linked from iDEFENSE advisory
Comment 3 Carsten Lohrke (RETIRED) gentoo-dev 2004-12-21 08:52:20 UTC
>The hideous security bug with multiple tentacles in other packages is back...

You say it. :(
Comment 4 Heinrich Wendel (RETIRED) gentoo-dev 2004-12-24 05:34:33 UTC
Bumped to -r7, stable on x86, ~alpha ~amd64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc
Comment 5 Matthias Geerdsen (RETIRED) gentoo-dev 2004-12-24 08:12:08 UTC
arches, please test xpdf-3.00-r7 and mark stable if possible

current KEYWORDS="~alpha ~amd64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc x86"
target KEYWORDS="alpha amd64 hppa ia64 ppc ppc64 sparc x86"
Comment 6 Ferris McCormick (RETIRED) gentoo-dev 2004-12-24 14:58:29 UTC
Sparc is done.
Comment 7 Danny van Dyk (RETIRED) gentoo-dev 2004-12-25 09:29:22 UTC
Stable on amd64.
Comment 8 Markus Rothe (RETIRED) gentoo-dev 2004-12-25 12:53:03 UTC
stable on ppc64
Comment 9 Bryan Østergaard (RETIRED) gentoo-dev 2004-12-26 16:29:21 UTC
Stable on alpha.
Comment 10 Jochen Maes (RETIRED) gentoo-dev 2004-12-27 00:31:40 UTC
stable on ppc
Comment 11 Thierry Carrez (RETIRED) gentoo-dev 2004-12-28 05:09:14 UTC
GLSA 200412-24
ia64, hppa : please mark gpdf stable to benefit from GLSA
Comment 12 René Nussbaumer (RETIRED) gentoo-dev 2005-06-26 05:19:15 UTC
Already stable on hppa