-
Notifications
You must be signed in to change notification settings - Fork 1.6k
"Database is not open. Use: SecGeoLookupDb directive." after reload #2041
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
I believe the issue is probably due to the fact that the call to GeoLookup::setDataBase is made only at the parser here: https://github.com/SpiderLabs/ModSecurity/blob/v3/master/src/parser/seclang-parser.cc#L2706-L2723 The leads me to believe that on a reload, when GeoLookup::evaluate eventually is called, GeoLookup::lookup is called directly without any prior call to GeoLookup::setDataBase. We might be missing an init() at the geo_lookup.cc operator. That being said, I could only reproduce this bug when I had BOTH MaxMind and the legacy GeoIP libraries/db installed. |
Tested your workaround and it does work:
|
Thanks for the feedback @asdfuken. Good to know that it works as intended this way :) Regardless, we'll try to get it fixed prior to 3.0.4 release. Thanks for reporting! |
GeoIp is already being cleaned elsewhere. Fix #2041
GeoIp is already being cleaned elsewhere. Fix #2041
GeoIp is already being cleaned elsewhere. Fix #2041
GeoIp is already being cleaned elsewhere. Fix #2041
GeoIp is already being cleaned elsewhere. Fix #2041
GeoIp is already being cleaned elsewhere. Fix #2041
GeoIp is already being cleaned elsewhere. Fix #2041
GeoIp is already being cleaned elsewhere. Fix #2041
GeoIp is already being cleaned elsewhere. Fix #2041
…d MaxMind libraries are present due to owasp-modsecurity/ModSecurity#2041
From the looks of this ticket, this fix has not yet made it to libmodsecurity? It's still planned for 3.1.0? Is there an estimate when it will become part of a release? |
Hello @davand01 , The SecGeoLookupDb configuration item does work in ModSecurity v3. I have used it myself moderately recently with:
|
@martinhsv - it works for me too, however if there is a reload (not restart) of nginx this exact error persists. |
Hello @davand01 , I do not see this effect when performing an nginx Per the comments from 2019, it looks like this issue was only reproducible if "BOTH MaxMind and the legacy GeoIP libraries/db installed". Is that the case for you? |
Hello, I am running Nginx with modsecurity which has both "MaxMind and the legacy GeoIP libraries/db installed". I can still notice the bug that when I perform an nginx -s "reload", it no longer works. I would have to restart the container (docker) running the engine for it to work! Has this bug been resolved? |
I'm afraid it hasn't. But I think it's rather a connector issue than libmodsecurity3 - we have to investigate it. Thanks for this reminder! |
Would it be okay for me to raise this as a separate issue, or will the team be reopening the existing issue? |
I reopen this issue - thanks! |
Describe the bug
I'm using mmdb to block countries from my website and it works fine until I reload my nginx server and I start getting the message "Database is not open. Use: SecGeoLookupDb directive." in the debug log and no country would be blocked anymore.
Logs and dumps
Before reload:
After reload:
ModSecurity config log:
To Reproduce
Use the following configuration with your own country code and restart nginx.
Test with your own country code and you should get a 403 forbidden error code, then remove your country from the collection, reload and try again, you should receive 200. Add your country code again to the collection and you should get a 200 status and the previous reported message in the logs as the geoip database was unloaded.
Or you can just create a disruptive rule with geoip and after testing it works, you can check if it works after a reload.
Expected behavior
Allow me to reload the geoip database without restarting the server.
Server:
--with-http_ssl_module
--add-module=/tmp/ModSecurity-nginx/
--with-http_ssl_module
--with-http_sub_module
--with-http_realip_module
--with-http_sub_module
--with-http_gunzip_module
--with-http_gzip_static_module
More info
It seems like Utils::GeoLookup::getInstance().cleanUp(); is being called and Utils::GeoLookup::setDataBase is not being called again, I'm trying to find out the problem over there.
Small workaround
You can "reload" nginx by renewing the process:
That would reload the whole engine and nginx without any downtime but using many resources.
Benchmarks for 1000 reloads and winchs in a 8 core 16gb memory server with just 100 rules:
The text was updated successfully, but these errors were encountered: