Postoverflow Whitelist Ignored
Hi there!
We have a custom postoverflow whitelist solution, but lately a customer has been complaining that their API bot is being banned despite being on our whitelist.
I've been debugging the issue for hours, but can't find why this happens.
We have the same whitelist system running on multiple servers, and it works flawlessly on our SMTP servers for example.
The server where we first became aware of this issue is running Apache, and the reason for the alerts and bans are crowdsecurity/http-backdoors-attempts and crowdsecurity/http-probing.
Unfortunately our customer is running a badly written API bot, so all their requests come from the same IP, regardless of the actual user's IP. They acknowledged this, and are not worried that a whitelist would let all this through.
This is how our whitelist system is set up currently (company name obscured):
/etc/crowdsec/postoverflows/s01-whitelist/custom_whitelist.yaml
The <company>_ipwl.txt contains IP ranges, something like this:
/var/lib/crowdsec/data/<company>_ipwl.txt
I've checked the contents of this file, it is correct, it contains the right IP.
It seems to me that the postoverflow step just doesn't run for some reason. I'm not sure if it has something to do with the type of alert that is being triggered, given that this system works on our mail servers.
Any help, or any debugging steps I could take are much appreciated.
Here's what I know for sure:
- the contents of the ipwl.txt file are correct
- the postoverflow is loaded
27 Replies
Important Information
This post has been marked as resolved. If this is a mistake please press the red button below or type
/unresolve
© Created By WhyAydan for CrowdSec ❤️
The whitelist is hit, but 0 requests get whitelisted.
Due to privacy reasons I can't share any actual logs or alerts here, but I'd be glad to supply anything you need to help me solve this in private messages.
You can set
debug: true
in your postoverflow to see what crowdsec is trying to match in itAlso, if the LAPI is dedicated to this customer, you can use centralized allowlists (https://docs.crowdsec.net/docs/next/local_api/centralized_allowlists) in the LAPI: they are a bit easier to work with
Allowlists | CrowdSec
The AllowLists feature in CrowdSec lets users manage IP-based allowlists at the LAPI level, affecting both local decisions and blocklist pulls. Paying customers can also control AllowLists directly from the console for added convenience. This ensures greater flexibility in managing trusted IPs while maintaining CrowdSec’s robust security measu...
We are running a company-wide LAPI unfortunately and allowlists lack a function that would allow us to switch to it.
I'll try debug: true
What is lacking ?
GitHub
Add node-specific allowlists, extend HTTP LAPI · Issue #3525 · cr...
What would you like to be added? Add node-specific allowlists the ability to tie allowlists to specific bouncers / a list of bouncers if no bouncer is set, the allowlist can remain global, thus not...
just tried your postoverflow locally, it seems to work for me:
It works for us with postfix, e.g. it whitelists requests when the scenario is crowdsecurity/postfix-relay-denied
But I just checked all our webhosting servers (running apache) and none of them seem to whitelist the IPs.
These are the logs that got the user banned with crowdsecurity/http-backdoors-attempts:
Before this, they had a user agent that got constantly banned with bad-user-agent, we told them to fix that, and that helped, there are no more bans like that.
are you sure those are legit requests ?
Because c99.php is a very well known PHP backdoor
It's extremely suspicious for a request to request this
and are you sure the postoverflows is properly loaded on the apache servers ?
Yeah, as I said the customer is using some kind of self-developed nuxt js software, and they basically created a proxy that pushes through every request, but the IP is always the same. I am sure it is a malicious request, we have told the customer about this, they are aware of the problems this could cause, but still asked us to whitelist the IP.
This is a shared hosting server, so we can't just turn off crowdsec altogether.
As far as I am aware, they are loaded correctly, I'm not sure how else I could check:
And it is also visible with postoverflows list, the status is
enabled, local
if you check
/var/log/crowdsec.log
do you see it being loaded?
like grep "custom-whitelist" /var/log/crowdsec.log
Yes
and within
ls -la /var/lib/crowdsec/data | grep "ipwl.txt"
exists?Yes, and the IP is in there (with a /32 range)
what does the debug output show ?
Also, the crowdsec install and the configurations are the same across all servers, as they are put there with SaltStack. So the one that works on the SMTP servers is the same as the one that doesn't work on our webservers.
I'll try the debug output, i'll just have to set up a quick test environment, because the customer has started using another provider temporarily.
Ah, I think I've found an issue based on the debug output.
Is reloading crowdsec after changing the file not enough?
In the debug output when it loops through the whitelisted IP range array, the newly added IP ranges are not there after a
(they are in the ipwl.txt file though)
systemctl restart crowdsec
did the trick, now it shows up in the debug output.
Is this really necessary / designed this way though? Restarts take much longer, and we'd prefer not to restart the service every time a new IP is added to the whitelist.that's weird: internally, a reload is basically a soft restart (we kill almost everything, and then start it again)
That's what I thought too.
And we modeled our whitelist script after the cron.daily upgrade script, which also only does a reload.
i can confirm the issue
the bug was introduced by this PR: https://github.com/crowdsecurity/crowdsec/pull/2419
GitHub
File init improvements by LaurenceJJones · Pull Request #2419 · c...
Current implementation has two flaws:
If user supplies same file X time, its loaded X times. This problem is extended with RE2 feature flag
The current map check only checks strings map, so added ...
Can we expect this to be fixed in the next few releases or should we find a workaround?
it will most likely be fixed in the next release, the fix should be fairly easy
for the time being, the only workaround I can think of is to restart crowdsec :/
Alright, thank you very much for the help. I'm glad we could get to the bottom of it.
Could you please ping me with a github issue when one gets created if it isn't too much of a hassle?
GitHub
Datafiles are not properly re-read on reload · Issue #3711 · crow...
When crowdsec is reloaded, any datafile (of type file or regexp) existing before the reload will not be reread, and the content will not be available for use by the parsers/scenarios. The bug was i...
Thank you very much!
Have a nice day!
Resolving Postoverflow Whitelist Ignored
This has now been resolved. If you think this is a mistake please run
/unresolve