-
Notifications
You must be signed in to change notification settings - Fork 1.7k
How to use persistent collections in ModSecurty v3.0.x? #1754
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
Comments
Well regression tests are passing for collections. I ran some rules collected from the regression test with debuglog 9 with v3.0.0 and v3/master. The difference of the to logs:
I think this maybe a bug :( |
Hi @LeeShan87, Within version 3 we have opted to make a plug-able architecture in terms of collections storage. By default we support the in-memory collection, which is an independent storage per process. The sdbm support (compilation flag) allow the communication via shared memory between the different process. There are also tickets opened to support the collections in Memcahe (#1140) and Redis (#1139). Keep in mind that even in v2 this math won't match as the collection where sync with the main process from time to time depending on various factors including a dice. With means that an increment may or may not work. |
@zimmerle @victorhora how does one move back and forth between storage engines when SDBM support is compiled in? |
Hi @zimmerle and @victorhora! Thank you for your reply. I have found that compilation flag. And I actively follow the progression of the mentioned to tickets. My issue is since commit 6f7fdd9 I can even use collections.
My current setup is: |
We are investigating this one. Reopening... Also seems related with #1778 |
fixed by 892beb5 |
Hi, A good to know notice: |
Humm... good catch @LeeShan87 i am going to have a look on ti. Thanks. |
Hi,
This could lead to problems with owasp-modsecurity-crs rules: REQUEST-912-DOS-PROTECTION and REQUEST-910-IP-REPUTATION. For example the vars are set in lowercase: setvar:'ip.dos_counter=+1' and accessed in uppercase: SecRule IP:DOS_COUNTER |
Hey @revilzs / @LeeShan87 Can you please check if this still happens in the current master of libModSecurity? As far as I can recall, PR #1810 was targeted to fix this inconsistency, but then #1820 covered this fix and other improvements which was merged at d810de9 |
It's looks really fixed to me in v3.0.3. Nginx: 1.15.6 It' not related to this issue, but in can be a pain in the a... So if a threshold exceeded in one worker, it's not means, that another will not serve the HTTP request. This other issue could be solved, if it were implemented yet, with redis or memcached collection backends. Or with lmdb, but it has other bugs (last time I've checked). |
I'm having trouble with lmdb and enabling it so processes can communicate with one another. I've compiled modsecurity (3.0.3) with Also @zimmerle commented about
But I can't find such flag when compiling modsecurity? |
@plamer SDBM is the default collection backend. It means that if you don't specify other collection backends such as LMDB, SDBM will be used by default. See here the collections backends here: https://github.com/SpiderLabs/ModSecurity/tree/v3/master/src/collection/backend Please notice that LMDB support is still experimental, so I would advise trying to reproduce the same scenario without LMDB. If the issue still persists, let us know and we can investigate. Thanks. |
@victorhora I did compile libmodsecurity without
I'm using v3 from master (cloned and compiled today): libmodsecurity compiled with:
nginx compiled with:
|
Hi @plamer |
Hi!
I'm trying to create some rules which use IP persistent collection.
First i tried with Nginx v1.14.0, ModSecurity-nginx master, ModSecurity v3.0.0 without lua or lmdb.
The collection initialized and I could make a counter. Like count every page load on the given uri.
But expirevar is not working. Which is very bad, if I try something like this on a production server.
After this I tried ModSecurity v3.0.2, with the same setup and configurations.
But in this case the rules previously worked are not working at all.
Operator like gt eq not working with that counter. I can't even get it value logged out.
I saw in the commits there were many changes related to collection naming since v3.0.0, but haven't found any example how should I use after these changes.
So my question is can you provide some example how to use IP collection in v3.0.2?
How can we change backend from in memory collection to other, like lmdb( or later to redist)?
Some example rules:
The text was updated successfully, but these errors were encountered: