Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModSecurity collection expirevar does not work #1803

Closed
sobigboy opened this issue Jun 14, 2018 · 17 comments
Closed

ModSecurity collection expirevar does not work #1803

sobigboy opened this issue Jun 14, 2018 · 17 comments
Labels
3.x Related to ModSecurity version 3.x workaround available The issue has either a temporary or permanent workaround available

Comments

@sobigboy
Copy link

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,

@zimmerle zimmerle self-assigned this Jun 14, 2018
@zimmerle zimmerle added the 3.x Related to ModSecurity version 3.x label Jun 14, 2018
@ghost
Copy link

ghost commented Sep 10, 2018

@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;

@zimmerle zimmerle added this to the v3.0.4 milestone Oct 24, 2018
@jptosso
Copy link

jptosso commented Mar 13, 2019

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.

@airween
Copy link
Member

airween commented Mar 13, 2019

Not yet - but I'll see that soon.

@theseion
Copy link
Collaborator

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

@victorhora victorhora added the workaround available The issue has either a temporary or permanent workaround available label Mar 21, 2019
@Hello-Linux
Copy link

Hello-Linux commented May 7, 2019

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

@theseion
Copy link
Collaborator

theseion commented May 7, 2019

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?

@pixelicous
Copy link

pixelicous commented Jul 21, 2020

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'"

@theseion
Copy link
Collaborator

@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).

@liusir-ht
Copy link

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

@ccl123456789012
Copy link

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

@tomsommer
Copy link
Contributor

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

@martinhsv
Copy link
Contributor

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.

@theseion
Copy link
Collaborator

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

@sharmashivanand
Copy link

@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.

@theseion
Copy link
Collaborator

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.

@martinhsv
Copy link
Contributor

This has now been merged.

@martinhsv martinhsv removed this from the v3.1.0 milestone Oct 25, 2023
@tomsommer
Copy link
Contributor

Thank you for your work 🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Related to ModSecurity version 3.x workaround available The issue has either a temporary or permanent workaround available
Projects
Status: Done
Development

No branches or pull requests