Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 135860 - dev-lang/php Infinite loop DoS (CVE-2006-2906)
Summary: dev-lang/php Infinite loop DoS (CVE-2006-2906)
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All Linux
: High minor (vote)
Assignee: Gentoo Security
URL: From BugTraq ML
Whiteboard: B3 [noglsa] jaervosz
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-06 22:30 UTC by Wolf Giesen (RETIRED)
Modified: 2006-07-23 13:09 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Complete posting (didn't see it anywhere else yet) (posting.txt,33.41 KB, text/plain)
2006-06-06 22:32 UTC, Wolf Giesen (RETIRED)
no flags Details
gdbad.c (gdbad.c,31.03 KB, text/plain)
2006-06-07 05:58 UTC, SpanKY
no flags Details
gd-infinite-loops-2 (gd-infinite-loops-2,7.27 KB, text/plain)
2006-06-09 14:32 UTC, Carsten Lohrke (RETIRED)
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wolf Giesen (RETIRED) gentoo-dev 2006-06-06 22:30:17 UTC
"A bug seems to affect the current (2.0.33) GD library version, located
in the LZW decoding while loading GIF images. The problem is an infinite
loop while decoding specifically crafted images ; for example when
calling gdImageCreateFromGifPtr() with badly formed GIF data. The loop
is causing 100% CPU consumption, and can be a problem when involving
online server scripts."

"3. Quick fix
------------

This quick-and-dirty fix just limits the number of loops in the
LWZReadByte_() function.

diff -r -c gd-2.0.33.orig/gd_gif_in.c gd-2.0.33/gd_gif_in.c
*** gd-2.0.33.orig/gd_gif_in.c  Mon Nov  1 19:28:56 2004
--- gd-2.0.33/gd_gif_in.c       Fri Apr  7 09:04:10 2006
***************
*** 417,422 ****
--- 417,423 ----
                                         GetCode(fd, code_size, FALSE,
ZeroDataBlockP);
                         return firstcode;
                 } else if (code == end_code) {
+                        int             maxcount = 1024;
                         int             count;
                         unsigned char   buf[260];

***************
*** 423,432 ****
                         if (*ZeroDataBlockP)
                                 return -2;

!                        while ((count = GetDataBlock(fd, buf,
ZeroDataBlockP)) > 0)
                                 ;

!                        if (count != 0)
                         return -2;
                 }

--- 424,433 ----
                         if (*ZeroDataBlockP)
                                 return -2;

!                        while ((count = GetDataBlock(fd, buf,
ZeroDataBlockP)) > 0 && --maxcount >= 0)
                                 ;

!                        if (count != 0 || maxcount < 0)
                         return -2;
                 }
"
Comment 1 Wolf Giesen (RETIRED) gentoo-dev 2006-06-06 22:32:21 UTC
Created attachment 88576 [details]
Complete posting (didn't see it anywhere else yet)
Comment 2 Wolf Giesen (RETIRED) gentoo-dev 2006-06-06 23:07:30 UTC
Guess we need to check a) if this is valid, b) if we're affected c) if gd-internal is affected.
Comment 3 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2006-06-07 02:23:48 UTC
Vapier please comment.

Removed from CC since he's on the security alias.
Comment 4 Raphael Marichez (Falco) (RETIRED) gentoo-dev 2006-06-07 02:50:34 UTC
> Guess we need to check a) if this is valid, b) if we're affected c) if
> gd-internal is affected.
> 

i can't reproduce the DoS with the supplied example with medias-libs/gd-2.0.33 x86 . It compiles, and runs, but doesn't crash.
Comment 5 SpanKY gentoo-dev 2006-06-07 05:58:52 UTC
Created attachment 88598 [details]
gdbad.c

this hung on my amd64 machine
Comment 6 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2006-06-07 06:48:59 UTC
Setting it to upstream until an official fix is available.
Comment 7 frilled 2006-06-07 09:44:54 UTC
Might be even A3 if the bundled version is affected, too. Quite some php apps use gd.
Comment 8 Carsten Lohrke (RETIRED) gentoo-dev 2006-06-09 14:32:50 UTC
Created attachment 88795 [details]
gd-infinite-loops-2

A second bug exists in gd_gif_in.c:152, which can make corrupted 
(truncated) GIF files to generate an infinite loop in libgd.

...

(bugtraq reply by Xavier Roche <rocheml@httrack.com>)
Comment 9 Carsten Lohrke (RETIRED) gentoo-dev 2006-06-09 14:37:35 UTC
cc'ing php team as php includes a gd lib
Comment 10 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2006-06-09 23:36:17 UTC
Does any other package bundle the gd lib?
Comment 11 SpanKY gentoo-dev 2006-06-10 05:57:06 UTC
i dont know of any
Comment 12 Raphael Marichez (Falco) (RETIRED) gentoo-dev 2006-06-14 02:45:38 UTC
CVE-2006-2906
Comment 13 Luca Longinotti (RETIRED) gentoo-dev 2006-07-14 09:20:38 UTC
PHP's bundled libgd was fixed wrt all the security problems the maintainer told us about in the just added dev-lang/php-4.4.2-r6 and dev-lang/php-5.1.4-r4. The infinite loop DoS should already be fixed in older dev-lang/php revisions of 4.4.2 and 5.1.4, this one further fixes a problem with bad colormaps and a problem with the size of GIF images. Stabling of those two PHP versions can be handled in bug 133524.
Best regards, CHTEKK.
Comment 14 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2006-07-22 23:59:04 UTC
This one is ready for GLSA decision.
Comment 15 Wolf Giesen (RETIRED) gentoo-dev 2006-07-23 01:15:52 UTC
Phew. I think the impact is high enough to call for it, but the attack vector is not so interesting. But when in doubt, yes.
Comment 16 Stefan Cornelius (RETIRED) gentoo-dev 2006-07-23 04:37:11 UTC
mhh tough one, but weak yes. having a possibly important webpage DoSed surely is no fun
Comment 17 Thierry Carrez (RETIRED) gentoo-dev 2006-07-23 12:14:12 UTC
Voting no. It's not very common to accept untrusted GIF images and process them. Even in that case, the infinite loop is not very impact-ish.
Comment 18 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2006-07-23 13:09:38 UTC
Voting NO and closing. Feel free to reopen if you disagree.