-
Notifications
You must be signed in to change notification settings - Fork 44
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
Bouncer does not block when ban gets readded #243
Comments
Attempt to replicate doesn't seem to be an issue with the actual LAPI. It may be an issue adding the IP to the ruleset if the IP already exists so most likely need to implement a check if it does then update it??
EDIT: checking with the team it most likely an issue just with NFTables as it doesn't like overlapping IP's or ranges so we implemented a check but I guess the check didn't go as fast as checking if the decisions is new as you can run the bouncer in ipset mode only meaning nothing is lost between reboots. |
In nftables it is not an error to add a duplicate element to a set (it is an error to add overlapping ranges, but that requires set flag The only way to refresh timers currently appears to be to delete and re-add the element, which is likely to be very slow if performed one element at a time on busy systems, however deleting a non-existent element will produce an error, which exposes some difficulty when performing updates in batches. It may be possible to achieve the desired result while retaining batches by performing a sequence of:
This seems rather inefficient, but is likely still more efficient than performing get/delete/add operations for each elem individually. The current delete code appears to fall back to deleting each elem individually in the case of a flush failure, I assume to handle the non-existent elem issue, however the whole update operation must be performed atomically to avoid exposing the system to attackers between delete and add, so the same logic cannot be applied during add/update, as the flush must happen after all operations are applied, hence the suggested add/delete/add sequence, rather than just delete/add. There does appear to be some work toward supporting timer updates on the netfilter list, however even if merged on the netfilter side, this would require updates on the kernel side too, since timer updates are apparently ignored completely on modern kernels. |
I run an instance of Uptime-Kuma and added the IP of the Container to my crowdsec banlist.
Like this I can check the functionality of the firewall bouncer with hitting the secured host with a tcp request and get a timeout because the IP is blocked. If the blocking does not work anymore, I get an notification.
The secured host uses nftables as firewall.
I created a cron job, adding the descision every night with 25h duration. Like this I am sure, the ban does never end.
But now the strange things happen.
In crowdsec itself i can list the decision and my manually added one is there all the time.
It looks to me like the firewallbouncer adds a rule with the bantime at time x.
When the decision gets added again at time y the bouncer just checks that the ip is already banned but does not extend or rewrite the bantime of the nftables rule to "y + bantime". Therefore the rule expires after "x + bantime".
(just my impression)
The text was updated successfully, but these errors were encountered: