27 Jun 13:58
problem with my regex and single line HTML comment in RESPONSE_BODY
From: Stephen Craig Evans <stephencraig.evans <at> gmail.com>
Subject: problem with my regex and single line HTML comment in RESPONSE_BODY
Newsgroups: gmane.comp.apache.mod-security.user
Date: 2008-06-27 12:00:47 GMT
Subject: problem with my regex and single line HTML comment in RESPONSE_BODY
Newsgroups: gmane.comp.apache.mod-security.user
Date: 2008-06-27 12:00:47 GMT
Hi,
I'm having a problem with a regex.
I want to prevent content in an HTTP response being returned as in:
<!--
TODO admin:adminpw
-->
My regular expression:
<!--[ \r\n\t]*(.?)*(Admin|admin|administrator|pwd|password)(.*)[ \r\n\t]* -->
works both in Regex Coach and Expresso 3.0 and on variations such as:
<!--
Use Admin to regenerate database
-->
which is what I want.
To try to make a long story short - without a bunch of debug stuff -
it works as designed on the 'bad' pages with multiline HTML comments
like above but when it processes a page with any HTML comment on one
line (e.g. <!-- Stop Instructions -->) it chokes and stops processing
the page.
My rule:
SecRule RESPONSE_BODY "<!--[
\r\n\t]*(.?)*(Admin|admin|administrator|pwd|password)(.*)[ \r\n\t]*
-->"
"phase:4,ctl:auditLogParts=+E,log,deny,status:501,auditlog,msg:'HTML
(Continue reading)
Cheers,
Stephen
On Fri, Jun 27, 2008 at 10:45 PM, Ryan Barnett <Ryan.Barnett <at> breach.com> wrote:
> Stephen,
> First off, I am sending you a "Virtual High-Five" as you are
> demonstrating that you are using many of the various tools and
> techniques that we have been discussing for trouble-shooting! Using
> RegEx Coach/Expresso and also leveraging the debug log is outstanding.
>
> To your exact issues, I don't believe that Mod was "choking" on anything
> but rather that your RegEx was not working correctly for the single line
> comment. Here are a few comments -
>
> 1) While RegEx tools (such as Expresso) are invaluable for helping to
> create or trouble-shoot regex issues, beware that you can also run into
> issues if the tool is not configured identically to how ModSecurity's
> pcre/transformations will be used. I just ran into this recently where
> Expresso had the option checked to "Ignore Whitespace" and it screwed up
> some of my tests. In Expresso 3.0, click on the "Design Mode" tab and
RSS Feed