Bug 441839 (CVE-2008-1382) - CVE-2008-1382 libpng unknown chunk handling flaw
Summary: CVE-2008-1382 libpng unknown chunk handling flaw
Keywords:
Status: CLOSED ERRATA
Alias: CVE-2008-1382
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard:
: 445487 (view as bug list)
Depends On: 487164 487165 487166 487167 487168 487169 487170 487171 487172 537849 802164
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-04-10 14:40 UTC by Josh Bressers
Modified: 2021-02-25 14:54 UTC (History)
6 users (show)

Fixed In Version: 1.2.29-1.fc8
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-05-08 20:05:08 UTC
Embargoed:


Attachments (Terms of Use)
Proposed upstream patch (7.63 KB, patch)
2008-04-10 14:44 UTC, Josh Bressers
no flags Details | Diff
Local copy of libpng upstream advisory text (1.95 KB, text/plain)
2008-04-15 07:37 UTC, Tomas Hoger
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2009:0333 0 normal SHIPPED_LIVE Moderate: libpng security update 2009-03-04 20:05:12 UTC

Description Josh Bressers 2008-04-10 14:40:54 UTC
Tavis Ormandy reported:
    libpng does not correctly handle unknown zero-length chunks, which could
    result in writing to attacker controlled addresses, depending on how the
    libpng api is used.

In order for this to be an issue, the application in question is going to need
to call png_set_keep_unknown_chunks(), which tells libpng not to ignore unknown
chunks, but to do something with them.  The PNG spec allows for "unknown"
chunks, which are ignored by default, but an application could in theory embed
some sort of extra data in a png image, then later get it back out via this
mechanism.

This in turn appears to be how the flawed code in question will get executed. 
If the application doesn't call png_set_keep_unknown_chunks(), it shouldn't be
vulnerable to this problem.

Comment 4 Josh Bressers 2008-04-10 14:44:52 UTC
Created attachment 302000 [details]
Proposed upstream patch

Comment 5 Josh Bressers 2008-04-10 14:47:10 UTC
Upon inspecting the Red Hat Enterprise Linux and Fedora source, it appears that
only ImageMagick in RHEL5 and Fedora use this functionality in libpng.

Comment 6 Tom Lane 2008-04-10 17:54:22 UTC
Glenn R-P reports on the png security list that ImageMagick doesn't actually crash, so this may be a low 
priority issue for our purposes.

Comment 7 Josh Bressers 2008-04-11 00:21:58 UTC
Yes, absolutely.  If we fix this, it be piggy-backed on a more sever libpng
update.  it's not worth rolling updates just for this.

Comment 8 Tomas Hoger 2008-04-14 06:42:18 UTC
Public now via:

http://www.ocert.org/advisories/ocert-2008-003.html
http://libpng.sourceforge.net/Advisory-1.2.26.txt

Lifting embargo.

Comment 9 Tomas Hoger 2008-04-14 06:49:23 UTC
This issue affects all versions of libpng and libpng10 shipped in Red Hat
Enterprise Linux 2.1, 3, 4, and 5 and current Fedora versions.

Due to a very low security impact of this flaw (see previous comments and
upstream advisory linked in comment #8), we do not plan to release updated
libpng and libpng10 packages for Red Hat Enterprise Linux immadiately.  This
issue may be addressed in future updates of those packages.

Comment 10 Tomas Hoger 2008-04-15 07:37:08 UTC
Created attachment 302414 [details]
Local copy of libpng upstream advisory text

Comment 11 Tomas Hoger 2008-04-15 07:38:11 UTC
Tom, Paul, feel free to include a patch in future Fedora libpng/libpng10
packages updates once you'll be doing them.  Thanks!

Comment 12 Paul Howarth 2008-04-30 14:27:36 UTC
I built updated packages of libpng10 1.0.33 for Fedora 7, 8, 9, and devel, and
submitted updates for testing for the non-devel branches. I don't think there's
any need to push these straight to stable.

Comment 13 Tom Lane 2008-05-07 04:58:26 UTC
*** Bug 445487 has been marked as a duplicate of this bug. ***

Comment 15 Fedora Update System 2008-05-29 02:34:33 UTC
libpng10-1.0.37-1.fc9 has been pushed to the Fedora 9 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 16 Fedora Update System 2008-05-29 02:49:47 UTC
libpng10-1.0.37-1.fc7 has been pushed to the Fedora 7 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 17 Fedora Update System 2008-05-29 02:50:20 UTC
libpng10-1.0.37-1.fc8 has been pushed to the Fedora 8 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 18 Fedora Update System 2008-06-03 07:30:00 UTC
libpng-1.2.29-1.fc8 has been pushed to the Fedora 8 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 19 Fedora Update System 2008-06-03 07:34:12 UTC
libpng-1.2.29-1.fc9 has been pushed to the Fedora 9 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 20 Fedora Update System 2008-06-03 07:36:14 UTC
libpng-1.2.29-1.fc7 has been pushed to the Fedora 7 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 21 Tom Lane 2009-02-25 21:52:13 UTC
After looking more closely at the changes made for this in libpng 1.2.27, I'm not actually convinced that there is any bug here at all.  What will happen with a zero chunk length is that png_malloc will return a NULL buffer, png_crc_read will do nothing, and png_free will do nothing because it's handed a NULL.  (There's a potential crash in the pre-1.2.27 Borland-specific png_free, but we don't care about that.)
The only way that there's actually any problem is if an application-supplied unknown-chunk handler
tries to dereference the NULL pointer despite being told there's zero data there.  If so, then (1) it's not
libpng's bug and (2) the 1.2.27 changes don't prevent the case anyway.

Has anyone reproduced an actual problem related to this, other than on a Borland-specific build?

Comment 22 Tom Lane 2009-02-25 22:40:59 UTC
Ah, after looking closer I see the issue: the changes on the read side really are just cosmetic --- they might save a few cycles but I don't think they change the outcome.  The bug is actually on the *write* side, where the code to copy a zero-length unknown chunk from the application and into libpng's data structure is wrong.  So the problem only occurs if attempting to *write* a zero-length unknown chunk.
It could be called a security issue I guess if you suppose the chunk is being copied from a malevolent
source PNG, but the argument is pretty thin.

Anyway, we might as well fix it as long as we're turning 2009-0040, but I'd put the security impact at somewhere around nil.

Comment 36 Vincent Danen 2013-05-08 20:05:08 UTC
Statement:

This issue does not affect the version of libpng as shipped with Red Hat Enterprise Linux 3.

Updates for affected versions of Red Hat Enterprise Linux can be found here:
http://rhn.redhat.com/errata/RHSA-2009-0333.html


Note You need to log in before you can comment on or make changes to this bug.