Bug 137156 (CVE-2005-3193) - VUL-0: CVE-2005-3193: xpdf: overflows
Summary: VUL-0: CVE-2005-3193: xpdf: overflows
Status: RESOLVED FIXED
: 142106 (view as bug list)
Alias: CVE-2005-3193
Product: SUSE Security Incidents
Classification: Novell Products
Component: Incidents (show other bugs)
Version: unspecified
Hardware: Other Other
: P5 - None : Normal
Target Milestone: ---
Assignee: Security Team bot
QA Contact: Security Team bot
URL:
Whiteboard: CVE-2005-3628: CVSS v2 Base Score: 7....
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-06 16:32 UTC by Ludwig Nussel
Modified: 2017-07-10 12:52 UTC (History)
9 users (show)

See Also:
Found By: Other
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
xpdf-3.01pl1.patch from xpdf home page (4.82 KB, patch)
2005-12-06 16:34 UTC, Ludwig Nussel
Details | Diff
patch for 2.02 from redhat (2.35 KB, patch)
2005-12-06 16:56 UTC, Dirk Mueller
Details | Diff
updated patch for CAN-2005-3193 (4.30 KB, patch)
2005-12-08 13:31 UTC, Dirk Mueller
Details | Diff
goo's gmallocn integer overflow fix (774 bytes, patch)
2005-12-09 12:48 UTC, Dirk Mueller
Details | Diff
combined patch by Martin Pitt aginst 3.00 that also fixes potentially undefined behavior with signed integer multiplications (4.16 KB, patch)
2005-12-09 14:56 UTC, Ludwig Nussel
Details | Diff
updated patch from Martin Pitt (5.30 KB, patch)
2005-12-12 09:58 UTC, Dirk Mueller
Details | Diff
Overflows found by Chris Evans (1.43 KB, patch)
2005-12-12 09:59 UTC, Dirk Mueller
Details | Diff
new patch for overflows found by Chris evans and similiar ones (3.07 KB, patch)
2005-12-13 13:04 UTC, Dirk Mueller
Details | Diff
xpdf 2.02 combined patch fixes all currently knows problems (6.89 KB, patch)
2005-12-15 15:52 UTC, Ludwig Nussel
Details | Diff
xpdf 3.00 combined patch fixes all currently known problems (8.50 KB, patch)
2005-12-15 15:53 UTC, Ludwig Nussel
Details | Diff
xpdf 3.01pl1 combined patch (8.41 KB, patch)
2005-12-15 16:25 UTC, Dirk Mueller
Details | Diff
untested backport to xpdf1 (3.51 KB, patch)
2006-01-11 16:30 UTC, Ludwig Nussel
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ludwig Nussel 2005-12-06 16:32:35 UTC
The issue is public.

Considering kpdf:
   6 remote non-root user
  +1 default package
  +1 default active
  -1 user interaction
  +1 command execution

Total Score: 8 (Critical)

Date: Tue, 6 Dec 2005 10:29:16 -0500
From: bugzilla@redhat.com
To: enterprise-watch-list@redhat.com
Subject: [security] [RHSA-2005:840-01] Important: xpdf security update

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

- ---------------------------------------------------------------------
                   Red Hat Security Advisory

Synopsis:          Important: xpdf security update
Advisory ID:       RHSA-2005:840-01
Advisory URL:      https://rhn.redhat.com/errata/RHSA-2005-840.html
Issue date:        2005-12-06
Updated on:        2005-12-06
Product:           Red Hat Enterprise Linux
CVE Names:         CAN-2005-3193
- ---------------------------------------------------------------------

[...]

3. Problem description:

The xpdf package is an X Window System-based viewer for Portable Document
Format (PDF) files.

Several flaws were discovered in Xpdf.  An attacker could construct a
carefully crafted PDF file that could cause Xpdf to crash or possibly
execute arbitrary code when opened.  The Common Vulnerabilities and
Exposures project assigned the name CAN-2005-3193 to these issues.

Users of Xpdf should upgrade to this updated package, which contains a
backported patch to resolve these issues.

Red Hat would like to thank Derek B. Noonburg for reporting this issue and
providing a patch.

