43 Replies
As my custom rules, after 5minutes or less get changed to block, and unused filter.
like this.
pretty much the action changes.
no known issues https://www.cloudflarestatus.com/, and nothing like that
I would check your Audit Log to see what's changing it. If you're using a partner like Ezotic or something with access to your account
User cloudflare... and it changes the value this part specifically.
show the full audit event (hiding your account name/etc as needed)?
]
is there any other events or interest around/before that? That w/ the firewall api property kind of looks like something using the old firewalls api and it being translated to a custom rule update
Like terraform or something like that, using those old endpoints
i have 3 api keys
1 which i should remove, and i will do now,
1 for subdomains (custom stuff)
1 for fail2ban
i think fail2ban is the issue, as it wasnt doing this before
you don't see anything else in the audit log, and fail2ban is given access to that domain/zone?
yes fail2ban has access to the zone
could you just stop/pause fail2banfor a bit, change the custom rule back, and see if it happens again?
easier to turn back on then reissuing the token and setting it up again
o9k ill pause it and see what happens
ok ill pause fail2ban everywhere
k paused everywhere, now ill change the rule again.
and now we wait 😄
seems like that was the issue.
but i need fail2ban with cloudflare, not sure what i did wrong with permission.
not permission based, not sure how exactly fail2ban interfaces with Cloudflare (a plugin maybe?), but it looks like it's 1. using the old Firewall API (will be gone in 2025 Jan) and 2. overriding other rules
Ok how can i use the new firewall api ig
for the record it's here - /etc/fail2ban/action.d/cloudflare.conf and it should be there by default.
this is what i had there.
i have removed personal information.
Any idea what could be causing it to change the rules?
it was making a fw rule per ban? You'd run out rather quickly I would assume
I'm not sure of all the auto translation magic between old firewall api and the new custom rules, there's some docs here: https://developers.cloudflare.com/waf/reference/migration-guides/firewall-rules-to-custom-rules/#relevant-changes-for-api-users
Cloudflare Docs
Firewall Rules to WAF custom rules migration · Cloudflare Web Appli...
Cloudflare converted existing firewall rules into WAF custom rules. With custom rules, you get the same level of protection and a few additional …
The goal was just to make the ip get banned on all the servers nothing else
Like if it gets banned on 1 server, it gets banned everywhere
why not use IP Access Rules and their api?
looks like they even have a default config which uses them: https://github.com/fail2ban/fail2ban/blob/master/config/action.d/cloudflare-token.conf
GitHub
fail2ban/config/action.d/cloudflare-token.conf at master · fail2ban...
Daemon to ban hosts that cause multiple authentication errors - fail2ban/fail2ban
ill use that configuration, and let you know how it works.
thanks
sure, you can have up to 50,000 of those, should be plenty
ill use this config, let you know if the issue persist, thanks!
ok so i started reconfigurring the servers, and i noticed this, is it normal that you don't see the same amount of bans on all the servers?
ok finally updated alll configurations, now let's see.
will see if it get's changed again.
I do not use fail2ban, but I would assume each server is independent
the issue still persists
well it stopped when you paused fail2ban right?
yep
I would wager then somehow one of the servers isn't updated or is using both configs/etc
i was already using that config by default, but yea i just putted the info
ill doublecheck again.
ps, if you didn't see the migration I linked above:
Cloudflare will internally convert your Firewall Rules API and Filters API calls into the corresponding Rulesets API calls. The converted API calls between the Firewall Rules API/Filters API and the Rulesets API appear in audit logs as generated by Cloudflare and not by the actual user making the requests.that's why it shows as CF user
ok
I double checked, issue persists
now it's spamming this tho
maybe is there a way to "whitelist" specific rules?
so they don't get touched?
Well let me know if anyone has any ideas, thanks
hard to test volume from that but you might want to be careful/limit things a bit to not hit the global 1200 requests per 5 minutes limit.
Those ruleset updates mean something's still using the old firewall rules api
Mh I'll change the api key, and update all servers, will see what happens
Ok so i updated the key, i deleted the old one, updated everywhere, and for now seems to be good,
ill let you know how it goes
Seems like that helped thank you!