[CVE-2008-2363] Heap overflow in PartsBatch class via .nzb files

Bug #238089 reported by Till Ulen
264
Affects Status Importance Assigned to Milestone
pan
Fix Released
Critical
pan (Fedora)
Fix Released
High
pan (Gentoo Linux)
Fix Released
Medium
pan (Ubuntu)
Fix Released
Low
Unassigned
Hardy
Fix Released
Undecided
Unassigned
Intrepid
Fix Released
Undecided
Unassigned
Jaunty
Fix Released
Undecided
Unassigned
Karmic
Fix Released
Low
Unassigned

Bug Description

Binary package hint: pan

CVE-2008-2363 description:

"The PartsBatch class in Pan 0.132 and earlier does not properly manage the data structures for Parts batches, which allows remote attackers to cause a denial of service (application crash) and possibly execute arbitrary code via a crafted .nzb file that triggers a heap-based buffer overflow."

http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-2363
http://nvd.nist.gov/nvd.cfm?cvename=CVE-2008-2363

Related branches

CVE References

Revision history for this message
In , Pavel (pavel-redhat-bugs) wrote :

Description of problem:

Version-Release number of selected component (if applicable):
pan-0.132-2.fc8.x86_64

How reproducible:
Always

Steps to Reproduce:
  Start pan from the command line

Actual results:

pan: parts.cc:244: void pan::Parts::set_parts(const pan::PartBatch&): Assertion
`pch == part_mid_buf + part_mid_buf_len' failed.
Aborted

Expected results:

PAN starts

Additional info:

Revision history for this message
In , Pavel (pavel-redhat-bugs) wrote :

Created attachment 306290
Tasks.nzb causing corrupted double-linked list abort from glibc

Revision history for this message
In , Pavel (pavel-redhat-bugs) wrote :

Debugged the problem further. It happens when trying to load a huge tasks.nzb
(around 95000 lines). When the file is split into two parts by copying and
removing extra <file>...</file> sections, each part loads successfully.
This most likely means state corruption in nzb parser by certain input.

Attaching the bad nzb files that cause: assertion, segmentation fault, or abort
inside glibc (double-linked list corruption detected).

Revision history for this message
In , Pavel (pavel-redhat-bugs) wrote :

Created attachment 306292
Glibc-generated stack trace from abort

Revision history for this message
In , Pavel (pavel-redhat-bugs) wrote :

Created attachment 306293
Tasks.nzb causing pan to segfault

Revision history for this message
In , Pavel (pavel-redhat-bugs) wrote :

Created attachment 306294
Stack trace from segfault

Revision history for this message
In , Pavel (pavel-redhat-bugs) wrote :

Created attachment 306296
Tasks.nzb causing assertion in pan.

Revision history for this message
In , Pavel (pavel-redhat-bugs) wrote :

Created attachment 306297
Stack trace from assertion

Revision history for this message
In , Pavel (pavel-redhat-bugs) wrote :

Found the root cause of the problem.

PartsBatch class has inconsistent storage for Parts. For each new batch, it does
not clear() the 'parts' variable, but only resize()s it if the new batch is
bigger (pan/data/parts.cc, lines 307 and 316). If the new batch is smaller than
the previous, extra entries are untouched.

The problem happens when pan attempts to sort the full vector
(pan/tasks/nzb.cc:128), thus possibly mixing the parts from the current batch
with the parts from the previous batches.

The solution is to clear() the 'parts' vector on each init(), then push_back()
the new parts in add_part, so the vector size always corresponds to the real
number of found parts.

Revision history for this message
In , Pavel (pavel-redhat-bugs) wrote :

Created attachment 306880
Fix the assertion in PAN due to sorting of an array containing redundant elements

Added proper handling of PartBatch::parts vector.
Fixed allocation policy of Part::packed_mid element to re-allocate it every
time rather than trying to reuse a previous instance.

Signed-off by: <email address hidden>

Revision history for this message
In , Pavel (pavel-redhat-bugs) wrote :

Note that when compiled with -O0 for ease of debugging, abort or segfault never
happen, assertion always happens instead.

Revision history for this message
In , Josh (josh-redhat-bugs) wrote :

I'm assigning this issue CVE-2008-2363. From the look of this, it looks like a
pretty generic heap overflow, which means we can't rule out arbitrary code
execution.

Revision history for this message
In , Pavel (pavel-redhat-bugs) wrote :

Added dependency on bug 433970.
Building pan rpm with this assertion fix for F9 is impossible without
compilation fixes here: https://bugzilla.redhat.com/attachment.cgi?id=306299

Revision history for this message
In , Tomas (tomas-redhat-bugs) wrote :

Moving to Security Response product, creating tracking bugs.

Changed in pan:
status: Unknown → In Progress
status: Unknown → Confirmed
Changed in pan:
status: Unknown → New
Changed in pan:
status: New → Fix Released
Changed in pan:
status: In Progress → Fix Released
Revision history for this message
Darren Albers (dalbers) wrote :

This bug was patched in Intrepid based on a synch from Debian. Can the Security team backport the fix at:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=483562

Is there something I can do to help with getting the fix in? I could put a patched package into a PPA for testing if that would help.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Darren, if you would like to help out, you could review https://wiki.ubuntu.com/SecurityUpdateProcedures and submit a debdiff. Thanks!

Changed in pan:
status: New → Confirmed
Changed in pan (Ubuntu):
importance: Undecided → Low
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

This was fixed in 0.132-3.1

Changed in pan (Ubuntu Intrepid):
status: New → Fix Released
Changed in pan (Ubuntu Jaunty):
status: New → Fix Released
Changed in pan (Ubuntu Hardy):
status: New → Confirmed
Changed in pan (Ubuntu Karmic):
status: Confirmed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pan - 0.132-2ubuntu2.1

---------------
pan (0.132-2ubuntu2.1) hardy-security; urgency=low

  * SECURITY UPDATE: denial of service and possible code execution via
    Parts batches (LP: #238089)
    - debian/patches/CVE-2008-2363.dpatch: make sure vector size always
      corresponds to the real number of found parts in
      pan/data/parts.{cc,h}.
    - CVE-2008-2363

 -- Marc Deslauriers <email address hidden> Wed, 07 Oct 2009 11:08:20 -0400

Changed in pan (Ubuntu Hardy):
status: Confirmed → Fix Released
Changed in pan:
importance: Unknown → Critical
Changed in pan (Gentoo Linux):
importance: Unknown → Medium
Revision history for this message
In , Vincent (vincent-redhat-bugs) wrote :

Current Pan in Fedora is 0.135+ and this was fixed in 0.133 (http://pan.rebelbase.com/download/releases/0.133/).

Changed in pan (Fedora):
importance: Unknown → High
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public Security information  
Everyone can see this security related information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.