Enforcement

How to configure custom filtering rules for different types of traffic.

Available only in Anti-bot mode.

This feature is enabled on request. If the Enforcement tab in Custom rules is inactive in the UI, contact support to enable it.

By default, you can create up to 20 enforcement rules. If you need more, contact support to increase the limit.

About enforcement rules

Description

Enforcement is a group of rules that lets you flexibly configure how protection responds in specific situations.

For example, you can configure rules like these:

  • Block requests to /admin that do not come from your work IP address.

  • Pass requests to /signup when the source is a human, and return a CAPTCHA when the source is Likely human, Likely bot, or Bot.

  • Block a request that includes the ?view=all query parameter but does not include your secret cookie.

  • Allow an IP address to send no more than five POST requests per minute to /api/reports/export, and block requests that exceed the limit.

Rules you create take priority over the individual protection settings configured for your resource by Strictera engineers.

Features

Rules are evaluated in order

You assign each rule a position—its sequence number in the overall list of rules. The order is critical. During filtering, protection strictly follows the list: it first checks whether a request matches the conditions of the first rule. If it does not, it checks the second rule, then the third, and so on. As soon as protection finds a matching rule, it applies it and skips the rules below it.

Example

You have created three rules:

  1. Block requests from India.

  2. Return a cookie challenge for requests from Kazakhstan.

  3. Return a JavaScript challenge for requests to /login.

A request to /login arrives from Kazakhstan. Protection first checks whether it matches the first rule. It does not. It then checks the second rule. It matches, so the client receives a cookie challenge. Protection does not check the third or any subsequent rules.

A single rule can apply different actions to different source classes

Before applying a rule, protection analyzes every request and assigns its source to one of four classes: Human, Likely human, Likely bot, or Bot. Within one rule, you can configure a separate protection response for each class.

Example

You have created a rule for requests to /signup and configured the following actions:

  • Bot—return a CAPTCHA.

  • Likely bot—return a JavaScript challenge.

  • Likely human—return a JavaScript challenge.

  • Human—pass the request.

A request to /signup arrives. After analyzing the technical and behavioral attributes of its source, protection assigns it the Likely bot class. Based on your custom rule, it then returns a JavaScript challenge in response.

Enforcement works together with other rule groups

Four rule groups are available in the management console:

You can use them together to configure filtering more precisely for specific scenarios.

Example

For requests to /reports/generate, you have configured the following:

  • Rate limits—10 requests in five minutes from one IP address.

  • Score collection—return a JavaScript challenge and calculate the source’s bot score.

  • Bot classification—consider sources with a bot score of 0.4 or higher to be bots.

  • Enforcement—pass requests from humans and return a CAPTCHA to bots.

A request to /reports/generate arrives. Protection first checks whether the number of requests from that IP address has reached the limit of 10 requests in five minutes. If the limit is reached, the IP address is temporarily blocked. Otherwise, protection calculates the bot score and determines the source class. A source with a bot score of 0.4 or higher is considered a bot and receives a CAPTCHA.

Place in the filtering hierarchy

Protection filters every request in stages: first with one filtering mechanism, then another, and so on. The list below shows where Enforcement is placed:

If two filtering mechanisms conflict, the one that is evaluated first applies. For example, the black list is evaluated before enforcement rules. Therefore, a request from an IP address on the black list is blocked even if an enforcement rule is configured to pass it.

Recommendations

  • Note that if you do not specify any conditions, the rule applies to all incoming traffic.

  • Place specific rules above general ones. For example, a rule that passes a partner’s IP address must be above a rule that blocks requests from an entire country. Otherwise, if the partner’s IP address belongs to a blocked country, protection applies the block first and does not reach the allow rule.

  • Enforcement rules are evaluated from top to bottom, and the first matching rule applies. If you change their order, check the result in Request logs: filter entries by rule ID and make sure the rule applies at the required time.

  • Do not return a JavaScript challenge to sources that cannot run JavaScript. This type of check is suitable for browser pages but not for APIs, webhooks, mobile apps, or requests that expect JSON, a file, or an image.

  • Use the DDoS status condition when a rule must strengthen protection only during an attack.

  • Before configuring rate limits, use the charts in Request logs to assess the volume of traffic that matches the rule conditions. Consider normal request rates and peak values so that the limit does not affect legitimate traffic.

Configuration

Open Enforcement

Go to Application protection → Resources. For the resource where you want to configure a rule, click the ellipsis (…) and select Custom rules. The page that opens contains the Enforcement tab.

Create an enforcement rule

  1. Click + Create enforcement rule. The rule creation window opens. Complete the remaining steps there.

    If the system asks you to select a rule type, choose Enforcement rule. This article describes how to configure this type of rule.

    An API shielding rule is a separate feature that protects API endpoints from direct requests that bypass the website. For details, see API shielding rule.

    By default, you can create up to 20 enforcement rules. If you need more, contact support to increase the limit.

  2. Specify the Position and Description.

    Position determines the rule’s place in the queue. Numbering starts at zero.

    By default, a new rule is added to the bottom of the list and receives the next available position. You can edit this field and enter a different number.

    Description is a text comment. In practice, it is a name that you give the rule for your own reference. It makes the rule easier to find in the list.

    Examples of useful descriptions: Allow Partner X API, Brute-force login protection.

    Configure the position and description
  3. Configure the Conditions.

    You can configure three types of conditions: traffic, rate limiting, and DDoS status. The rule applies to requests that meet all specified conditions at the same time.

    Example: you configure the traffic conditions Country—Germany and URL path starts with /login, and the rate limiting condition After limits exceeded: 100 requests per minute per IP. The rule then:

    • Applies to users from Germany who have already sent more than 100 requests to the login page in one minute. All conditions are met.

    • Does not apply to users from Germany who have sent fewer than 100 requests to the login page in one minute. The per-IP rate limit condition is not met.

    • Does not apply when a request to the login page comes from China. The Country—Germany condition is not met.

    • Does not apply when a request comes from Germany but targets the website home page. The URL path starts with /login condition is not met.

    • Traffic

    • Rate limiting

    • DDoS status

    Example traffic settings

    To add a condition, click + Add condition, select a parameter—for example, Country, URL path, or Request method—select a comparison operator such as starts with, and specify a value such as /login.

    The tables below describe how to complete each parameter, their limits and examples, and the available operators. Click a heading to expand its description.

    Description of each parameter
    Parameter name Parameter description Value requirements Condition example

    Country

    The geographical location of the source IP address.

    Select a value from the drop-down list.

    Country in Germany

    Query string

    Parameters specified in the URL after the ? character.

    • You can add up to 100 values to one condition (use the + Or button).

    • You can specify only a key or a key-value pair.

    • The string length must be from 1 to 200 characters.

    • Do not start the string with a space, /, or ?.

    • Use only characters allowed in URLs.

    • Specify special characters in percent-encoding format. For example, use %2F instead of /.

    Query string contains debug=true

    URL path

    The request URL path, the part of the URL after the domain and before the ? character.

    • Always start the string with /.

    • Do not specify a domain name, for example site.com.

    • Do not specify a protocol, for example https://.

    • Do not add parameters after the ? character.

    • Use only characters allowed in URLs.

    URL path starts with /admin

    URL path segment

    Any part of a URL path between / characters.

    • You can add up to 100 values to one condition (use the + Or button).

    • The value length is from 1 to 200 characters.

    • You can specify a section name, such as api, or a file extension, such as .php.

    • Do not use the / character.

    URL path segment contains backup

    Content-Type

    The format of the data sent in the request, such as JSON, plain text, images, or web form data.

    • You can add up to 100 values to one condition (use the + Or button).

    • The value length must be from 1 to 200 characters.

    • Do not start the string with a space.

    • Specify the full type or part of it.

    Content-Type equals application/json

    Cookie_any (or)

    Cookie names and values. The rule applies when the request contains at least one specified name-value pair.

    • You can add up to 100 name-value pairs to one condition (use the + Or button).

    • The name length must not exceed 200 characters.

    • The value length must not exceed 4,096 characters.

    Name equals user_type

    Value starts with premium

    OR

    Name equals partner_id

    Value equals any

    Cookie_all (and)

    Cookie names and values. The rule applies when the request contains the entire set of specified name-value pairs at the same time.

    • You can add up to 100 name-value pairs to one condition (use the + And button).

    • The name length must not exceed 200 characters.

    • The value length must not exceed 4,096 characters.

    Name equals promo_code

    Value equals active

    AND

    Name equals is_subscriber

    Value equals yes

    Header

    Names and values of HTTP headers.

    Parameter details
    • Different headers use AND logic: the request must contain all specified name-value pairs.

    • Multiple values for the same header use OR logic: it is enough for one of them to match.

    • These conditions work together: different headers use AND logic, while multiple values of one header use OR logic.

    Example. You specify the headers X-Env: prod, X-Region: eu, and X-Region: us. If the request contains:

    • X-Env: prod and X-Region: eu, the rule applies;

    • X-Env: prod and X-Region: us, the rule applies;

    • only X-Env: prod, the rule does not apply;

    • only X-Region: eu, the rule does not apply.

    • You can add up to 100 name-value pairs to one condition (use the + Or button).

    • The name length must not exceed 200 characters.

    • The value length must not exceed 200 characters.

    Name equals X-App-Version

    Value starts with 2.0

    Host

    The value of the Host header: the domain name of the server that the client requests.

    • You can add up to 100 values to one condition (use the + Or button).

    • The value length must not exceed 200 characters.

    • Do not start the string with a space.

    • Specify the full domain or part of it.

    • Do not specify a protocol, for example https://.

    • Do not specify a path, for example /main.

    Host equals api.site.com

    Hosting subnet

    Traffic from IP addresses that belong to hosting providers or data centers.

    Not set.

    —

    Request method

    The type of HTTP method used.

    Select one or more methods from the drop-down list.

    Request method in POST

    Referer

    The value of the Referer header: the address of the page from which the user came to your resource.

    • You can add up to 100 values to one condition (use the + Or button).

    • The value length must not exceed 200 characters.

    • Specify the full URL, a domain, or part of it.

    • Do not start the string with a space.

    • Use only characters allowed in URLs.

    Referer starts with google.com

    ASN

    The autonomous system number (ASN) to which the source IP address belongs.

    • Use a number with the AS prefix, for example AS13335 or as13335.

    • The number must contain from 1 to 10 digits.

    • You can specify up to 100 unique numbers in one field.

    • The same number cannot be specified in both the in and not in lists.

    ASN in AS15169

    Hashes

    A unique device fingerprint (hash), with one of three available accuracy levels: Strictera hash (loose), Strictera hash (medium), or Strictera hash (strict).

    • You can add up to 100 values to one condition (use the + Or button).

    • The value must be a positive number from 1 to 200 characters long.

    Strictera hash (strict) in 1234567890

    Request from a new user

    Traffic from users who visit the resource for the first time and whose device fingerprint (hash) has not yet been recorded in our database.

    Not set.

    —

    Source subnets

    The sender’s IP address or subnet.

    • You can add up to 200 values to one condition (use the + Or button).

    • Specify individual IP addresses or their ranges (subnets).

    • You can specify IPv4 addresses, for example 192.168.1.1, and IPv6 addresses, for example 2001:db8::1.

    • To specify ranges, use CIDR notation with a slash, for example /24 for a whole network or /32 for one address.

    Source subnets in 192.168.1.0/24 or 2001:db8::1

    User-Agent

    The value of the User-Agent header: an identifier of the browser, device, or software client that sends the request.

    • You can add up to 100 values to one condition (use the + Or button).

    • The value length must not exceed 200 characters.

    • Do not start the string with a space.

    • Use the required letter case, for example Chrome and chrome are different values.

    User-Agent equals BadBot/1.0

    X-Forwarded-For

    The value of the X-Forwarded-For header: the chain of proxy server IP addresses through which the request passed before reaching your resource.

    • You can add up to 100 values to one condition (use the + Or button).

    • The value length must not exceed 200 characters.

    • Do not start the string with a space.

    • Specify individual IP addresses or their ranges.

    X-Forwarded-For contains 203.0.113.10

    Tor (The Onion Router)

    Traffic from the Tor network, which hides the source’s real IP address.

    Not set.

    —

    Description of operators
    The available operators depend on the selected parameter.
    Operator When the rule applies

    equals

    When the value matches exactly.

    Example: you specify URL path equals /login. The rule applies to a request for /login but not to a request for any other path, including a nested path such as /login/reset.

    does not equal

    When the value does not match the specified value.

    Example: you specify Host does not equal api.example.com. The rule applies to requests for other hosts, such as example.com, www.example.com, or admin.example.com. It does not apply to requests for api.example.com.

    contains

    When the value contains the specified character sequence.

    Example: you specify Query string contains debug=true. The rule applies only to requests whose parameters include debug=true, for example ?id=10&debug=true. The sequence must match exactly. If the parameters contain something similar but not identical, such as degub=true or debug=treu, the rule does not apply.

    does not contain

    When the value does not contain the specified character sequence.

    Example: you specify Content-Type does not contain json. The rule applies to a request with any header value that does not include json, such as text/plain, application/xml, multipart/form-data, and others. It does not apply to application/json, application/ld+json, or similar values.

    starts with

    When the value starts with the specified character sequence.

    Example: you specify URL path starts with /admin. The rule applies to requests for /admin and all nested paths: /admin/users, /admin/access, and others.

    does not start with

    When the value does not start with the specified character sequence.

    Example: you specify Host does not start with api. The rule applies to requests for hosts such as example.com, www.example.com, and admin.example.com, whose names do not start with api. It does not apply to api.example.com or api-test.example.com.

    ends with

    When the value ends with the specified character sequence.

    Example: you specify URL path segment ends with .php. The rule applies to values login.php, index.php, and profile.php. It does not apply to login.html, index.js, or php-login: the specified sequence must be at the end of the value.

    does not end with

    When the value does not end with the specified character sequence.

    Example: you specify X-Forwarded-For does not end with 10. The rule applies to requests where the header value ends with other characters, such as 192.0.2.15 or 198.51.100.25. It does not apply to values 192.0.2.10, 203.0.113.10, or other values ending in 10.

    in

    When the value belongs to the specified list.

    Example: you specify Request method in GET, POST. The rule applies to requests with one of these methods. It does not apply to requests using PUT, DELETE, PATCH, or other methods that are not in the list.

    not in

    When the value does not belong to the specified list.

    Example: you specify Country not in Germany, France. The rule applies to requests from all countries except Germany and France.

    empty

    When the parameter has no value.

    Example: you specify Content-Type empty. The rule applies to requests where the Content-Type header is not passed. If the header is present and contains any value, such as application/json or text/plain, the rule does not apply.

    not empty

    When the parameter has a value.

    Example: you specify Content-Type not empty. The rule applies to requests where the Content-Type header contains any value, such as application/json or text/plain. If the header is not passed, the rule does not apply.

    any

    With any parameter value.

    Example: you specify Cookie_all (and): Name—session, Value—any. The rule applies when the request contains a session cookie with any value. If the request has no cookie with this name, the rule does not apply.

    Example rate limiting settings

    A rate limit is a threshold for the number of incoming requests within a specified period, for example, one minute. It lets you limit when the rule applies.

    Without a rate limit, the rule applies to all requests that meet the specified conditions on the Traffic tab. With a rate limit, protection counts the number of those requests and applies the rule either before or after the limit is reached—you choose which.

    To configure a rate limit, specify the following parameters:

    • The rate limit type. You can configure both types:

      • Global—protection totals all requests that meet your traffic conditions. The rule applies to any such requests, regardless of IP address.

      • Per-IP—protection counts requests that meet your conditions separately for each IP address. The rule applies only to IP addresses for which the limit is exceeded.

    • Requests—the number of requests that protection must record. The maximum value is 5,000.

    • Period—the time window in which these requests are counted, from one second to 10 minutes.

    • The rule application mode: before or after the limit is reached.

    • After limits exceeded

    • Before limits reached

    The rule does not apply until the limit is reached. Once it is reached, the rule starts applying to all subsequent requests.

    Why use it: to create blocking rules. You do not affect regular users while their activity is within the normal range. But as soon as there are too many requests, you enable protection measures, such as requiring a CAPTCHA.

    Example: you configure the conditions Country—not Germany and Hosting subnet, a rate limit of 100 requests per minute, and the CAPTCHA action.

    • Your rule does not respond to the first 100 requests.

    • Starting with the 101st request, protection displays a CAPTCHA to everyone who comes from hosting providers in other countries.

    The rule applies until the limit is reached. Once it is reached, the rule stops applying, and subsequent requests are checked by other rules.

    Why use it: as a safeguard when configuring allow rules. You give a trusted source unrestricted access to the resource but set a rate limit as a precaution. As a result, even if an attacker manages to imitate trusted traffic—for example, by stealing a secret HTTP header—they cannot send more requests than you allow.

    Example: you configure the conditions Country—Germany and User-Agent contains MyBusinessBot/1.0, set a limit of 100 requests per minute, and configure the Pass action. Then:

    • The first 100 such requests pass through to the resource without restrictions.

    • Starting with the 101st request, the rule stops applying. New requests with Country—Germany and User-Agent contains MyBusinessBot/1.0 are checked by the next rules in the list.

    Do not use the Block action in Before limits reached mode. Otherwise, the rate limit stops working: blocked requests are not included in the counter, so all traffic that meets the rule conditions is blocked continuously.

    This is because this mode is designed for passing traffic or returning challenges, not for blocking it.

    DDoS status settings

    Choose when the rule must apply:

    • Always—the rule is active at all times.

    • While no attack—the rule applies while there is no DDoS attack. As soon as an attack starts, the rule stops applying.

    • During DDoS attack—the rule applies while an attack is in progress. When the attack ends, the rule stops applying.

  4. Select the Actions.

    Configure actions

    Specify what protection must do with a request that meets the rule conditions. You can either block all traffic or configure an action for each source class.

    • Block all traffic

    • Actions by source class

    Use the Block all (include mobile app) option to block all traffic that matches the rule.

    By default, protection passes requests from your mobile app without checks. The Block all setting overrides this automatic pass-through, so all traffic that matches the rule is blocked.

    Why use it: to stop attackers who have learned to imitate requests from your mobile app and are trying to bypass protection.

    Configure a separate action for each source class. For example, you can pass humans through to the resource and return a CAPTCHA to bots.

    This setting does not affect requests from mobile apps. Protection continues to pass them automatically.

    There are four source classes:

    • Bot—the request was definitely sent by a bot.

    • Likely bot—the request was probably sent by a bot, but protection is not 100% certain.

    • Likely human—the request was probably sent by a human, but protection is not 100% certain.

    • Human—the request was definitely sent by a human.

    Set the required action for each class:

    • Default—the rule does not make a decision for this class. The request is analyzed by the individual protection profile.

    • Pass—allow the request without additional checks.

    • Block—block the request immediately.

    • JavaScript challenge—return a JavaScript check.

    • Cookie challenge—check whether the client supports cookies.

    • CAPTCHA—return a CAPTCHA to verify that the request was sent by a human.

    If you use the Module or Hybrid integration option and want to configure CAPTCHAs, do the following before creating the rule:

    1. Contact support to enable CAPTCHAs for your resource.

    2. Wait until the necessary changes are made to the protection configuration.

    3. Configure CAPTCHAs in the enforcement rule.

    If you skip these steps, protection blocks requests instead of returning a CAPTCHA.

  5. Click Create.

    The rule appears in the list on the Enforcement tab. To activate the rule, turn on the switch in the Enabled column. It must turn white.

    Switch for enabling and disabling a rule

Configuration examples

The examples below show how to configure an enforcement rule. Click a heading to expand its description.

Example 1. Brute-force login protection

Task: limit login attempts from one IP address to five per minute.

Configuration:

  1. Rule description: Brute-force login protection.

  2. Traffic conditions:

    • Parameter: URL path, operator: equals, value: /login.

    • Parameter: Request method, operator: equals, value: POST.

  3. Rate limiting:

    • Enable the Per-IP switch.

    • Requests: 5.

    • Period: 1 minute.

  4. Actions:

    • Bot: Block.

    • Likely bot: Block.

    • Likely human: CAPTCHA.

    • Human: CAPTCHA.

Example 2. Challenge suspicious traffic during an attack

Task: strengthen checks for requests to the catalog during a DDoS attack.

Configuration:

  1. Rule description: Additional DDoS protection.

  2. Traffic conditions:

    • Parameter: URL path, operator: starts with, value: /catalogue/.

  3. DDoS status: During DDoS attack.

  4. Actions:

    • Bot: JavaScript challenge.

    • Likely bot: JavaScript challenge.

    • Likely human: JavaScript challenge.

    • Human: Pass.

Example 3. Allow access to a partner API

Task: allow all requests to /api/partner/ from the 1.2.3.4 IP address.

Configuration:

  1. Rule description: Allow Partner X API.

  2. Traffic conditions:

    • Parameter: URL path, operator: starts with, value: /api/partner/.

    • Parameter: Source subnets, operator: in, value: 1.2.3.4/32.

  3. Do not configure rate limits.

  4. Actions:

    • Bot: Pass.

    • Likely bot: Pass.

    • Likely human: Pass.

    • Human: Pass.

