Ticket #1335 (new defect)

Opened 11 months ago

Last modified 10 months ago

source disclosure vulnerability on win32 with ntfs alternate data streams

Reported by: wlmp Assigned to: jan
Priority: highest Milestone: 1.4.20
Component: core Version: 1.4.17
Severity: critical Keywords: vulnerability uri expose source
Cc: Blocking:
Need Feedback: 0

Description

We received the following post on the WLMP Project (http://wlmp.dtech.hu) forum:

To whom it may concern,

I am not sure whether or not the Win32 build of Lighttpd is officially supported,
but I would like to report a security vulnerability specific to this specific release.

The vulnerability is due to an NTFS-specific feature, called an ADS stream. Using this feature, it is possible to retrieve the source code of a file stream that would normally be interpreted by e.g. PHP using the ":$DATA". (I believe IIS and/or Apache had similar vulnerabilities; Apache on Win32 completely forbids the ":" character in URLs now.)

Example:
You can retrieve the source code of http://wlmp.dtech.hu/index.php by using the URL http://wlmp.dtech.hu/index.php::$DATA

I'm not sure whether there are additional parameters similar to ":$DATA", but I think it's safe to say that ADS streams should be ignored/disallowed completely. The feature isn't very well documented and not very commonly used.

More information about NTFS/ADS can be found at http://en.wikipedia.org/wiki/NTFS

Regards,
Ben de Graaff


We can confirm the existence of this vulnerability.

Proposed solution in src/request.c

Replace

int request_uri_is_valid_char(unsigned char c) {
    if (c <= 32) return 0;
    if (c == 127) return 0;
    if (c == 255) return 0;

    return 1;
}

with

int request_uri_is_valid_char(unsigned char c) {
    if (c <= 32) return 0;
    if (c == 58) return 0; // 58 is the ASCII code for ':'
    if (c == 127) return 0;
    if (c == 255) return 0;

    return 1;
}

Attachments

Change History

09/03/2007 01:20:05 PM changed by darix

veto. the ":" is a valid char in uris. and we use that extensively on one of our services.

the real fix would be to check for ":" in the filename part of the uri. and this restriction should be only applied to window. imho

09/09/2007 11:14:53 PM changed by ralf

some hints/urls while iam locking for a useful fix:

URLs

* MSDN: A Programmer's Perspective on NTFS 2000 Part 1: Stream and Hard Link

* MSDN: Search for streams

* Old IIS Bug related to streams

Hints

There are not only "::$Data" streams, it is possible to create userdefined streams.

A example of a other (default) stream is: http://domain.tld/index.php:VersionInfo:$Data

While playing a bit, atm. i found no way to determine if a file is a stream (without parsing the string against a ":" character).

I play with:

* GetFileAttributesEx()

* GetFileInformationByHandle()

* GetFileType()

09/10/2007 12:05:21 AM changed by ralf

as darix says in irc reiser4 knows also some meta stuff.


Add/Change #1335 (source disclosure vulnerability on win32 with ntfs alternate data streams)




Change Properties