• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Issue ModSecurity Rule in custom directives ignored

Abed

New Pleskian
Hello,
I have Mod security enabled on the server. Recently, we've been getting daily bots from cortex/1.0 bot (faceboook). WAF is on and set to comdo Free, and predefined to FAST. I have added some custom rules in the custom directives to limit that user-agent, from a solution I saw online used in Apache.p Site is using Apache-FPM, serve static files by Nginx and nginx caching are not enabled. Only proxy mode and static file processing are enabled.

# Limit client hits by user agent
SecRule REQUEST_HEADERS:User-Agent "@pm cortex/1.0" \
"id:400009,phase:2,nolog,pass,setvar:global.ratelimit_cortex=+1,expirevar:global.ratelimit_cortex=3"
SecRule GLOBAL:RATELIMIT_CORTEX "@gt 2" \
"chain,id:4000010,phase:2,deny,status:429,setenv:RATELIMITED,log,msg:'RATELIMITED BOT'"
SecRule REQUEST_HEADERS:User-Agent "@pm cortex/1.0"
Header always set Retry-After "3" env=RATELIMITED
ErrorDocument 429 "Too Many Requests"

if I test with curl -A "cortex/1.0" example.com & curl -A "cortex/1.0" example.com & curl -A "cortex/1.0" example.com
it returns the proper result and I see in the logs that there is a Modsecurity deny for the 3rd request. I also tested from python selenium with success and from multiple ips at the same time as well.

However, when the actual bot comes in, its just makes the requests and they are served without any denying. I checked on Cloudflare and I can see the bot making the requests thousands of times with that exact user-agent in the header.... I also can see it in apache logs, that its clearly the same agent making multiple requests in the span of 3 seconds and nothing gets denied at all.

From the apache access log segment below (there are actually thousands of similar requests in the span of seconds/1 minute), Modsecurity should have started denying the requests. I'm wondering if there is a setting I should be aware off because it doesn't make sense to me. Any help is appreciated
Line 100: 2a03:2880:30ff:12::face:b00c - - [09/Dec/2021:11:05:01 -0500] "GET /url-here HTTP/1.0" 200 1048 "-" "cortex/1.0"
Line 101: 2a03:2880:20ff:11::face:b00c - - [09/Dec/2021:11:05:01 -0500] "/url-here HTTP/1.0" 200 1048 "-" "cortex/1.0"
Line 108: 2a03:2880:21ff:15::face:b00c - - [09/Dec/2021:11:05:01 -0500] "GET /url-here HTTP/1.0" 200 1038 "-" "cortex/1.0"
Line 114: 2a03:2880:30ff:14::face:b00c - - [09/Dec/2021:11:05:01 -0500] "GET /url-here HTTP/1.0" 200 1048 "-" "cortex/1.0"
Line 115: 2a03:2880:31ff:7::face:b00c - - [09/Dec/2021:11:05:01 -0500] "GET /url-here HTTP/1.0" 200 1038 "-" "cortex/1.0"
Line 116: 2a03:2880:23ff:c::face:b00c - - [09/Dec/2021:11:05:01 -0500] "GET url-here HTTP/1.0" 200 1048 "-" "cortex/1.0"
Line 118: 2a03:2880:12ff:a::face:b00c - - [09/Dec/2021:11:05:01 -0500] "GET url-here HTTP/1.0" 200 1048 "-" "cortex/1.0"
Line 121: 2a03:2880:31ff:20::face:b00c - - [09/Dec/2021:11:05:01 -0500] "GET url-here HTTP/1.0" 200 1048 "-" "cortex/1.0"
Line 123: 2a03:2880:31ff:8::face:b00c - - [09/Dec/2021:11:05:01 -0500] "GET /url-here HTTP/1.0" 200 1038 "-" "cortex/1.0"
 
Back
Top