[...]

5. Bug IDs fixed (http://bugzilla.redhat.com/):

173888 - CVE-2005-3193 xpdf issues
Comment 1 Ludwig Nussel 2005-12-06 16:34:32 UTC
Created attachment 59932 [details]
xpdf-3.01pl1.patch from xpdf home page
Comment 2 Karl Eichwalder 2005-12-06 16:51:20 UTC
Lars, will you please work on pdf2html/pdftohtml fixes, if required?
Comment 3 Dirk Mueller 2005-12-06 16:56:40 UTC
Created attachment 59935 [details]
patch for 2.02 from redhat

this is the patch they applied to the xpdf 2.0x tree. it seems broken though.
Comment 4 Lars Vogdt 2005-12-06 17:06:07 UTC
Jip. I will crosscheck with pdf2html...
Comment 5 Lars Vogdt 2005-12-06 17:44:54 UTC
Seems only patch for 2.02 is needed for pdftohtml. => checked in to stable, but 9.0, 9.1, 9.2, 9.3, 10.0, SLES9 are affected.
Comment 6 Klaus Singvogel 2005-12-06 19:45:29 UTC
By chance I noticed that there is a if-clause double in the xpdf-2.0x:
+  if (numComps <= 0 || numComps > 4) {
+    error(getPos(), "Bad number of components in DCT stream", prec);
+    return gFalse;
+  }
This part can be deleted. :-)
Comment 7 Klaus Singvogel 2005-12-06 19:50:20 UTC
submitted fixed cups packages for: SLES8, SLES9, 9.0, 9.1, 9.2, 9.3, 10.0
==> CUPS is done.
Comment 8 Dirk Mueller 2005-12-06 19:53:54 UTC
the error message is broken: 

error(getPos(), "Bad number of components in DCT stream", prec);

ok, thats not a big issue :)
Comment 9 Lars Vogdt 2005-12-06 21:34:25 UTC
submitted pdftohtml to: SLES8, SLES9, 9.0, 9.1, 9.2, 9.3, 10.0
==> pdftohtml is done
Comment 10 Dirk Mueller 2005-12-06 21:42:52 UTC
ok, the redhat patches are incomplete. the posted patch is against xpdf 3.01, which is a regression introduced by 3.0.1. they didn't notice and backported the patch brute force against 3.0. 

xpdf 3.0.1 however itself fixes about 100 integer overflow bugs. 

xpdf 2.0 and friends has those very same bugs: 

$ grep malloc * | grep '*' | grep sizeof | wc -l
108

while 3.0.1+CVE patch has almost fixed those issues: 
$ grep gmalloc * | grep '*' | grep sizeof  | grep -v gmallocn
GfxFont.cc:  map = (Gushort *)gmalloc(mapsize * sizeof(Gushort));
PSOutputDev.cc: codeToGID = (Gushort *)gmalloc(n * sizeof(Gushort));

so there are still two integer overflows left in 3.0.1 + patch. 
Comment 11 Dirk Mueller 2005-12-06 21:43:59 UTC
if we don't care about those 108 integer overflows in xpdf 2.x then we don't need to care about those 2 integer overflows that were fixed in 3.0.1 either. 

Comment 12 Ludwig Nussel 2005-12-07 10:34:34 UTC
CAN-2005-3191 - DCTStream Progressive/Baseline Heap Overflow
CAN-2005-3192 - StreamPredictor Heap Overflow Vulnerability
CAN-2005-3193 - JPX Stream Reader Heap Overflow Vulnerability
Comment 13 Ludwig Nussel 2005-12-07 10:43:55 UTC
... potential overflows. It still depends on where the data comes from.
Comment 14 Stanislav Brabec 2005-12-07 14:37:24 UTC
Submitted:
xpdf: stable 10.0 9.3 9.2 9.1 9.0 ul1
gpdf: stable plus 10.0 9.3 9.2 9.1
poppler: stable plus 10.0
Comment 15 Ludwig Nussel 2005-12-07 15:23:50 UTC
For xpdf 3.0 I'd move the sizeof(JPXTile) into the calculation:

nTiles = img.nXTiles * img.nYTiles * sizeof(JPXTile);
if (nTiles == 0 || nTiles / img.nXTiles / sizeof(JPXTile)  != img.nYTiles) {
  error(getPos(), "Bad tile count in JPX SIZ marker segment");
  return gFalse;
}
img.tiles = (JPXTile *)gmalloc(nTiles);
Comment 16 Ludwig Nussel 2005-12-07 15:28:14 UTC
Maintenance-Tracker-3136
Comment 17 Stanislav Brabec 2005-12-07 16:26:36 UTC
Resubmitted:
xpdf: 10.0 9.3 9.2 9.1
poppler: stable plus 10.0
Comment 18 Dirk Mueller 2005-12-07 21:08:18 UTC
Submitted: 

kdegraphics3-pdf: stable plus 10.0 9.3 9.2 9.1
koffice-wordprocessing: 10.0 9.3 9.2 9.1 9.0

Comment 19 Ludwig Nussel 2005-12-08 08:09:31 UTC
wrt koffice, what about 8.1 (slec)?
Comment 20 Dirk Mueller 2005-12-08 11:47:34 UTC
Ludwig: koffice 1.2.x is not affected. 

Comment 21 Dirk Mueller 2005-12-08 11:49:00 UTC
the patches the KDE team released were incorrect. I received this mail this morning: 

From: 
Martin Pitt <martin.pitt@canonical.com>
Hi Derek, hi Dirk, hi Vendor-Sec!

Josh Bressers [2005-12-06 13:50 -0500]:
> In the event any of you missed this:
> 
> http://www.idefense.com/application/poi/display?id=342&type=vulnerabilities
> http://www.idefense.com/application/poi/display?id=343&type=vulnerabilities

It seems that the patch linked from these advisories [1] is a little
bit flawed: it checks numComps twice in DCTStream::readBaselineSOF(),
but does not check it in DCTStream::readProgressiveSOF().


I'll have to resubmit most of the kpdf/koffice updates now, will do so ASAP. most likely others need to update their patches as well, please have a look. 


Comment 22 Dirk Mueller 2005-12-08 13:31:38 UTC
Created attachment 60106 [details]
updated patch for CAN-2005-3193

this is the updated patch addressing the bugs Ludwig and Martin Pitt found.
Comment 23 Stanislav Brabec 2005-12-08 13:47:24 UTC
Do last two comments affect already submitted xpdf, gpdf and evince?
Comment 24 Dirk Mueller 2005-12-08 13:56:44 UTC
yes, the chances are very high that your submissions are also incorrect. kpdf uses a close to unmodified xpdf fork (luckily we replaced that with poppler now).  

Comment 25 Marcus Meissner 2005-12-09 09:15:21 UTC
dpo we need libextractor updates for old distros, Karl? You submitted a fixed on to STABLE at least.
Comment 26 Karl Eichwalder 2005-12-09 10:42:41 UTC
Yes, libextractor-0.5.2 comes with 10.0.  I'll check whether I can apply the posted patch or backport the xpdf fixes from version 0.5.8.
Comment 27 Karl Eichwalder 2005-12-09 11:02:39 UTC
I applied CAN-2005-3193-updated.patch without the JPXStream.cc hunk; JPXStream.cc does not exist in the libextractor archive.  Submitted to /work.
Comment 28 Ludwig Nussel 2005-12-09 12:47:08 UTC
So the current state of knowledge is that all packages need to be resubmitted to include the additional numComps check. numComps needs to be checked in

readBaselineSOF()
readProgressiveSOF()
readScanInfo()

Previously it was only in readBaselineSOF(). Creating diffs with the -p parameter helps verifying this.
Comment 29 Dirk Mueller 2005-12-09 12:48:29 UTC
Created attachment 60190 [details]
goo's gmallocn integer overflow fix

this patch fixes the integer overflow check in gmallocn and friends.
Comment 30 Ludwig Nussel 2005-12-09 14:56:23 UTC
Created attachment 60194 [details]
combined patch by Martin Pitt aginst 3.00 that also fixes potentially undefined behavior with signed integer multiplications
Comment 31 Dirk Mueller 2005-12-09 19:05:10 UTC
Resubmitted with attachment 60194 [details]: 

