Ban immediately after scenario is triggered
I adapted one of the scenarios to immediately ban an IP when it requests files like .env or wp. It bans the IP after some time when the url was called but always with a delay. How can I ban immediately?
I don't want the requests to reach my server. Is that even possible? because crowdsec would have to read the log and by the time the log is written, it is probably to late.
Additional info: When I call domain.tld/.env the alert and the decision are created right away but I can still browse around on the website and open other pages for half a minute until I get banned and when unbanning it always takes half a minute to be unbanned, if that is relevant.
6 Replies
Important Information
Thank you for getting in touch with your support request. To expedite a swift resolution, could you kindly provide the following information? Rest assured, we will respond promptly, and we greatly appreciate your patience. While you wait, please check the links below to see if this issue has been previously addressed. If you have managed to resolve it, please use run the command
/resolve
or press the green resolve button below.Log Files
If you possess any log files that you believe could be beneficial, please include them at this time. By default, CrowdSec logs to /var/log/, where you will discover a corresponding log file for each component.
Guide Followed (CrowdSec Official)
If you have diligently followed one of our guides and hit a roadblock, please share the guide with us. This will help us assess if any adjustments are necessary to assist you further.
Screenshots
Please forward any screenshots depicting errors you encounter. Your visuals will provide us with a clear view of the issues you are facing.
© Created By WhyAydan for CrowdSec ❤️
A lot depends on your remediation component - how frequently it gets updates from the lapi and how it applies the remediation ( thus if it for example blocks new connections but keeps the open ones)
How can I ban immediately? I don't want the requests to reach my server.Then you have to use something to block the request midway, so a WAF https://docs.crowdsec.net/docs/next/appsec/intro
AppSec Component - CrowdSec WAF | CrowdSec
Introduction
also you most likely want to do a
endsWith
on these
as you shouldnt care I look for /foo/bar/test.sql
I prefer to write my rules in raw seclang but let me know and I can convert it to our DSL but here an example blocking programming UA's
then it blocks these requests before they get to my backend

Thank you! I enabled WAF and now the requests get blocked. When going back to a normal url I still am able to access it for a few seconds before the ip gets banned.
This is my profiles.yaml with the remediation settings.
That looks neat. This would block common crawler tools?
Do I understand correctly that the appsec rules also ban like scenarios? but they only run for waf and not for the logs?
And scenarios are treated as In-band rules for the waf?
I think ideally I would want a seclang rule or new dsl that blocks all access to requests ending with certain keywords like .env and it would read the keywords from a new line separated list out of a txt file that is in the same folder as the rule.
Is that possible and could you write me something like that? or point me to resources that explain that?
I read over https://docs.crowdsec.net/docs/appsec/rules_syntax/ I guess you prefere seclang because you are used to it and you already have a lot of rules written in it?