Help Center/ Web Application Firewall/ User Guide/ Configuring Protection Policies/ Configuring CC Attack Protection Rules to Defend Against CC Attacks
Updated on 2024-11-19 GMT+08:00

Configuring CC Attack Protection Rules to Defend Against CC Attacks

CC attack protection can limit the access to a protected website based on a single IP address, cookie, or referer. Beyond that, CC attack protection can also limit access rate based on policies, domain names, and URLs to precisely mitigate CC attacks. In policy-based rate limiting, the number of requests for all domain names in the same policy are counted for triggering the rule. In domain-based rate limiting, the total number of requests for each domain name is counted separately for triggering the rule. In URL-based rate limiting, the number of requests for each URL is counted separately for triggering the rule. To use this protection, ensure that you have toggled on CC Attack Protection ().

A reference table can be added to a CC attack protection rule. The reference table takes effect for all protected domain names.

If you have enabled enterprise projects, ensure that you have all operation permissions for the project where your WAF instance locates. Then, you can select the project from the Enterprise Project drop-down list and configure protection policies for the domain names in the project.

Prerequisites

Constraints

  • Managing reference tables is not included in the standard edition cloud WAF.
  • If you set Logic to Include any value, Exclude any value, Equal to any value, Not equal to any value, Prefix is any value, Prefix is not any of them, Suffix is any value, or Suffix is not any of them, select an existing reference table. For details, see Creating a Reference Table to Configure Protection Metrics in Batches.
  • Only the cloud CNAME access mode supports counting requests to All WAF instances.
  • If you are using a cloud WAF edition and your website uses proxies such as anti-DDoS, Content Delivery Network (CDN), and cloud acceleration services, select Source for Rate Limit Mode and then Per user and enable All WAF instances.

    If a website has used other proxy services, such as CDN and advanced anti-DDoS in front of WAF, the access requests to WAF will be distributed to each WAF instance for traffic forwarding. By default, WAF counts requests on each WAF instance separately. To set a proper rate limit frequency, follow the following principles:

    • Cloud mode - CNAME access: This mode supports counting requests to All WAF instances. That means WAF aggregates requests to all WAF nodes for rate limiting. You can just enable this function during configuration.
    • Dedicated mode: This mode does not support global counting for all WAF instances. The Rate Limit can be set to the maximum access requests allowed for a visit divided by the number of proxies in front of WAF or the number of WAF instances, whichever is smaller.

      Assume that you use three proxy services in front of WAF and use two dedicated WAF instances to protect your website. The smaller value is 2. If you want to limit the requests of a visitor within 1,000 times in a rate limiting period, you can set Rate Limit to 500, which is 1,000 divided by 2.

  • The Response Code, Response Length, Response Time, Response Header, and Response Body fields are not supported by the Cloud Mode - Load balancer access mode. Only the platinum edition WAF using the Cloud Mode - CNAME access mode supports response fields.
  • It takes several minutes for a new rule to take effect. After the rule takes effect, protection events triggered by the rule will be displayed on the Events page.

Configuring a CC Attack Protection Rule

  1. Log in to the management console.
  2. Click in the upper left corner of the management console and select a region or project.
  3. Click in the upper left corner and choose Web Application Firewall under Security & Compliance.
  4. In the navigation pane on the left, choose Policies.
  5. Click the name of the target policy to go to the protection configuration page.
  6. Click the CC Attack Protection configuration area and toggle it on or off if needed.

    • : enabled.
    • : disabled.

  7. In the upper left corner above the CC Attack Protection rule list, click Add Rule.
  8. In the displayed dialog box, configure a CC attack protection rule by referring to Table 1.

    For example, you can configure a CC attack protection rule to block requests from a visit for 600 seconds by identifying their cookie (name field) if the visitor accessed a URL (for example, /admin*) of your website over 10 times within 60 seconds.

    Figure 1 Adding a CC attack protection rule
    Table 1 Rule parameters

    Parameter

    Description

    Example Value

    Rule Name

    Name of the rule

    waftest

    Rule Description

    A brief description of the rule. This parameter is optional.

    --

    Rate Limit Mode

    • Source: Requests from a specific source are limited. For example, if traffic from an IP address (or user) exceeds the rate limit you configure in this rule, WAF limits traffic rate of the IP address (or user) in the way you configure.
      • Per IP address: A website visitor is identified by the IP address.
      • Per user: A website visitor is identified by the key value of Cookie or Header.
      • Other: A website visitor is identified by the Referer field (user-defined request source).
      NOTE:

      If you set Rate Limit Mode to Other, set Content of Referer to a complete URL containing the domain name. The Content field supports prefix match and exact match only, but cannot contain two or more consecutive slashes, for example, ///admin. If you enter ///admin, WAF will convert it to /admin.

      For example, if you do not want visitors to access www.test.com, set Referer to http://www.test.com.

    • Destination: If this parameter is selected, the following rate limit types are available:
      • By rule: If this rule is used by multiple domain names, requests for all these domain names are counted for this rule no matter what IP addresses these requests originate from. If you have added a wildcard domain name to WAF, requests for all domain names matched the wildcard domain name are counted for triggering this rule no matter what IP addresses these requests originate from.
      • By domain name: Requests for each domain name are counted separately. If the number exceeds the threshold you configure, the protective action is triggered no matter what IP addresses these requests originate from.
      • By URL: Requests for each URL are counted separately. If the number exceeds the threshold you configure, the protective action is triggered no matter what IP addresses these requests originate from.

    --

    User Identifier

    This parameter is mandatory when you select Source and Per user for Rate Limit Mode.

    • Cookie: A cookie field name. You need to configure an attribute variable name in the cookie that can uniquely identify a web visitor based on your website requirements. This field does not support regular expressions. Only complete matches are supported.

      For example, if a website uses the name field in the cookie to uniquely identify a web visitor, enter name.

    • Header: Set the user-defined HTTP header you want to protect. You need to configure the HTTP header that can identify web visitors based on your website requirements.

    name

    Request Aggregation

    This parameter is not required when you select Destination and By rule for Rate Limit Mode.

    This function is disabled by default. Keep this function enabled so that requests to all domain names that match a protected wildcard domain are counted for triggering this rule. For example, if you added *.a.com to WAF, requests to all matched domain names such as b.a.com and c.a.com are counted.

    --

    Trigger

    Click Add Conditions and add conditions. At least one condition is required, but up to 30 conditions are allowed. If you add more than one condition, the rule will only take effect when all conditions are met.

    • Field
    • Subfield: Configure this field only when IPv4, IPv6, Cookie, Header, or Params is selected for Field.
      NOTICE:

      A subfield cannot exceed 2,048 bytes.

    • Logic: Select a logical relationship from the drop-down list.
      NOTE:

      If you set Logic to Include any value, Exclude any value, Equal to any value, Not equal to any value, Prefix is any value, Prefix is not any of them, Suffix is any value, or Suffix is not any of them, select an existing reference table. For details, see Creating a Reference Table to Configure Protection Metrics in Batches.

    • Content: Enter or select the content that matches the condition.

    Path Include /admin

    Rate Limit

    The number of requests allowed from a website visitor in the rate limit period. If the number of requests exceeds the rate limit, WAF takes the action you configure for Protective Action.

    All WAF instances: Requests to on one or more WAF instances will be counted together according to the rate limit mode you select. By default, requests to each WAF instance are counted. If you enable this, WAF will count requests to all your WAF instances for triggering this rule. To enable user-based rate limiting, Per user or Other (Referer must be configured) instead of Per IP address must be selected for Rate Limit Mode. This is because IP address-based rate limiting cannot limit the access rate of a specific user. However, in user-based rate limiting, requests may be forwarded to one or more WAF instances. Therefore, All WAF instances must be enabled for triggering the rule precisely.

    NOTE:

    If a website has used other proxy services, such as CDN and advanced anti-DDoS in front of WAF, the access requests to WAF will be distributed to each WAF instance for traffic forwarding. By default, WAF counts requests on each WAF instance separately. To set a proper rate limit frequency, follow the following principles:

    • Cloud mode - CNAME access: This mode supports counting requests to All WAF instances. That means WAF aggregates requests to all WAF nodes for rate limiting. You can just enable this function during configuration.
    • Dedicated mode: This mode does not support global counting for all WAF instances. The Rate Limit can be set to the maximum access requests allowed for a visit divided by the number of proxies in front of WAF or the number of WAF instances, whichever is smaller.

      Assume that you use three proxy services in front of WAF and use two dedicated WAF instances to protect your website. The smaller value is 2. If you want to limit the requests of a visitor within 1,000 times in a rate limiting period, you can set Rate Limit to 500, which is 1,000 divided by 2.

    10 requests allowed in 60 seconds

    Protective Action

    The action that WAF will take if the number of requests exceeds Rate Limit you configured. The options are as follows:

    • Verification code: WAF allows requests that trigger the rule as long as your website visitors complete the required verification.
    • Block: WAF blocks requests that trigger the rule.
    • Block dynamically: WAF blocks requests that trigger the rule based on Allowable Frequency, which you configure after the first rate limit period is over.
    • Log only: WAF only logs requests that trigger the rule.
    • JS Challenge: WAF returns a piece of JavaScript code that can be automatically executed by a normal browser to the client. If the client properly executes the JavaScript code, WAF allows all requests from the client within a period of time (30 minutes by default). During this period, no verification is required. If the client fails to execute the code, WAF blocks the requests.

    Block

    Application Schedule

    • Immediate: The rule works immediately after it is enabled.
    • Custom: You can select a time range for the rule to work.

    Immediate

    Allowable Frequency

    This parameter can be set if you select Block dynamically for Protective Action.

    WAF blocks requests that trigger the rule based on Rate Limit first. Then, in the following rate limit period, WAF blocks requests that trigger the rule based on Allowable Frequency you configure.

    Allowable Frequency cannot be larger than Rate Limit.

    NOTE:

    If you set Allowable Frequency to 0, WAF blocks all requests that trigger the rule in the next rate limit period.

    8 requests allowed in 60 seconds

    Block Duration

    Period of time for which to block the item when you set Protective Action to Block.

    600 seconds

    Block Page

    The page displayed if the request limit has been reached. This parameter is configured only when Protective Action is set to Block.

    • If you select Default settings, the default block page is displayed.
    • If you select Custom, a custom error message is displayed.

    Custom

    Block Page Type

    If you select Custom for Block Page, select a type of the block page among options application/json, text/html, and text/xml.

    text/html

    Page Content

    If you select Custom for Block Page, configure the content to be returned.

    Page content styles corresponding to different page types are as follows:

    • text/html: <html><body>Forbidden</body></html>
    • application/json: {"msg": "Forbidden"}
    • text/xml: <?xml version="1.0" encoding="utf-8"?><error> <msg>Forbidden</msg></error>

  9. Click Confirm. You can then view the added CC attack protection rule in the CC rule list.

    • To disable a rule, click Disable in the Operation column of the rule. The default Rule Status is Enabled.
    • To modify a rule, click Modify in the row containing the rule.
    • To delete a rule, click Delete in the row containing the rule.

Protection Effect

If you have configured a CC attack protection rule like Figure 1 (with Protective Action set to Block) for your domain name www.example.com, take the following steps to verify the protection effect:

  1. Clear the browser cache and enter the domain name in the address bar to check whether the website is accessible.

    • If the website is inaccessible, connect the website domain name to WAF by referring to Website Settings.
    • If the website is accessible, go to 2.

  2. Clear the browser cache, enter http://www.example.com/admin in the address bar, and refresh the page 10 times within 60 seconds. In normal cases, the custom block page will be displayed the eleventh time you refresh the page, and the requested page will be accessible when you refresh the page 60 seconds later.

    If you select Verification code for protective action, a verification code is required for visitors to continue the access if they exceed the configured rate limit.

  3. Return to the WAF console. In the navigation pane, click Events. On the displayed page, view the event log.

Configuration Example - Verification Code

If domain name www.example.com has been connected to WAF, perform the following steps to verify that WAF CAPTCHA verification is enabled.

  1. Add a CC attack protection rule with Protection Action set to Verification code.

    Figure 2 Verification code

  2. Enable CC attack protection.

    Figure 3 Enabling CC Attack Protection

  3. Clear the browser cache and access http://www.example.com/admin/.

    If you access the page 10 times within 60 seconds, a verification code is required when you attempt to access the page for the eleventh time. You need to enter the verification code to continue the access.

  4. Go to the WAF console. In the navigation pane on the left, choose Events. View the event on the Events page.