Is this for academic research purposes or
do you have a specific issue you are trying to address? The reason why I
ask is that you can potentially provide a large amount of information to a
client. This could be both good and bad… For non-malicious
users, this information can be very help and it could speed along the
trouble-shooting process. For malicious users, however, this data could
help them to try and evade detection.
So, implement this with caution!
Check out pages 10-11 of this doc - http://www.modsecurity.org/documentation/ModSecurity2_Deployment.pdf
This will present the user with the mod_unique_id value of the current
transaction. They could then include this in their helpdesk email and it
would allow the ModSecurity admin to pull up the correct transaction and
inspect what happened.
So, let’s say that you have these lines
set in your httpd.conf file so that you can execute SSI in the custom 403
forbidden doc -
ErrorDocument 403
/error/HTTP_FORBIDDEN.shtml
<Location
"/error/">
Options +IncludesNoExec
</Location>
The contents of the HTTP_FORBIDDEN.shtml
file is this –
<HTML>
<HEAD>
<TITLE>403
Forbidden</TITLE>
</HEAD>
<BODY>
<H1>Forbidden</H1>
You don't have permission
to access the requested directory.
There is either no index
document or the directory is read-protected.
<P>
The ModSecurity Transaction # is - <!--#echo
var="UNIQUE_ID" -->
The ModSecurity Rule ID that matched is - <!--#echo
var="REDIRECT_MOD_MSG" -->
<HR>
</BODY>
</HTML>
Now you would need to update the Core
Rules to add the “setenv” action like this -
SecRule
REQUEST_FILENAME|ARGS|ARGS_NAMES
"(?:\b(?:\.(?:ht(?:access|passwd|group)|www_?acl)|global\.asa|httpd\.conf|boot\.ini)\b|\/etc\/)"
\
"capture,t:htmlEntityDecode,t:lowercase,ctl:auditLogParts=+E,deny,log,auditlog,status:403,msg:'
Remote File Access
Attempt. Matched signature <%{TX.0}>',id:'950005',severity:'2',setenv:mod_msg=950005"
Now, if someone triggers this rule, the
403 status will be triggered and it will use the ErrorDocument setting. The
client would receive a page similar to this –
Forbidden
You don't have permission to access the requested
directory. There is either no index document or the directory is
read-protected.
The ModSecurity Transaction # is -
0yd9yMCoD4QAAB7FAqoAAAAA
The ModSecurity Rule ID that matched is - 950005
--
Ryan C. Barnett
ModSecurity Community
Manager
Breach Security: Director of Training
Web Application Security Consortium (WASC)
Member
CIS Apache Benchmark Project Lead
SANS Instructor, GCIA, GCFA, GCIH, GSNA,
GCUX, GSEC
Author: Preventing Web Attacks with Apache
From:
mod-security-users-bounces <at> lists.sourceforge.net
[mailto:mod-security-users-bounces <at> lists.sourceforge.net] On Behalf Of Oteng Michael Raesima
Sent: Friday, February 01, 2008
7:26 PM
To:
mod-security-users <at> lists.sourceforge.net
Subject: [mod-security-users]
return IP address to client browser for rulematch
Good day to you all
I am using ModSecurity v2.1.4. I am bew to ModSecurity and am experimenting. I
would like to return client's IP address and a custom message to matches to
certain rule ID's to their browser. Could anyone assist me as to how to do this
given the directives in the core rule set and Apache.
Thank you
Oteng