SecFilterSelective not working?

#1
I'm trying to block users who don't have a user agent:
SecFilterSelective HEADER_USER_AGENT "^$"
SecFilterSelective HTTP_USER_AGENT "^$"

Neither work and yes I am using vhosts, no Apache. Any suggestions?
 

NiteWave

Administrator
#2
I tested
SecFilterSelective HEADER_USER_AGENT "^$"
and
SecFilterSelective HEADER_USER_AGENT ""
not working.the test command is
#curl -A "" -I 127.0.0.1/test.html

however, if not empty, e.g.
SecFilterSelective HEADER_USER_AGENT "chome"
will work as expected -- will forbid Chrome browser to access.

however, you can use rewrite rule to archive the same goal, and much simpler.
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule . - [F]

rewriterule is widely used and well tested, it's simpler yet powerful.
 
#3
I think the issue is I am trying to grab the access my site by the domain (root) - that goes through, but everything else doesn't. For some reason that rule isn't applying to /.

77.9.186.5 - - [22/Jun/2012:19:20:55 +0200] "GET / HTTP/1.1" 200 25992 "-" "-"
77.9.186.5 - - [22/Jun/2012:19:20:55 +0200] "GET / HTTP/1.1" 200 25992 "-" "-"
77.9.186.5 - - [22/Jun/2012:19:20:56 +0200] "GET / HTTP/1.1" 200 25992 "-" "-"
77.9.186.5 - - [22/Jun/2012:19:20:56 +0200] "GET / HTTP/1.1" 200 25992 "-" "-"

vs

77.9.186.5 - - [22/Jun/2012:19:20:55 +0200] "GET /index.php HTTP/1.1" 403 25992 "-" "-"

Is there a reason why rules aren't applying to the root?
 
Last edited:

NiteWave

Administrator
#6
Code:
77.9.186.5 - - [22/Jun/2012:19:20:55 +0200] "GET /index.php HTTP/1.1" 403 25992 "-" "-"
looks problem. above "25992" should be "380" ?
i.e., response body's size is 380 bytes. content is
<html>
<head><title> 403 Forbidden
</title></head>
<body><h1> 403 Forbidden
</h1>
Access to this resource on the server is denied!<hr />
Powered By <a href='http://www.litespeedtech.com'>LiteSpeed Web Server</a><br />
<font face="Verdana, Arial, Helvetica" size=-1>LiteSpeed Technologies is not responsible for administration and contents of this web site!</font></body></html>
although it's not most efficient, but only return 380 bytes instead of 25,992 bytes; more importantly, PHP is not triggered. php/mysql usually to be bottle-neck especially under attack.
 
Top