Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 32190 - mod_security 1.7.2 ( New Package )
Summary: mod_security 1.7.2 ( New Package )
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Apache Team - Bugzilla Reports
URL: http://modsecurity.org
Whiteboard:
Keywords: EBUILD
Depends on:
Blocks:
 
Reported: 2003-10-28 07:00 UTC by Minati jean michel
Modified: 2004-06-04 13:57 UTC (History)
1 user (show)

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


Attachments
Ebuild for mod_security 1.7.1 (mod_security-1.7.1.ebuild,771 bytes, text/plain)
2003-10-28 07:02 UTC, Minati jean michel
Details
Ebuild for mod_security 1.7.2 (mod_security-1.7.2.ebuild,771 bytes, text/plain)
2003-10-29 01:54 UTC, Minati jean michel
Details
Patch to upgrade to mod_security-1.7.5 (mod_security-1.7.5.ebuild.diff,985 bytes, patch)
2004-02-28 12:10 UTC, Minati jean michel
Details | Diff
an example of 99_mod_security.conf (99_mod_security.conf,3.32 KB, text/plain)
2004-03-18 07:09 UTC, Julien Allanos (RETIRED)
Details
net-www/mod_security/mod_security-1.7.6.ebuild (mod_security-1.7.6.ebuild,1.18 KB, text/plain)
2004-03-24 07:45 UTC, Julien Allanos (RETIRED)
Details
net-www/mod_security/mod_security-1.7.6.ebuild (mod_security-1.7.6.ebuild,1.18 KB, text/plain)
2004-03-24 07:45 UTC, Julien Allanos (RETIRED)
Details
net-www/mod_security/files/99_mod_security.conf (99_mod_security.conf,3.58 KB, text/plain)
2004-03-24 07:47 UTC, Julien Allanos (RETIRED)
Details
net-www/mod_security/files/mod_security.conf (mod_security.conf,3.32 KB, text/plain)
2004-03-24 07:47 UTC, Julien Allanos (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Minati jean michel 2003-10-28 07:00:00 UTC
ModSecurity is an open source intrusion detection and prevention engine for web
applications. It operates embedded into the web server, acting as a powerful
umbrella - shielding applications from attacks. ModSecurity supports Apache
(both branches) today, with support for Java-based servers coming soon.

Reproducible: Always
Steps to Reproduce:
1.
2.
3.
Comment 1 Minati jean michel 2003-10-28 07:02:02 UTC
Created attachment 19891 [details]
Ebuild for mod_security 1.7.1
Comment 2 Minati jean michel 2003-10-28 07:40:22 UTC
I suggest net-www/mod_security as portage subsection.
Comment 3 solar (RETIRED) gentoo-dev 2003-10-28 16:49:32 UTC
Be forwarned..

This module has a really bad security track record.

---------------------------------------------
Program:                mod_security (www.modsecurity.org)
Versions:               1.7RC1 to 1.7.1 (Apache 2 version)
Synopsis:               malloc based buffer overflow
Author:                 Adam Dyga (adeon(at)o2.pl, ad(at)adsystems.com.pl)
URL:                    http://adsystems.com.pl/adg-mod_security171.txt
Discovered:             October 24, 2003
Published:              October 28, 2003

Issue:

        There is a exploitable malloc based buffer overflow in
        mod_security (apache 2 version).
        When appropriately exploited this can lead to (under some circumstances
-               
        remote) code execution on a vulnerable system with apache server
user           
        privileges.

Details:

        The bug exists in sec_filter_out() function in apache2/mod_security.c
:

        <snip>

                if (ctx->bufused + len > ctx->buflen) {
            char *newbuffer;
            // todo: implement a smarter extension policy
            unsigned long int newsize = ctx->buflen * 2;

            sec_debug_log(r, 3, "sec_filter_out: expanding buffer to %i",
newsize);

            // allocate a larger buffer
            newbuffer = apr_palloc(f->r->pool, newsize + 1);
            memcpy(newbuffer, ctx->buffer, ctx->bufused);
            // free(ctx->buffer);

            ctx->buffer = newbuffer;
            ctx->buflen = newsize;
            ctx->input_ptr = ctx->buffer + ctx->bufused;
        }

        memcpy(ctx->input_ptr, data, len);
        ctx->input_ptr += len;
        ctx->bufused += len;

        </snip>

        As we can see, if ctx->buffer is too small, it's size is doubled,
regardless of
        the size of     incoming data. If incoming data size is larger than
        (ctx->buflen*2 - ctx->bufused) then the second memcpy may overwrite
further header(s) of
        the next chunks on the heap. The author assumed, that incoming data
size is not
        larger than 8kB, because Apache internally transports data in chunks
that are
        4kB/8kB long. However, this is not true when data is sent by server
side script.

        This is a piece of mod_security debug log:

        sec_filter_out: got 198301 bytes, bufused=0, buflen=16384
        sec_filter_out: expanding buffer to 32768

        The buffer is overflowed when server side script is generating large
output,
        for example when writing large file to the output:

        <?php
                Header('Content-Type: image/jpeg');
                readfile('some_large_image.jpeg');
        ?>

        When getting the 'some_large_image.jpeg' directly from server (not
by the above
        script, but by using GET method instead), the buffer overflow doesn't
occur.

        So, to perform an attack, the attacker has to have the possibility
to upload his/her own
        script to the server (very common on web hosting servers) or to use
some XSS bug found on
        the site.

        The sec_filter_out() function is called when the mod_security.so
module is just loaded,
        no other directives in httpd.conf (from mod_security) are needed.

Remedies:

        Upgrade to 1.7.2, which fixes the vulnerability. If that is not
        possible, turn output filtering off with "SecFilterScanOutput Off".

Vendor status:

        October 24, 2003 - ivanr@webkreator.com notified, no response
        October 25, 2003 - ivanr@webkreator.com notified, got response
        October 28, 2003 - patched version of mod_security 1.7.2 released
        October 28, 2003 - public disclosure
Comment 4 Minati jean michel 2003-10-29 01:54:12 UTC
Created attachment 19926 [details]
Ebuild for mod_security 1.7.2

Thanks for the info solar , it's very fresh news ! ( 1.7.2 wasn t out yesterday
).
here is the 1.7.2 ebuild.
Comment 5 gentoo 2004-02-27 15:06:01 UTC
Would be nice if this ebuilds against Apache 1.x too... (I dont use Apache2).
Comment 6 Minati jean michel 2004-02-28 11:17:17 UTC
this ebuild should works with apache 1.x.
do you have any troubles with it ?
Comment 7 Minati jean michel 2004-02-28 12:10:43 UTC
Created attachment 26532 [details, diff]
Patch to upgrade to mod_security-1.7.5

