Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 159941

Summary: www-servers/thttpd: potential oob write CVE-2007-0158
Product: Gentoo Security Reporter: Tavis Ormandy (RETIRED) <taviso>
Component: VulnerabilitiesAssignee: Gentoo Security <security>
Status: RESOLVED FIXED    
Severity: normal CC: www-servers+disabled
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard: B2? [noglsa]
Package list:
Runtime testing required: ---
Attachments:
Description Flags
patch for this issue none

Description Tavis Ormandy (RETIRED) gentoo-dev 2007-01-04 04:08:06 UTC
In libhttpd.c, expand_symlinks() around line 1492, this line assumes
strlen(path) is always > 0, but this isnt the case:

...
 if ( rest[restlen - 1] == '/' )
             rest[--restlen] = '\0';         /* trim trailing slash */
...

By sending a request that after normalization is empty, (eg GET /../),
if the byte before the rest heap buffer is 0x2f a '\0' is written
one byte before the buffer. restlen here could wrap to SIZE_MAX, and do
some more damage.

Theres a similar case earlier in the function but requires stat("", foo)
to return success.

I emailed the maintainer before christmas, and again after new year and no response. 

I think this would be very unlikely to be exploitable, but we should fix it to be safe.

Patch attached.
Comment 1 Tavis Ormandy (RETIRED) gentoo-dev 2007-01-04 04:10:36 UTC
Created attachment 105364 [details, diff]
patch for this issue
Comment 2 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2007-01-06 12:55:15 UTC
www-servers please advise.
Comment 3 Elfyn McBratney (beu) (RETIRED) gentoo-dev 2007-01-08 21:50:24 UTC
thttpd-2.25b-r6 applies the patch from taviso and is now in the tree.
Comment 4 Tavis Ormandy (RETIRED) gentoo-dev 2007-01-09 12:12:27 UTC
Arches, please test and mark stable thttpd-2.25b-r6
Comment 5 Tobias Scherbaum (RETIRED) gentoo-dev 2007-01-09 18:59:45 UTC
ppc stable
Comment 6 Christian Faulhammer (RETIRED) gentoo-dev 2007-01-10 08:26:43 UTC
x86 stable, we are last
Comment 7 Tavis Ormandy (RETIRED) gentoo-dev 2007-01-10 10:54:28 UTC
Please vote for glsa
Comment 8 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2007-01-10 11:33:56 UTC
I tend to vote NO.
Comment 9 Matt Drew (RETIRED) gentoo-dev 2007-01-10 12:50:26 UTC
padawan vote NO.
Comment 10 Tavis Ormandy (RETIRED) gentoo-dev 2007-01-10 13:48:57 UTC
NO as well from me, closing with noglsa.

Thanks everyone.