<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>75191</bug_id>
          
          <creation_ts>2004-12-21 08:44 0000</creation_ts>
          <short_desc>app-text/xpdf: New buffer overflow (CAN-2004-1125)</short_desc>
          <delta_ts>2006-03-23 19:21:02 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Security</product>
          <component>Vulnerabilities</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          <bug_file_loc>http://www.idefense.com/application/poi/display?id=172&amp;type=vulnerabilities&amp;flashstatus=true</bug_file_loc>
          <status_whiteboard>A2 [glsa]</status_whiteboard>
          
          <priority>P2</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>koon@gentoo.org</reporter>
          <assigned_to>security@gentoo.org</assigned_to>
          <cc>printing@gentoo.org</cc>

      

      
          <long_desc isprivate="0">
            <who>koon@gentoo.org</who>
            <bug_when>2004-12-21 08:44:11 0000</bug_when>
            <thetext>Multiple Vendor xpdf PDF Viewer Buffer Overflow Vulnerability 

iDEFENSE Security Advisory 12.21.04
www.idefense.com/application/poi/display?id=172&amp;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-&gt;lookup(&quot;Mask&quot;, &amp;maskObj);
        if (maskObj.isArray()) {
          for (i = 0; i &lt; maskObj.arrayGetLength(); ++i) {
        maskObj.arrayGet(i, &amp;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.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>koon@gentoo.org</who>
            <bug_when>2004-12-21 08:50:45 0000</bug_when>
            <thetext>The hideous security bug with multiple tentacles in other packages is back...
printing : please bump xpdf using provided patch.
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>koon@gentoo.org</who>
            <bug_when>2004-12-21 08:51:33 0000</bug_when>
            <thetext>Created an attachment (id=46548)
xpdf-3.00pl2.patch

patch from upstream, linked from iDEFENSE advisory</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>carlo@gentoo.org</who>
            <bug_when>2004-12-21 08:52:20 0000</bug_when>
            <thetext>&gt;The hideous security bug with multiple tentacles in other packages is back...

You say it. :(</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>lanius@gentoo.org</who>
            <bug_when>2004-12-24 05:34:33 0000</bug_when>
            <thetext>Bumped to -r7, stable on x86, ~alpha ~amd64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vorlon@gentoo.org</who>
            <bug_when>2004-12-24 08:12:08 0000</bug_when>
            <thetext>arches, please test xpdf-3.00-r7 and mark stable if possible

current KEYWORDS=&quot;~alpha ~amd64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc x86&quot;
target KEYWORDS=&quot;alpha amd64 hppa ia64 ppc ppc64 sparc x86&quot;</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>fmccor@gentoo.org</who>
            <bug_when>2004-12-24 14:58:29 0000</bug_when>
            <thetext>Sparc is done.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>kugelfang@gentoo.org</who>
            <bug_when>2004-12-25 09:29:22 0000</bug_when>
            <thetext>Stable on amd64.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>corsair@gentoo.org</who>
            <bug_when>2004-12-25 12:53:03 0000</bug_when>
            <thetext>stable on ppc64</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>kloeri@gentoo.org</who>
            <bug_when>2004-12-26 16:29:21 0000</bug_when>
            <thetext>Stable on alpha.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>sejo@gentoo.org</who>
            <bug_when>2004-12-27 00:31:40 0000</bug_when>
            <thetext>stable on ppc</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>koon@gentoo.org</who>
            <bug_when>2004-12-28 05:09:14 0000</bug_when>
            <thetext>GLSA 200412-24
ia64, hppa : please mark gpdf stable to benefit from GLSA</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>killerfox@gentoo.org</who>
            <bug_when>2005-06-26 05:19:15 0000</bug_when>
            <thetext>Already stable on hppa</thetext>
          </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>46548</attachid>
            <date>2004-12-21 08:51 0000</date>
            <desc>xpdf-3.00pl2.patch</desc>
            <filename>xpdf-3.00pl2.patch</filename>
            <type>text/plain</type>
            <data encoding="base64">KioqIEdmeC5jYy5vcmlnCVN1biBEZWMgMTIgMTY6MDQ6NDMgMjAwNAotLS0gR2Z4LmNjCVN1biBE
ZWMgMTIgMTY6MDU6MTYgMjAwNAoqKioqKioqKioqKioqKioKKioqIDI2NTQsMjY2MCAqKioqCiAg
ICAgIGhhdmVNYXNrID0gZ0ZhbHNlOwogICAgICBkaWN0LT5s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wor
ICAgICBuQ29tcHNBID0gZ2Z4Q29sb3JNYXhDb21wczsKKyAgIH0KICAgIGlmIChkaWN0LT5sb29r
dXAoIkFsdGVybmF0ZSIsICZvYmoyKS0+aXNOdWxsKCkgfHwKICAgICAgICAhKGFsdEEgPSBHZnhD
b2xvclNwYWNlOjpwYXJzZSgmb2JqMikpKSB7CiAgICAgIHN3aXRjaCAobkNvbXBzQSkgewoqKioq
KioqKioqKioqKioKKioqIDEwNTQsMTA2MCAqKioqCiAgICB9CiAgICBuQ29tcHNBID0gb2JqMS5h
cnJheUdldExlbmd0aCgpOwogICAgaWYgKG5Db21wc0EgPiBnZnhDb2xvck1heENvbXBzKSB7CiEg
ICAgIGVycm9yKC0xLCAiRGV2aWNlTiBjb2xvciBzcGFjZSB3aXRoIG1vcmUgdGhhbiAlZCA+ICVk
IGNvbXBvbmVudHMiLAogIAkgIG5Db21wc0EsIGdmeENvbG9yTWF4Q29tcHMpOwogICAgICBuQ29t
cHNBID0gZ2Z4Q29sb3JNYXhDb21wczsKICAgIH0KLS0tIDEwNTksMTA2NSAtLS0tCiAgICB9CiAg
ICBuQ29tcHNBID0gb2JqMS5hcnJheUdldExlbmd0aCgpOwogICAgaWYgKG5Db21wc0EgPiBnZnhD
b2xvck1heENvbXBzKSB7CiEgICAgIGVycm9yKC0xLCAiRGV2aWNlTiBjb2xvciBzcGFjZSB3aXRo
IHRvbyBtYW55ICglZCA+ICVkKSBjb21wb25lbnRzIiwKICAJICBuQ29tcHNBLCBnZnhDb2xvck1h
eENvbXBzKTsKICAgICAgbkNvbXBzQSA9IGdmeENvbG9yTWF4Q29tcHM7CiAgICB9Cg==
</data>        

          </attachment>
    </bug>

</bugzilla>