Rule Example 1 – Cross Site Scripting (XSS) Attack
- Last Updated: May 13, 2025
- 1 minute read
- LoadMaster
- LoadMaster GA
- Documentation
The following rule is used to avoid XSS attacks by checking for a <script> pattern in the request parameters and header and generates an ‘XSS Attack’ message with a 404 status response.
SecRule ARGS|REQUEST_HEADERS "@rx <script>" \
"id:101,\
deny,\
status:404,\
msg:'XSS Attack'"
Variables
Details about the variables in this rule example are in the table below:
|
Variable |
Definition |
|---|---|
|
Request parameters |
|
All of the request headers |
Operator
“@rx <script>” – Performs a regular expression match of the pattern (in this case <script>) provided as a parameter.
Actions
Details of the actions contained in this rule example are provided in the table below:
|
Action(s) |
Description |
|---|---|
|
These are all of the actions to be performed if the pattern is matched. |
|
The unique ID that is assigned to the rule (or chain) in which it appears. |
|
The custom message (i.e. XSS Attack) assigned to the rule (or chain) in which it appears. |
|
This stops rule processing and intercepts transaction. This is a disruptive action. |
|
This specifies the response status code (404) with actions deny and redirect. |