You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: crowdsec-docs/docs/appsec/configuration.md
+82Lines changed: 82 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,6 +58,88 @@ inband_rules:
58
58
#...
59
59
```
60
60
61
+
## Disabling rules at runtime
62
+
63
+
Even though we try to provide rules without false positives, sometimes a virtual patching rule can block legitimate requests on a website.
64
+
65
+
You can disable rules at runtime, either globally (for all requests) or based on specific conditions (source IP, URI, ...).
66
+
67
+
You can can disable rules by:
68
+
- Name with `RemoveInBandRuleByName`: Intended for disabling rules provided by crowdsec (the name is the name of the appsec-rule as seen in `cscli appsec-rules list`).
69
+
- ID with `RemoveInBandRuleByID`: Intended for disabling seclang rules
70
+
- Tag with `RemoveInBandRuleByTag`: Intended for disabling seclang rules
71
+
72
+
The same functions exist for out-of-band rules, prefixed with `RemovedOutBandRuleBy...`
73
+
74
+
To disable a rule, we'll first create a new `appsec-config` to avoid tainting the configuration from the hub (if you are already using a custom configuration, you can update this one instead).
We are using the [hooks](/docs/appsec/hooks.md) provided by the appsec to modify the configuration in 2 places:
88
+
- `on_load`: Expressions here will be applied when crowdsec loads the configuration, effectively disabling the rule `crowdsecurity/vpatch-env-access` globally.
89
+
- `pre_eval`: Expressions here will be applied only if the provided filter matches. In this example, we are disabling the rule `crowdsecurity/generic-wordpress-uploads-php` only if the request URI starts with `/blog/` and if we are currently processing in-band rules.
90
+
91
+
You can also disable native (seclang) rules by providing their ID with the `RemoveInBandRuleByID` helper. See the [hooks](appsec/hooks.md) documentation for a list of available helpers.
92
+
93
+
Also note that we are not loading any rules in our custom config: the rules are loaded by the `crowdsecurity/appsec-default` config, and we are just modifying the runtime behavior with this config.
94
+
95
+
Finally, we need to tell crowdsec to load our new config:
If your reverse-proxy forwards all requests to crowdsec, regardless of the FQDN, you can disable the appsec for specific domain with a custom appsec-config (ie, the request will be always allowed):
With this config, the rules will still be evaluated, but if a rule matches no alert or event will be generated, and the remediation will be set to `allow`(ie, instruct the bouncer to let the request through).
142
+
61
143
## Appsec configuration
62
144
63
145
The AppSec configuration is referenced by the acquisition configuration (`appsec_config`, `appsec_configs` or `appsec_config_path`):
Copy file name to clipboardExpand all lines: crowdsec-docs/docs/appsec/protocol.md
+15-14Lines changed: 15 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,14 +22,15 @@ This documentation can be useful in case you want to write your own remediation
22
22
23
23
To work with the CrowdSec application security component, some HTTP headers are require, in addition to the other HTTP headers and the body of the original request.
|`200`| The HTTP request is allowed |`{"action" : "allow"}`|
102
-
|`403`| The HTTP request triggered one or more application security component rules |`{"action" : "ban", "http_status": 403}` or `{"action" : "captcha", "http_status": 403}`|
103
-
|`500`| An error occurred in the application security component. The remediation component must support a `APPSEC_FAILURE_ACTION` parameter to handle this case |`null`|
104
-
|`401`| The remediation component is not authenticated. It must use the same API Key that was generated to pull the local API request |`null`|
|`200`| The HTTP request is allowed |`{"action" : "allow"}`|
103
+
|`403`| The HTTP request triggered one or more application security component rules |`{"action" : "ban", "http_status": 403}` or `{"action" : "captcha", "http_status": 403}`|
104
+
|`500`| An error occurred in the application security component. The remediation component must support a `APPSEC_FAILURE_ACTION` parameter to handle this case |`null`|
105
+
|`401`| The remediation component is not authenticated. It must use the same API Key that was generated to pull the local API request |`null`|
105
106
106
107
In case of a `403` response, the body will contain the action to take and the HTTP status code to return to the client.
0 commit comments