Public Vulnerability Reports

Multiple Vendor xpdf PDF Viewer Buffer Overflow Vulnerability



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


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/

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();
          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.


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


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
 Red Hat Linux
 Fedora Core
 Debian Linux
 Gentoo Linux
 FreeBSD (ports)


Only open PDF files from trusted individuals.


A patch to address this vulnerability is available from:

Updated binaries (version 3.00pl2) are available from:


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 (, which standardizes names for
security problems.


11/23/2004   Initial notification sent to project maintainer
11/29/2004   Initial response received from project maintainer
12/21/2004   Coordinated public disclosure


The discoverer of this vulnerability wishes to remain anonymous.

Get paid for vulnerability research


Copyright © 2004 Verisign, 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 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.