SQL Threat Detector rule
This rule protects APIs against SQL injection attacks by detecting SQL commands in headers, paths, queries, and payloads.
Known limitations
Complex regular expressions with certain patterns don't work correctly, causing either false positives (all payloads flagged as threats) or false negatives (no payloads flagged as threats). For details about affected patterns and recommended workarounds, see Regular expression limitations below.
Rule execution order
This SQL Threat Detector rule executes after the request has been authenticated.
If the request includes one of the specified SQL commands in the query string, header, or path, the requestor receives a Validation failed error. If the request doesn't include one of the specified SQL commands, the system applies the next rule or starts processing the request.
| Field/Field set | Description |
|---|---|
| When this rule should be applied | An expression that defines one or more conditions that must be
true for the rule to execute.
Example: The expression |
| Threat Detection Regex | The SQL string to use to detect threats. The default expression works as is. You can
append entries, re-order them, or replace the expression with your own. Default value:
Example:
|
| Description |
Default value: Requests are checked for SQL injection attempts. |
Regular expression limitations
Not all regular expressions are supported by the SQL Threat Detector regex engine. Use the | operator for alternation only (for example, SELECT|UPDATE or (?i)(select|update|delete)). To match literal pipe characters, use a character class such as [|] (for a single pipe) or [|]{2} (for two consecutive pipes). Backslash-escaped pipes such as \| or \|\| are not supported and must be rewritten using [|]-based patterns.
Prohibited
\b- Word boundaries\s- Whitespace shorthand\S- Non-whitespace shorthand\w- Word characters shorthand\d- Digits shorthand\|,\|\|- Backslash-escaped pipes; use[|]or[|]{2}instead(?=.*\S)- Lookaheads containing shorthand classes
Permitted
[|]- Character class for pipe literals (single pipe:[|], double pipe:[|]{2})[[:space:]]- POSIX whitespace class[[:alnum:]]- POSIX alphanumeric class.- Any character except line breaks+- One or more quantifier*- Zero or more quantifier|- Alternation operator without backslash escaping (for example,SELECT|UPDATE)()- Capturing groups(?i)- Case-insensitive flag