kdegraphics3-pdf: stable plus 10.0 9.3 9.2 9.1
koffice-wordprocessing: 10.0 9.3 9.2 9.1 9.0
Comment 32 Dirk Mueller 2005-12-12 09:06:42 UTC
I've been informed and can confirm that there is another integer overflow, found by Chris Evans apparently a few weeks ago. 

Comment 33 Dirk Mueller 2005-12-12 09:58:27 UTC
Created attachment 60264 [details]
updated patch from Martin Pitt

the new version from Martin Pitt obsoleting the old one
Comment 34 Dirk Mueller 2005-12-12 09:59:31 UTC
Created attachment 60265 [details]
Overflows found by Chris Evans

Overflows pointed out in the advisory by Chris Evans - patch is pending review.
Comment 35 Klaus Singvogel 2005-12-12 17:04:06 UTC
Sorry for asking...
But I'm currently joining a training course, and I'm only for a short time back in the office rooms. As these discussion grows now very quick and gets very long:
- are there final patches to apply or should I wait?
- which are xpdf-2.x relevant and which xpdf-3.x?
Thanks in advance.
Comment 36 Ludwig Nussel 2005-12-12 17:15:57 UTC
I hope we get some ack/nack about Dirk's patch from vendor-sec tonight. I'll post a summary and final patches tomorrow then.
Comment 37 Dirk Mueller 2005-12-13 13:04:31 UTC
Created attachment 60405 [details]
new patch for overflows found by Chris evans and similiar ones

this one contains protections for the new overflows of the day.
Comment 38 Ludwig Nussel 2005-12-13 15:54:06 UTC
Backported the patches to xpdf 2.02 and 3.00. On the way I made it more robust, it doesn't loop nor segfault with any of Chris Evans' bad pdf files anymore, worst thing is exit(1):
~lnussel/Export/xpdf
Comment 39 Dirk Mueller 2005-12-14 12:20:21 UTC
Resubmitted with attachment 60405 [details] and attachment 60264 [details]: 

kdegraphics3-pdf: stable plus 10.0 9.3 9.2 9.1
koffice-wordprocessing: 10.0 9.3 9.2 9.1 9.0
Comment 40 Ludwig Nussel 2005-12-15 15:52:43 UTC
Created attachment 60994 [details]
xpdf 2.02 combined patch fixes all currently knows problems
Comment 41 Ludwig Nussel 2005-12-15 15:53:24 UTC
Created attachment 60995 [details]
xpdf 3.00 combined patch fixes all currently known problems
Comment 42 Dirk Mueller 2005-12-15 15:54:19 UTC
Resubmitted with attachment 60994 [details]:

kdegraphics3-pdf: stable plus 10.0 9.3 9.2 9.1
koffice-wordprocessing: 10.0 9.3 9.2 9.1 9.0
Comment 43 Ludwig Nussel 2005-12-15 16:25:08 UTC
To all: Does anyone have a copy of xpdf version 1 in a package we have to maintain? Right now I'm only aware of xpdf itself on sles8.
Comment 44 Dirk Mueller 2005-12-15 16:25:38 UTC
Created attachment 60998 [details]
xpdf 3.01pl1 combined patch
Comment 45 Stanislav Brabec 2005-12-15 18:04:25 UTC
Submitted:
xpdf: stable 10.0 9.3 9.2 9.1 9.0
gpdf: stable plus 10.0 9.3 9.2 9.1
poppler: stable plus 10.0

Skipping: xpdf: ul1

Old patch replaced, old changelog entry kept.
Comment 46 Lars Vogdt 2005-12-15 19:27:41 UTC
Resubmitted pdftohtml to: STABLE, SLES8, SLES9, 9.0, 9.1, 9.2, 9.3, 10.0
Comment 47 Karl Eichwalder 2005-12-16 09:58:23 UTC
libextractor resubmitted (10.0 only).
Comment 48 Marcus Meissner 2005-12-20 09:41:57 UTC
From: "Derek B. Noonburg" <derekn@foolabs.com>
Reply-To: "Derek B. Noonburg" <derekn@foolabs.com>
Subject: Re: [vendor-sec] Re: xpdf update - gmallocn() flaw
To: bressers@redhat.com
Cc: joey@infodrom.org, mueller@kde.org, koon@gentoo.org,
        scarybeasts@gmail.com, martin.pitt@canonical.com, vendor-sec@lst.de,
        "Derek B. Noonburg" <derekn@foolabs.com>
