After you add web services to Web Application Firewall (WAF) 3.0, you can configure engine settings and manage rule libraries to protect your web services from common web application attacks, such as SQL injection attacks, cross-site scripting (XSS) attacks, code executions, webshell uploads, and command injection attacks. This topic describes how to configure the core protection rule module.
On November 7, 2024 (UTC+8), the core protection rule module was upgraded. For more information, see Upgrade the basic protection rule module in WAF 3.0. This topic describes the new version of the core protection rule module. If you use the old version, you can configure the module by following the instructions provided in Configure protection rules and rule groups for the core protection rule module.
Module function overview
Each protection template of the core protection rule module uses an independent detection engine. Various protection rules are incorporated into different detection modules based on business experience. Different detection modules identify different types of attacks. The following figure shows the relationships among protection templates, detection engines, detection modules, and rules.
Public cloud protection scenario | Hybrid cloud protection scenario |
Features
Support for multiple decoding formats
The core protection rule module supports multiple decoding formats, including the following:
The module can parse data in various formats to improve detection accuracy. The data formats include JSON, XML, and Multipart.
The module can identify data that is encoded to bypass WAF. This improves the detection rate of attacks. The encoding formats include Unicode encoding and HTML entity encoding.
Support for intelligent whitelist engine
To reduce the risks of false positives, WAF performs AI learning based on historical service traffic and identifies rules that may not be suitable at the URL level, then automatically adds them to the whitelist.
Support for custom protection rules in hybrid cloud scenarios
Custom protection rules take effect only for protected objects that are generated when you add services to WAF in hybrid cloud mode. This type of protected object is referred to as hybrid cloud protected objects. For more information about how to create a custom protection rule and add the rule to a protection template, see Manage rule libraries.
Prerequisites
A WAF 3.0 instance is purchased. If you want to apply custom protection rules to hybrid cloud protected objects, you must purchase a subscription WAF instance that runs the Enterprise or Ultimate edition. For more information, see Purchase a WAF 3.0 subscription instance and Activate a pay-as-you-go WAF 3.0 instance.
Web services are added to WAF 3.0 as protected objects. For more information, see Configure protected objects and protected object groups.
Template type
The core protection rule module has the following two types of protection templates.
Protection template | Description | Effective objects |
Default protection template | The initial default protection template provided by WAF, which contains the core protection rule set of WAF. No configuration is required if there are no specific protection requirements. | When created, it is automatically applied to protected objects/groups that are not associated with custom protection templates. Newly added protected objects will also be automatically added to the default protection template. You can manually adjust this. |
Custom protection template | A protection template customized according to business needs. It needs to be manually created and is suitable for scenarios where a single default protection template cannot meet business requirements. | You need to set Apply to. The template only takes effect for protected objects and object groups that are associated with the protection template. |
Create a protection template
Log on to the WAF 3.0 console. In the top navigation bar, select the resource group and region of the WAF instance. You can select Chinese Mainland or Outside Chinese Mainland for the region. In the left-side navigation pane, choose , in the Core Protection Rule section, click Create Template.
In the Create Template - Core Protection Rule panel, complete the template configuration by following these steps, and then click OK.
Step 1: Configure Template Information
Parameter
Configuration field
Description
Template Information
Template Name
The name can contain letters, digits, periods (.), underscores (_), and hyphens (-).
Save as Default Template
The default protection template does not require setting effective objects. It is automatically applied to all protected objects and object groups that are not associated with custom protection templates (including those newly added or removed from custom protection templates). You can also manually remove them from the default template. You can specify only one default template for a protection module, and it can only be set when creating a template.
Step 2: Engine Configuration
Parameter
Configuration field
Description
Engine Configuration
Automatic Update Of Detection Engine
By default, the switch is turned on. In this case, rules that are added to or removed from the default rule library of the Alibaba Cloud security team are automatically synchronized to the current detection engine. If the switch is turned on, WAF automatically updates rules. The rules are enabled and uses the Monitor or Block action. If the switch is turned off, WAF still synchronizes rules. The rules are disabled and uses the Monitor action.
Configure Engine
System Protection Rules: WAF provides four levels of system protection rules based on the built-in detection modules of Alibaba Cloud Security. The rule levels are Super Strict, Strict, Medium, and Loose. By default, rules at the Super Strict and Strict levels are disabled, and rules at the Medium and Loose levels are enabled.
NoteFor more information about the supported detection modules, see Detection module descriptions.
You can configure the following parameters of a rule:
Action: Specify the action that you want WAF to perform on the requests that match the rule.
Block: blocks a request that matches the rule and returns a block page to the client that initiates the request.
NoteBy default, WAF returns a preconfigured block page. You can use the custom response feature to configure a custom block page.
Monitor: records a request that matches the rule in a log and does not block the request. You can query the logs of requests that match the rule and analyze the protection performance. For example, you can query logs to check whether normal requests are blocked.
ImportantYou can query logs only if the Simple Log Service for WAF feature is enabled.
If you select Monitor, you can perform a dry run on the rule to check whether the rule blocks normal requests. If the rule passes the dry run, you can set the Action parameter to Block.
NoteOn the Security Reports page, you can query the details of matched rules in Monitor or Block mode. For more information, see Security reports.
Status: Turn on or turn off the switch. If a rule is disabled, WAF does not match requests against the rule.
Adaptive Engine
Intelligent Whitelist Engine: By default, the switch is turned off.
Protection rules of the whitelist module that are automatically created are displayed in the AutoTemplate protection template in the Whitelist section. For more information, see View whitelist.
NoteOnly pay-as-you-go and subscription WAF instances of the Enterprise and Ultimate editions support this feature.
Step 3: Configure Effective Scope
Select the Protected Objects and Protected Object Groups to which you want to apply the template from the added protected objects and object groups.
You can apply only one core protection rule template to a protected object or object group. If you set a default protection template in Step 1, all protected objects and object groups that are not associated with custom protection templates are selected by default. If you do not set a default template, no protected objects or object groups are selected by default. You can manually modify the effective objects.
View protection templates
You can click the
icon to the left of the protection template name to view the engine information of the template. You can also click Configure Engine to open the engine configuration page and view the action and status information of the detailed rules.
Edit protection templates
Enable and disable a protection template
After you create a protection template, you can turn on or turn off the switch in the Status column to enable or disable the template.
Modify a protection template
You can click Edit in the Actions column of the target template. After you make the adjustments, click OK to save the changes.
For protection in hybrid cloud scenarios, you can configure the following parameters for a custom protection rule in the Configure Engine panel:
Action: Specify the action that you want WAF to perform on the requests that match the rule. Valid values: Monitor and Block.
Status: By default, the switch is turned off. You can turn on or turn off the switch. If you turn on the switch, the setting takes effect only on the protection template.
Delete a protection template
You can delete a protection template that you no longer require. Before you delete a protection template, make sure that the template is not associated with protected objects. To delete a protection template, find the template and click Delete in the Actions column. In the message that appears, click OK.
After a protection template is deleted, the system automatically applies the default template to the protected objects that were previously associated with the deleted protection template.
If you delete a default template and the template is associated with protected objects, the protected objects are no longer protected by the core protection rule module.
View hit records
On the Core Protection Rule tab of the Security Reports page, you can view the hit records of specific protection rules. For more information, see Security reports. The Core Web Protection page does not support searching for specific core protection rules by rule ID. To query specific rule information, see Manage rule libraries.
If you believe that a rule incorrectly blocks normal service traffic, you can configure a whitelist rule for that specific rule through the Whitelist module. For more information about how to configure whitelist rules, see Configure protection rules for the whitelist module to allow specific requests.
Related descriptions and references
Detection module descriptions
Detection modules can identify and block different types of web attacks based on the protection rules of the modules.
References
For more information about the protected objects, protection modules, and protection process of WAF 3.0, see Protection configuration overview.
For more information about how to create a protection template by calling an API operation, see CreateDefenseTemplate.
For more information about how to create a core protection rule by using OpenAPI, see CreateDefenseRule.