Setup Rate Limit / DDoS Control
Last updated
Was this helpful?
Last updated
Was this helpful?
open-appsec agents can limit the number of requests to a matched URI within a configured time scope, according to the source identifier.
An agent from version 1.1.2 and up is required.
Browse to Assets and edit the relevant Web Application asset. Choose the RATE LIMIT tab.
Pay attention to the configuration of Source Identity. When counting requests to see if a limit was exceeded, the source identity is the key according to which they are counted,
i.e. "X requests from the same source identifier...".
In the community edition, only IP and X-Forwarded-For are supported as Source Identities.
If the source identity configuration doesn't match a value, the source IP address is used instead to count the request.
There are 3 optional modes:
Prevent - Rate limit is enforced.
Detect/Learn - Only logs will be issued if the rate limit is reached.
Inactive - Temporarily disable the rate limit function, instead of deleting the practice altogether.
When creating a new rule or editing an existing rule, a configuration window will open:
A rate limit rule consists of:
Action configuration. there are 3 options:
According to practice - The action will be determined by the practice mode previously configured.
Detect - Only logs will be issued if the rate limit for this rule is reached. This will override the practice mode unless it is Inactive.
Prevent - Rate limit for this rule is enforced. This will override the practice mode unless it is Inactive.
Match conditions:
URI - A string written in this field is concatenated as a suffix to all defined URLs of the Web Application or Web API asset. The concatenation result is considered the prefix for all requests that will match this rule. While the URI field does not accept a regular expression, it does support usage of '*' wildcard character. Example - If the Asset's defined URLs are "http://www.myapp.com" and "https://www.mysecureapp.com" and the URI in the rule is "/docs", it will be matched on all requests starting with either http://www.myapp.com/docs or https://www.mysecureapp.com/docs.
Use "/" to match all requests to the asset's domains.
Additional Conditions - An optional logical expression in addition to the main URI regular expression. The logical expression can use AND/OR/NOT between matching key-value pairs to decide what traffic should be counted to determine if rate of requests has exceeded. There are several keys that can be used:
URI - A regular expression that is matched on the URI field. Since the main URI field already creates an initial prefix match of the URI path, the regular expression is usually used to match specific states if a wildcard was used, or strings in the full URI beyond the prefix.
Source Identifier - A regular expression matching the source identifier values according to Source Identity configuration of the asset. If source identifier is not detected in traffic according to configuration, the value will be matched vs the source IP address.
Source IP - A network IP address in X.X.X.X format or CIDR (e.g. 11.22.33.44/24).
Limit configuration:
Limit - the maximum number of requests in a specific time scope.
Time Unit - the time scope in which the limit is enforced.
Trigger configuration: Configure the trigger (usually the log trigger) that will activate when a Rate Limit rule is fully matched by URI as well as requests rate.
In Detect/Learn mode, the Trigger is the only action that will occur if the rate of matched URIs from the same source identifier has exceeded configured limits.
After clicking OK, you will see the full rule:
Click Enforce on the top banner of the open-appsec portal.