Errors-To: vendor-sec-admin@lst.de
Date: Mon, 19 Dec 2005 21:04:24 -0800 (PST)

On 16 Dec, Josh Bressers wrote:
>>
>> True.  However, December 21st is just next week and we all have to prepare   
>> updates for xpdf, gpdf, kpdf, cups, koffice, tetex - and maybe more.  That  
>> alone take a while already.  I can only speak of Debian, but I'm not even
>> sure I'm *able* to release updates before the 21st, given there are no more  
>> corrections.  So, I'm fine with any disclosure date before Christmas.
>
> I don't think this is wise.  I'm sure there are other issues that will be
> found during patch creation, and this is a bad time for most of us given
> the pending holidays.  Putting this off until after the holidays would work
> best as none of us would be pressed to do a quick and incomplete job.  The
> decision is obviously up to Chris as he's the discoverer.

I apologize for not chiming in earlier -- I've been travelling (and will
be travelling again this week), and I still haven't had time to look at
these patches.  I'd strongly prefer postponing any announcement/release
until after I've looked things over, which is going to be early January
at this point.

- Derek
Comment 49 Sebastian Krahmer 2005-12-21 11:09:55 UTC
Date: Tue, 20 Dec 2005 20:01:43 +0100
From: Sune Kloppenborg Jeppesen <jaervosz@gentoo.org>
To: vendor-sec@lst.de
Cc: Martin Schulze <joey@infodrom.org>, Josh Bressers <bressers@redhat.com>,
    Dirk Mueller <mueller@kde.org>, Chris Evans <scarybeasts@gmail.com>,
    Martin Pitt <martin.pitt@canonical.com>, derekn@foolabs.com
Subject: Re: [vendor-sec] Re: xpdf update - gmallocn() flaw
Parts/Attachments:
   1 Shown    ~13 lines  Text
   2          196 bytes  Application
----------------------------------------

On Friday 16 December 2005 15:51, Martin Schulze wrote:
> Please don't postpone it after Christmas.  Then rather release the
> current fixes now and add another set of updates after Christmas.

What embargo date has been decided on this issue? 

Gentoo would prefer a release soon as patches are apparently available in at 
least one upstream public svn repository. 

-- 
Sune Kloppenborg Jeppesen
Gentoo Linux Security Team
Comment 50 Ludwig Nussel 2006-01-03 12:41:04 UTC
From: Josh Bressers <bressers@redhat.com>
To: Dirk Mueller <mueller@kde.org>

> On Monday 02 January 2006 22:02, Sune Kloppenborg Jeppesen wrote:
> 
> > > I'd also prefer to release soon, preferably on 21st like I suggested last
> > > week.
> > New Year and Christmas are behind us now, any news on an embargo date?
> 
> The latest patch I mailed around, which has been created by Ludwig Nussel and 
> myself, which also contains fixes for vulnerabilities found by Chris Evans, 
> has already been published by Red Hat on 2005-12-20. 
> 
> https://rhn.redhat.com/errata/RHSA-2005-868.html
> 
> Therefore I consider the patch to be leaked and the embargo to be broken.

This does appear this is true.  The complete patch is also in our xpdf
update as well.  Both xpdf and kpdf are maintained by the same person, who
I have never sent the full patch to.  Sadly he's out today so the whole
story will have to wait.

As for the CVE ids, here they are:

1) Out-of-bounds heap accesses with large or negative parameters to
   "FlateDecode" stream.
2) Out-of-bounds heap accesses with large or negative parameters to
   "CCITTFaxDecode" stream.
* CVE-2005-3624

3) Infinite CPU spins in various places when stream ends unexpectedly.
   Probably repeated at various locations in the code.
* CVE-2005-3625

