Many sysadmins will be in the unpleasant situation of having to live with a known vulnerable apache server (or switching it off) until they can obtain, test and integrate updated apache binaries for their various platforms from different vendors, or make enough time to sit down and patch, re-compile and test their homegrown versions.
Some vendors have been very fast to respond and have back-ported the fix to many older apache releases, helping avoid many issues that a forced upgrade might involve. Other vendors supplying apache and apache-based servers may not be so quick off the mark (or may not even be around anymore). Homegrown releases may also be similarly outdated, and back porting is tedious.
Because apache is so great, and has had a history of very few serious security bugs, older versions are embedded in a wide variety of products and systems, making it even more problematic to update all of them to the latest release in a timely manner.
Here is an option that might help in protecting those vulnerable servers, giving a breathing space until a proper tested fix does become available:
Most web sites and applications have no need for chunked transfer encoding on HTTP "request" messages. Most browsers do not even support it, and it is only *required* when a client does not know the final length of a file before an upload (which is rare). Disallowing such requests should be no big deal.
Attached are a two versions of code to allow the server to intercept each incoming HTTP request (at the 'Post Read Request' phase), and check to see if chunked encoding has been requested. If so, the request is denied and logged. This should prevent clients being able to trigger the vulnerable 'chunk size' reading code, and therefore prevent DoS or exploits.
* BlowChunks.pl - this version is for mod_perl enabled servers - if you have a server with mod_perl already in place, this patch is trivial to install. Just paste it into the end of your existing httpd.conf, and restart. All done. Very Easy.
* mod_blowchunks.c - this version is an apache module. If your apache is compiled with DSO support (run httpd -l and look for mod_so), you can compile and install this module with just one apxs command (and a compiler!), and restart. Should be straightforward for most administrators.
Both methods offer the advantage of not needing to touch your existing apache binary (or any other modules), and can be trivially reverted if you have any trouble, or when your real fix is ready. This should work on any platform with either mod_perl or DSO support. If your apache is static, without DSO, you could re-compile it with this module included, but then you might as well just fix it properly.
Tool code:
# $Id: BlowChunks.pl,v 1.4 2002/06/22 05:27:33 cbailiff Exp $
#
# Reject chunked requests before vulnerable chunking routines can read them.
# (mod_perl version)
#
# Cris Bailiff, c.bailiff+blowchunks@devsecure.com - http://www.awayweb.com
# http://www.devsecure.com/pub/src/BlowChunks.pl
#
# Copyright 2002 Cris Bailiff. All rights reserved.
#
# Permission is granted to anyone to use this software for any purpose on
# any computer system, and to alter it and redistribute it, subject
# to the following restrictions:
#
# 1. The author is not responsible for the consequences of use of this
# software, no matter how awful, even if they arise from flaws in it.
#
# 2. The origin of this software must not be misrepresented, either by
# explicit claim or by omission.
#
# 3. Altered versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
#
# 4. This notice may not be removed or altered.
#
# To install in your mod_perl enabled server, copy the code below into
# your httpd.conf file (at the end is best), or read this file into
# your configuration using an 'Include' statement, and restart httpd.
#
# You need mod_perl with support for PerlPostReadRequestHandler
# and <perl> sections. You have these if your mod_perl was configured
# using EVERYTHING=1, which is typical.
#
# (Permission is granted to leave these comments out of your httpd.conf file :-)
# but please use this original version if passing along...)
#
# --cut-here---
<perl>
# blowchunks for mod_perl
# $Id: BlowChunks.pl,v 1.4 2002/06/22 05:27:33 cbailiff Exp $
# Deny requests using Transfer-Encoding: chunked
#
sub Awayweb::BlowChunks::handler {
my $r = shift;
if (join('',$r->headers_in->get('Transfer-Encoding'))
=~ m/chunked/i)
{
$r->log->warn('Transfer-Encoding: chunked - denied and logged');
return 400
}
return 0
}
</perl>
PerlPostReadRequestHandler Awayweb::BlowChunks
/*
* $Id: mod_blowchunks.c,v 1.3 2002/06/22 05:27:33 cbailiff Exp $
*
* Reject chunked requests before vulnerable chunking routines can read them.
* (apache module version)
*
* Cris Bailiff, c.bailiff+blowchunks@devsecure.com - http://www.awayweb.com
* http://www.devsecure.com/pub/src/mod_blowchunks.c
*
* Copyright 2002 Cris Bailiff. All rights reserved.
*
* Permission is granted to anyone to use this software for any purpose on
* any computer system, and to alter it and redistribute it, subject
* to the following restrictions:
*
* 1. The author is not responsible for the consequences of use of this
* software, no matter how awful, even if they arise from flaws in it.
*
* 2. The origin of this software must not be misrepresented, either by
* explicit claim or by omission.
*
* 3. Altered versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 4. This notice may not be removed or altered.
*
* To compile & install in your apache (using apxs):
*
* # /usr/sbin/apxs -i -a -c mod_blowchunks.c
*
* and restart. Read the apxs(8) man page for more info on compiling apache
* modules.
*/