ModSecurity icon indicating copy to clipboard operation
ModSecurity copied to clipboard

ModSecurity 3.0.3 collection expirevar does not work

Open sobigboy opened this issue 7 years ago • 8 comments

When I use collection 'IP', the variable in collection never expire even if I restart nginx. The variable in collecion expired unless I remove the files:modsec-shared-collections modsec-shared-collections-lock in disk,

sobigboy avatar Jun 14 '18 08:06 sobigboy

@sobigboy how do you get the values of modsec-shared-collections modsec-shared-collections-lock in disk, i tried it in dos-attack and dos run well , but i can't get the attack-ip values or timestrap;

ghost avatar Sep 10 '18 08:09 ghost

Hello, any update on this? I have been testing and the collection file under /modsec-shared-collections is not being expired according to expirevar nor SecCollectionTimeout. I'm using --with-lmdb because the standard method would destroy each collection on reload.

jptosso avatar Mar 13 '19 03:03 jptosso

Not yet - but I'll see that soon.

airween avatar Mar 13 '19 06:03 airween

Meanwhile here's a workaround for everyone who needs DOS protection to work. The hack uses dedicated variables in conjunction with the TIME_EPOCH variable to explicitly expire the DOS variables.

REQUEST-912-DOS-PROTECTION.conf.txt

theseion avatar Mar 20 '19 15:03 theseion

The document you provided really works. But if I change the browser I'll have normal access the web server So I think this disabling policy is only for the combination of the browser and the IP address and not for the IP address alone I feel the authorities should fix this problem or adopt your document @theseion

Hello-Linux avatar May 07 '19 06:05 Hello-Linux

Good to hear that, thanks. As for switching browsers: that shouldn't make a difference. AFAICT, only the IP is considered for the blocking logic. Are you sure that you don't have a proxy configured in one of those browsers?

theseion avatar May 07 '19 07:05 theseion

The solution posted by @theseion above didn't help in my case. Added it to my already existing file, restart the server. Tested on a browser that was available before (which is weird in the first place, one browser got blocked while the other was available), now none of my browsers are available now unless restarting server

Supposed to block remote ips based on getting 404 more than 3 times, for 60secs

SecAction "phase:1,initcol:ip=%{REMOTE_ADDR},id:'123456'"
SecRule RESPONSE_STATUS "@streq 404" "phase:3,pass,setvar:ip.block_script=+1,expirevar:ip.block_script=60,id:'1234567'"
SecRule IP:BLOCK_SCRIPT "@ge 3" "phase:2,deny,status:403,id:'12345678'"

pixelicous avatar Jul 21 '20 01:07 pixelicous

@pixelicous Sorry, this is very late.

You're using expirevar, which does not work (at least it didn't when I wrote the workaround). Make sure to do everything as it's done in the workaround because there are a couple of things that matter (e.g. casing, phase order).

theseion avatar Dec 22 '20 18:12 theseion

Hello,@pixelicous I met the same problem. Has this problem been solved?

liusir-ht avatar Mar 31 '23 03:03 liusir-ht

使用了提供的REQUEST-912-DOS-PROTECTION.conf.txt,发现一个问题某个ip访问被判断为ddos,应该会封禁该ip一个小时但是偶尔还是可以该网站

ccl123456789012 avatar May 31 '23 01:05 ccl123456789012

Can we please have this fixed? It's pretty critical as it breaks all collections?

tomsommer avatar Jul 24 '23 08:07 tomsommer

There is an implementation for this support here: https://github.com/SpiderLabs/ModSecurity/tree/v3/dev/action_expirevar

There will be at least a short delay before it is merged.

martinhsv avatar Oct 12 '23 13:10 martinhsv

Thanks @martinhsv! It will be a good day when this feature is release.

theseion avatar Oct 13 '23 05:10 theseion

@theseion When I implement the workaround, it clashes with inbound anomaly score. (Also can we pls create a separate thread to help with this workaround?)

Matched "Operator Ge' with parameter 10' against variable TX:BLOCKING_INBOUND_ANOMALY_SCORE' (Value: 10' )

I'm using [ver "OWASP_CRS/4.0.0-rc1"] on nginx.

sharmashivanand avatar Oct 13 '23 07:10 sharmashivanand

The version I wrote was for CRS 3.0.1. I do not have a working version for 4.0 and seeing as it will (hopefully) be a non-issue soon, the plugin implementation we created for CRS v4 for ModSecurity v2 should work for v3 as well, when expirevar works: https://github.com/coreruleset/dos-protection-plugin-modsecurity-v2.

theseion avatar Oct 14 '23 08:10 theseion

This has now been merged.

martinhsv avatar Oct 25 '23 14:10 martinhsv

Thank you for your work 🥇

tomsommer avatar Oct 26 '23 09:10 tomsommer