Place the Allow access to a partner API rule at the top of the list so that it is evaluated before any blocking rules.

Verify operation

You can check how a rule is applied in the Request logs tab of the management console.

The logs show:

  • Request parameters.

  • The protection action, such as passing or blocking.

  • The reason for the action. If a request matched a rule, this field contains the rule ID.

  • The source class assigned to the request source: Human, Likely human, Likely bot, or Bot.

Example log

If you notice that legitimate traffic is affected after you enable a rule, change its settings or contact support.

Management

On the Enforcement tab, you can manage rules directly in the list:

  • Move: rules in the list are evaluated from top to bottom. Use the six-dot icon (⠿) to drag a row to the required position.

  • View details: use the > icon to view all configured conditions and actions without entering edit mode.

  • Enable or disable: use the switch in the Enabled column. White means the rule is active and participates in filtering; gray means it is inactive.

  • View statistics: click the chart icon to see how many times the rule was applied during the selected period, such as the last 15 minutes or a day. The page shows the number of requests that matched the rule conditions and the actions applied to them.

  • Edit: click the ellipsis (…) at the end of the row and select Edit. You can change any rule parameter there.

  • Delete: click the ellipsis (…), select Delete, and confirm the action. A deleted rule cannot be restored.

  • Create rule above: click the ellipsis (…) and select Create rule above to quickly add a new rule above the current one. The new rule has a higher priority.

  • Create rule below: click the ellipsis (…) and select Create rule below to add a new rule below the current one. The new rule has a lower priority.

Actions for rules