4) NULL pointer crash in the "FlateDecode" stream.
* CVE-2005-3626

5) Overflows of compInfo array in "DCTDecode" stream.
6) Possible to use index past end of array in "DCTDecode" stream.
7) More possible out-of-bounds indexing trouble in "DCTDecode" stream.
* CVE-2005-3627

These are for the CESA-2005-003 advisory from Chris.

-- 
    JB
Comment 51 Ludwig Nussel 2006-01-09 08:10:52 UTC
CVE-2005-3628 for the JBIG2Bitmap fixes. It's all public in the meantime so if anyone did not submit to STABLE yet you may do so now.

There is another xpdf issue pending (#141242), no patch yet.
Comment 52 Dirk Mueller 2006-01-09 16:45:58 UTC
updated koffice for sles8-slec, which contained a backported xpdf from KOffice 1.3.x (sigh!)

Comment 53 Marcus Meissner 2006-01-10 10:01:08 UTC
*** Bug 142106 has been marked as a duplicate of this bug. ***
Comment 54 Marcus Meissner 2006-01-10 10:33:45 UTC
pdftohtml needs corrected packages.

cups needs updated patches.

tetex needs updated patches.
Comment 55 Dr. Werner Fink 2006-01-10 10:49:55 UTC
Does this mean we've stable patches for both xpdf 3+ and xpdf 2 which do not
change every day?
Comment 56 Dirk Mueller 2006-01-10 11:06:34 UTC
yes, besides that we have another xpdf issue already in the making this particular one is done. 
Comment 57 Dr. Werner Fink 2006-01-10 11:45:24 UTC
OK, which attachments are required for xpdf 3 and which attachments for xpdf 2?
Comment 58 Dirk Mueller 2006-01-10 12:17:53 UTC
read the list of attachments, please. there is one combined patch for 2.00, 3.00 and 3.01 attached (and not marked as obsoleted). The goo fix is necessary if you use 3.01pl1

Comment 59 Klaus Singvogel 2006-01-10 14:33:49 UTC
cups is finished: SLES8, SLES9, 9.0, 9.1, 9.2, 9.3, 10.0, STABLE
Comment 60 Lars Vogdt 2006-01-11 10:53:44 UTC
pdftohtml: correct packages for SLES9, 9.0, 9.1, 9.2, 9.3 (STABLE and 10.0) checked in 
Comment 61 Dr. Werner Fink 2006-01-11 15:19:16 UTC
For tetex on SLES8 a xpdf-1 version is needed.
Comment 62 Dr. Werner Fink 2006-01-11 16:02:48 UTC
tetex: SLES9, 9.0, 9.1, 9.2, 9.3, 10.0, STABLE

Missed SLES8 due missed patch:

  Patch #15 (xpdf-CAN-2005-3191,3192,3193-xpdf202.dif):
  + patch -p0 -b --suffix .xpdfsec4 -s
  7 out of 10 hunks FAILED -- saving rejects to file libs/xpdf/xpdf/Stream.cc.rej
  The text leading up to this was:
  --------------------------
  |--- libs/xpdf/xpdf/JBIG2Stream.cc
  |+++ libs/xpdf/xpdf/JBIG2Stream.cc
  --------------------------
  File to patch:
  Skip this patch? [y]
  6 out of 6 hunks ignored
  Bad exit status from /var/tmp/rpm-tmp.10321 (%prep)
Comment 63 Ludwig Nussel 2006-01-11 16:30:17 UTC
Created attachment 62964 [details]
untested backport to xpdf1
Comment 64 Dr. Werner Fink 2006-01-11 17:04:51 UTC
OK, now we're done with tetex, just submitted to SLES8.
Comment 65 Marcus Meissner 2006-01-24 16:16:34 UTC
we rejected tetex, since it only renders into pdfs but does not read out 
of them.

we will not fix tetex for pdf rendering issues again.

I released libextractor, the last package with xpdf code left in the queue.

Thanks everybody!
Comment 66 Thomas Biege 2009-10-13 20:42:26 UTC
CVE-2005-3628: CVSS v2 Base Score: 7.5 (AV:N/AC:L/Au:N/C:P/I:P/A:P)