Version Bump.
the dependencies have been updated , so no if you use -apache2 in USE, this add
apache 1.3.28 ( the version I used ) to dependencies.
also , the manual as been added.
Comment 8 solar (RETIRED) gentoo-dev 2004-02-28 12:39:09 UTC
Remove hardened@ from CC: 
Add us back if we are needed for anything else. (other than a commit)
Comment 9 Julien Allanos (RETIRED) gentoo-dev 2004-03-18 07:03:10 UTC
maybe it would be a great enhancement if a basic configuration file (in the /etc/apache2/conf/ directory, such as xx_mod_security.conf) was added to the ebuild?
Comment 10 Julien Allanos (RETIRED) gentoo-dev 2004-03-18 07:09:13 UTC
Created attachment 27550 [details]
an example of 99_mod_security.conf

Here is a configuration file corresponding to the examples from the official
site. You just have to put it in /etc/apache2/conf/ and add -D SECURITY to the
/etc/conf.d/apache2 file. Feel free to adjust it to your needs.
Comment 11 Minati jean michel 2004-03-19 01:48:34 UTC
I don t know if we much spend time for this ebuild.since it's not gonna be in portage.
Comment 12 Julien Allanos (RETIRED) gentoo-dev 2004-03-19 03:47:06 UTC
why won't this module be included in portage?
Comment 13 Julien Allanos (RETIRED) gentoo-dev 2004-03-24 07:45:20 UTC
Created attachment 27924 [details]
net-www/mod_security/mod_security-1.7.6.ebuild

mod_security 1.7.6 is out. here is a new ebuild for it, which corrects the
installation of the pdf manual, and add a configuration file for apache.
Comment 14 Julien Allanos (RETIRED) gentoo-dev 2004-03-24 07:45:29 UTC
Created attachment 27925 [details]
net-www/mod_security/mod_security-1.7.6.ebuild

mod_security 1.7.6 is out. here is a new ebuild for it, which corrects the
installation of the pdf manual, and add a configuration file for apache.
Comment 15 Julien Allanos (RETIRED) gentoo-dev 2004-03-24 07:47:10 UTC
Created attachment 27926 [details]
net-www/mod_security/files/99_mod_security.conf

the configuration file for apache 2.
Comment 16 Julien Allanos (RETIRED) gentoo-dev 2004-03-24 07:47:50 UTC
Created attachment 27927 [details]
net-www/mod_security/files/mod_security.conf

the configuration file for apache 1.
Comment 17 Chuck Short (RETIRED) gentoo-dev 2004-06-03 12:48:20 UTC
We wont be adding 1.7.1 to cvs since it has security problems. 

I dont have a problem adding 1.7.6 to cvs though. Will try to get to it tonight
Comment 18 Chuck Short (RETIRED) gentoo-dev 2004-06-04 10:14:38 UTC
Added last night.

chuck
Comment 19 James Kyle 2004-06-04 13:57:14 UTC
I just compiled it on a ppc machine and it worked fine if you would like to add 'ppc' to the keywords.