Skip to content

SecConnReadStateLimit and SecReadStateLimit doesn't work with Apache 2.4.x #786

@mariuszzbrowski

Description

@mariuszzbrowski

Hello,

I try to protect apache server before Slow HTTP Headers attack using SecConnReadStateLimit and SecReadStateLimit but this directives doesn't work with Apache 2.4.x.

I've tested few version of Apache and ModSecurity on centos 6 and centos 7 servers without success.

Apache version tested:
2.4.3 Package from internal repository
2.4.6 Package form repository
2.4.9 Compiled on my own ./configure --prefix=/usr/local/apache-2.4.9 --with-included-apr -enable-nonportable-atomics=yes --enable-so --enable-ssl

ModSecurity version tested:
2.8.0 Compiled on my own ./configure --with-apxs=path_to_apxs --with-apu=patch_to_apu --with-apr=path_to_apr
2.7.5 Compiled on my own ./configure --with-apxs=path_to_apxs --with-apu=patch_to_apu --with-apr=path_to_apr
2.7.3 Package from repository

ModSecurity configuration (2.7.3 and 2.7.5):
LoadFile /usr/lib64/libxml2.so
LoadFile /usr/lib64/liblua-5.1.so

LoadModule security2_module modules/mod_security2.so

SecRuleEngine on

SecTmpDir /tmp/
SecDataDir /tmp/

SecDebugLog /content/logs/httpd/debug.log
SecDebugLogLevel 9

SecReadStateLimit 50

SecAuditEngine RelevantOnly
SecAuditLogRelevantStatus "^(?:5|4(?!04))"

SecAuditLogParts ABIJDEFHZ

SecAuditLogType Serial
SecAuditLog /var/log/httpd/modsec_audit.log

SecRule RESPONSE_STATUS "@Streq 408" "phase:5,t:none,log,msg:'Counter +1',pass,setvar:ip.slow_dos_counter=+1, expirevar:ip.slow_dos_counter=60,id:'10'"

SecRule IP:SLOW_DOS_COUNTER "@gt 5" "phase:1,t:none,log,deny,msg:'Client Connection Dropped due to high number of slow DoS alerts',id:'11'"

SecDefaultAction "phase:2,pause:3000,deny,nolog,auditlog"

ModSecurity configuration (2.8.0):
LoadFile /usr/lib64/libxml2.so
LoadFile /usr/lib64/liblua-5.1.so

LoadModule security2_module modules/mod_security2.so

SecRuleEngine on

SecTmpDir /tmp/
SecDataDir /tmp/

SecDebugLog /content/logs/httpd/debug.log
SecDebugLogLevel 9

SecConnEngine on
SecConnReadStateLimit 50

SecAuditEngine RelevantOnly
SecAuditLogRelevantStatus "^(?:5|4(?!04))"

SecAuditLogParts ABIJDEFHZ

SecAuditLogType Serial
SecAuditLog /var/log/httpd/modsec_audit.log

SecRule RESPONSE_STATUS "@Streq 408" "phase:5,t:none,log,msg:'Counter +1',pass,setvar:ip.slow_dos_counter=+1, expirevar:ip.slow_dos_counter=60,id:'10'"

SecRule IP:SLOW_DOS_COUNTER "@gt 5" "phase:1,t:none,log,deny,msg:'Client Connection Dropped due to high number of slow DoS alerts',id:'11'"

SecDefaultAction "phase:2,pause:3000,deny,nolog,auditlog"

I've tested configuration using slowhttptest tool and behavior is that ModSecurity don't block new incoming connections after reach Read Connection limit..

With Apache 2.2.15 and ModSecurity 2.7.3 intstalled form Repository on Centos 6 all configuration works perfect.

Has someone had the same problem with apache 2.4.x ?

Please advise.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions