Configuring a Traffic Identifier for a Known Attack Source
WAF traffic identifiers are designed to extract unique identifying information from client request bodies. This capability is fundamental to blocking known attack sources, as it provides the essential basis for locating malicious request origins, distinguishing between legitimate and malicious request bodies, and determining which targets to block.
- IP tag: WAF extracts the real client IP address from the HTTP request header (for example, X-Forwarded-For). If no custom IP tag is configured, WAF reads the client IP address by default. This enables WAF to identify the actual server that initiates each request and block those that send malicious requests.
- Session tag: This tag enables WAF to extract the session ID (for example, JSESSIONID) from the request cookie. This tag is used to identify the browser session that initiates the request. The session ID must match the service cookie field. This tag serves as the basis for cookie–based blocking.
- User tag: This tag enables WAF to extract the service user ID from request parameters (such as uid and username). This tag is used to identify the service account that initiates the request. The user ID must match the service API parameter. This tag serves as the basis for Params–based blocking.
- Header tag: This tag enables WAF to extract information from a specified custom HTTP request header field. It is intended for use in scenarios where standard IP, session, and user tags are not enough to identify requests. The tag must match the configured custom header field. This tag serves as the basis for header-based blocking.
The more precise the traffic tag configuration, the more accurately malicious entities can be blocked, preventing false positives and false negatives.
Principles
- Request interception: Client requests are first intercepted by the Huawei Cloud WAF engine to prevent malicious requests from reaching backend servers.
- Tag extraction: WAF extracts information from HTTP request headers, cookies, and request parameters based on the configured IP tag, session tag, user tag, and header tag.
- Attack identification: WAF counts the number of malicious requests with the same tag within a specified period based on a known attack source rule you configure. If the number reaches the threshold configured in the rule, requests with the tag are identified as a malicious entity.
- Punishment execution: WAF takes actions against the malicious entity identified by the tag. The punishment only applies to the entity corresponding to the tag (for example, blocking malicious IP addresses, restricting abnormal sessions, disabling access from accounts that violate rules, and blocking requests with specific request headers). This does not affect the normal access of other legitimate entities.
If no traffic identifier is configured, WAF will be unable to block known attack sources using specific tags. WAF can only provide basic protection based on default rules. This reduces protection accuracy.
Typical Application Scenarios
- E-commerce and application backend APIs: This feature helps defend against batch scanning from a single IP address, brute-force attacks, and high-frequency malicious requests from a single user.
- Backend management systems: This feature helps restrict abnormal sessions and unauthorized IP address access to keep the management portal secure.
- Websites using CDN/ELB proxies: This feature helps accurately obtain the real IP addresses of clients to prevent legitimate requests from being mistakenly blocked or malicious requests from being allowed.
- Multi-user service platforms: This feature helps block malicious behaviors (such as malicious registration and order placement) from specific accounts.
- Custom protection scenarios: This feature helps block attacks based on custom fields (such as device IDs, API keys, and channel IDs) in HTTP request headers. For example, it can be used to block malicious requests from specific devices or channels.
Constraints
- If the IP address tag is configured, ensure that the protected website has a layer-7 proxy configured in front of WAF and that Use Layer-7 Proxy is set to Yes for the protected website.
If the IP address tag is not configured, WAF identifies the client IP address by default.
- Before enabling cookie-, header-, or params-based known attack source rules, a session, header, or user tag must be configured for the corresponding website domain name.
Configuring a Traffic Identifier for a Known Attack Source
You can configure a traffic identifier for a known attack source by referring to Procedure, Configuration Suggestions and Verification Methods.
Procedure
- Log in to the WAF console.
- Click
in the upper left corner and select a region or project. - (Optional) If you have enabled the enterprise project function, in the upper part of the navigation pane on the left, select your enterprise project from the Filter by enterprise project drop-down list. Then, WAF will display the related security data in the enterprise project on the page.
- In the navigation pane on the left, choose .
- On the Protected Objects page, click the target domain name.
- In the Traffic Identifier area, click
next to IP Tag, Session Tag, Header Tag, or User Tag and configure a traffic identifier by referring to Table 1. Table 1 Traffic identifier parameters Tag
Description
Example Value
IP Tag
HTTP request header field of the original client IP address. After this parameter is configured, WAF extracts the real IP address of the client from the HTTP request header (for example, X-Forwarded-For). If this parameter is not configured, WAF reads the client IP address by default.
When a website is connected to WAF, the IP tag you configured is synchronized to the IP tag of the traffic identifier. You can modify the following settings:- $remote_sockaddr: If there is no other proxy in front of WAF, the packet contains the TCP Option Address (TOA), and you do not want WAF to use the TOA as the client IP address, select this option. With this tag configured, WAF uses the Layer 3 source IP address of the packet as the real client IP address.
- $remote_addr: If there is a layer-4 proxy in front of WAF, WAF uses the TCP connection IP address as the real client IP address.
- x-forwarded-for: If there is a layer-7 proxy in front of WAF, WAF uses the first IP address in the X-Forwarded-For (XFF) header as the real client IP address.
- Custom: If there is a layer-7 proxy in front of WAF, WAF preferentially obtains the real client IP address from the configured field. If multiple fields are configured, WAF reads the real client IP address from left to right.
If WAF does not obtain the real client IP address from the custom field, it reads the CDN-Src-Ip, X-Real-Ip, X-Forwarded-For, and $remote_addr fields in sequence to obtain the real client IP address.
This field is used to store the real IP address of the client. You can customize the field name and configure multiple fields (separated by commas). After the configuration, WAF preferentially reads the configured field to obtain the real IP address of the client. If multiple fields are configured, WAF reads the IP address from left to right.- If you want to use a TCP connection IP address as the client IP address, set IP Tag to $remote_addr.
- If the TCP Option Address (TOA) kernel module is configured for packets, but you do not want to identify TOA as the client IP address, set the IP address identifier to $remote_sockaddr and upgrade the dedicated engine version to the one later than May 2024. After doing this, layer-3 source IP addresses of packets will be identified as client IP addresses.
- If WAF does not obtain the real IP address of a client from fields you configure, WAF reads the cdn-src-ip, x-real-ip, x-forwarded-for, and $remote_addr fields in sequence to read the client IP address.
x-forwarded-for
Session Tag
This tag is used in a known attack source rule that blocks malicious requests based on cookie attributes. This tag is mandatory to block requests based on the cookie attributes.
Only digits, letters, hyphens (-), underscores (_), and periods (.) are allowed.
sessiontest
User Tag
This tag is used in a known attack source rule that blocks malicious requests based on params attributes. This tag is mandatory to block requests based on the Params attributes.
Only digits, letters, hyphens (-), underscores (_), and periods (.) are allowed.
Params
Header Tag
This tag is used in a known attack source rule that blocks malicious requests based on header attributes. This tag is mandatory to block requests based on the Header attributes.
Only digits, letters, hyphens (-), underscores (_), and periods (.) are allowed.
Referer
- Click OK.
Configuration Suggestions
The more precisely the traffic tags are configured, the more accurately malicious access entities can be blocked, thereby reducing both false positives and false negatives. You can select a traffic tag combination based on your service scenario by referring to the following table.
| Scenario | Core Requirement | Configuration Solution |
|---|---|---|
| E-commerce and application backend APIs (with login status) | Block batch attacks from a single IP address and malicious operations (such as malicious order placement and comments) from a single account. | IP tag + User tag
|
| Backend management system (without CDN, with session verification) | Restrict access from abnormal IP addresses and prevent frequent login attempts from a single browser. | IP tag + Session tag
|
| Public APIs without login status (such as static APIs on the official website) | Defend against batch scanning and CC attacks from a single IP address. | IP tag only
|
| Websites that pass through multiple layers of CDN and/or ELB | Accurately obtain real client IP addresses to prevent CDN node IP addresses from being blocked mistakenly. | Custom IP tag field. The real IP address transferred by the outermost proxy is read first.
|
| Custom request header protection scenarios (such as device binding and channel control) | Protect against malicious requests from specific devices or unauthorized channels, such as forged device identifiers and unauthorized channel access. | IP tag + Header tag
|
Verification Methods
To verify the configuration, search for access logs for the target domain name within a specific time range and see whether corresponding information is displayed.
You can also configure a known attack rule for the corresponding tag type by referring to Configuring a Known Attack Source Rule. Then simulate malicious requests (such as high-frequency access from a single IP address, multiple malicious parameter submissions in a single session, and malicious requests carrying specific header fields). If the attacks are blocked, the tag configuration has taken effect.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot
