Anatomy of a Pre-Auth RCE: Decomposing the wp2shell WordPress Core Chain
Background and Motivation
On July 17 2026, WordPress shipped an emergency release — 7.0.2, with backports to 6.9.5 and 6.8.6 — to close a vulnerability publicly tracked as wp2shell (WordPress security release). The flaw is rare: a pre-authentication, remote, plugin-free remote code execution (RCE) chain that reaches a default WordPress install. Searchlight Cyber, whose researcher Adam Kues reported the issue, characterized the attack as having no preconditions — no account, no plugin, no user interaction (Searchlight Cyber research).
For most operators the action is straightforward — patch. But for engineers responsible for frameworks, RPC APIs, or any system that exposes a batch endpoint, the more interesting question is how two independently tracked bugs combined. wp2shell is a textbook example of a chain: a routing-layer confusion (CVE-2026-63030) supplies the attacker the ability to inject a value into a code path (CVE-2026-60137, SQL injection via WP_Query::author__not_in) that was supposed to be reachable only from authenticated internal callers. This article decomposes the chain, shows how to determine exposure from inside a running site, and collects the hardening patterns that prevent this class of bug rather than just this instance.
Prerequisites
- A working WordPress 6.8.x – 7.0.1 site under your control (DO NOT test against production — see the safe-validation note in Step 3).
- Shell access to
wp-includes/so you can readclass-wp-rest-server.php,class-wp-query.php, andrest-api.php. - A local snapshot of the diff between WordPress 7.0.1 and 7.0.2 for the three patched files. You can produce this via the official SVN/Git mirror:
git diff 7.0.1..7.0.2 -- \ wp-includes/rest-api/class-wp-rest-server.php \ wp-includes/class-wp-query.php \ wp-includes/rest-api.php - Optional but recommended: a persistent object-cache backend (Redis or Memcached). One of the more operationally interesting facts about wp2shell is that the RCE path is only reachable when a persistent object cache is NOT enabled — a common default for self-hosted and small shared-hosting installs (Rapid7 ETR).
Step 1: Preparation
The chain has two PDFs in its “trust boundary failure” diagram. Lock down the vocabulary before reading any code:
| Component | Failure (CVE) | What it does alone | What it does in the chain |
|---|---|---|---|
WP_REST_Server::serve_batch_request_v1() | CVE-2026-63030 | Routes a sub-request under the wrong matched-route context | Hands attacker-controlled parameters into handlers that the matched-route guard was supposed to filter |
WP_Query::author__not_in | CVE-2026-60137 | Facilitated SQL injection via unnormalised integer-list input | Supplies the injection primitive the chain escalates to RCE |
Both advisories (GHSA-ff9f-jf42-662q, GHSA-fpp7-x2x2-2mjf) were published on 2026-07-17.
Build a small reconnaissance helper — a must-use plugin that prints whether your site is in the exposed version window and whether persistent object cache is in use. This is non-destructive and safe to run against a staging site:
<?php
// wp-content/mu-plugins/wp2shell_recon.php
add_action('admin_init', function () {
if (!current_user_can('administrator')) return;
global $wp_version;
$v = $wp_version; // e.g. "6.9.4"
$branches = [
'6.8' => ['min' => '6.8.0', 'fixed' => '6.8.6', 'rce' => false],
'6.9' => ['min' => '6.9.0', 'fixed' => '6.9.5', 'rce' => true],
'7.0' => ['min' => '7.0.0', 'fixed' => '7.0.2', 'rce' => true],
];
[$major] = explode('.', $v);
$branch = "$major." . explode('.', $v)[1];
$b = $branches[$branch] ?? null;
echo "<!-- wp2shell recon: version=$v branch=$branch";
if (!$b) { echo "; branch not in affected range -->"; return; }
$exposed_sqli = version_compare($v, $b['min'], '>=') && version_compare($v, $b['fixed'], '<');
$exposed_rce = $exposed_sqli && $b['rce'];
$persistent = wp_using_ext_object_cache();
printf("; sqli_exposed=%s rce_exposed=%s persistent_obj_cache=%s -->",
$exposed_sqli ? 'YES' : 'no',
$exposed_rce ? 'YES' : 'no',
$persistent ? 'YES' : 'no');
});Install with wp plugin activate --skip-plugins for a fresh CLI probe, or just visit /wp-admin/ and view source. The RCE column reads YES only when both the version is vulnerable and no external object cache is wired up — exactly the condition Cloudflare flagged as the in-the-wild exploitable population.
Step 2: Core Implementation
Step 2a — The batch endpoint and route confusion
WordPress’s REST batch endpoint (/wp-json/batch/v1) shipped in 5.6 (Nov 2020) precisely so API clients can issue multiple sub-requests in one round-trip — useful for plugin install flows, block editor presave, and OEmbed fan-out. The dispatcher WP_REST_Server::serve_batch_request_v1() (source) iterates the sub-requests, calls match_request_to_route() for each, and serves each one in turn.
The CVE-2026-63030 weakness is in how matched-route state persists between sub-requests inside the loop. A correctly-named batch handler must reset the matched-route response for each sub-request; the buggy implementation reused state from a previously matched route when the next sub-request failed to fully match. An attacker can author a batch whose first sub-request normalises a handler (say, a public /wp/v2/posts route) and whose second sub-request re-uses the matched context under a different route that was supposed to be auth-guarded — allowing the resubmitted parameters to flow into handlers that had not been cleared for untrusted callers.
The patched version performs per-sub-request matched-route reset before any user-supplied parameter is read:
// Simplified outline of the 7.0.2 fix
foreach ($data['requests'] as $i => $single) {
$matched_route = null; // reset, every sub-request
$result = $this->serve_single_request($single, $matched_route);
if (is_wp_error($result) && $result->get_error_code() === 'rest_no_route') {
// previously: subtatthe next sub-request could inherit stale $matched_route
continue;
}
$results['responses'][ $i ] = $result;
}Step 2b — Where author__not_in enters the chain
WP_Query::author__not_in is a query var for “exclude posts by these author IDs”. Its value is expected to be an integer or array of integers. The vulnerable code in class-wp-query.php did not perform a hard cast/singleton normalisation when the value arrived as a one-element array carrying a non-integer string. Combined with the route-confusion weakness, the injected value reached MySQL unescaped inside an AND post_author NOT IN (...) clause.
The minimal injected body for demonstrating the SQL injection (NOT the RCE — the RCE demo requires a full PoC beyond what public sources have published) is:
POST /wp-json/batch/v1 HTTP/1.1
Host: vulnerable.example
Content-Type: application/json
{
"validation": "require-all-properties-validate",
"requests": [
{"path": "/wp/v2/posts", "method": "GET"},
{"path": "/wp/v2/posts",
"method": "GET",
"params": {"author__not_in": ["0) UNION (SELECT user_login, user_pass FROM wp_users-- "]}}
]
}DO NOT run this against a production WordPress site to “prove” it needs a patch. A staging clone or a local Docker WordPress is sufficient; the security release notes already confirm the issue (WordPress 7.0.2 release). The Penligent write-up calls out this exact anti-pattern (Penligent) — weapons used in production become evidence cleanup work.
Step 2c — From SQLi to RCE
The final step is material-specific: the recovered credentials from wp_users.user_pass are phpPortable hashing; cracking them offline yields admin login. With admin login an attacker uploads a malicious plugin and gets arbitrary PHP execution. Because the SQLi is reachable pre-auth via the batch route confusion, the entire chain needs no valid account. The persistent-object-cache precondition is — per Cloudflare’s analysis — the mitigation that accidentally disarms most expensive premium hosts; without an external cache backend, WordPress falls back to per-query MySQL round-trips for query results, which is exactly the path the injected value traverses.
Step 3: Verification and Tuning
Confirm propagated version. Dashboard → Tools → Site Health → Info → WordPress version. Or via WP-CLI:
wp core version wp core verify-checksums # the file tree matches the releaseWordPress enabled forced auto-update for affected branches; do not assume the update landed. Verify per host: filesystem permissions,
DISALLOW_FILE_MODS, immutable container images, and managed-hosting locks can each silently prevent the update.Inspect access logs for the batch endpoint, retroactively to July 17 and earlier:
grep -E '(/wp-json/batch/v1|rest_route=/batch/v1)' /var/log/nginx/access.log \ | awk '{print $1}' | sort | uniq -c | sort -rn | headAny IP sending abnormally large
POSTbodies to that endpoint in the last 30 days is a candidate for deeper review — pull the raw payload from your WAF or full-post logging.Block the batch path as a temporary fence if you run a non-updateable image:
# nginx vhost location ^~ /wp-json/batch/v1 { deny all; return 410; } # Also block the query-param alias if ($args ~* "rest_route=/batch/v1") { return 410; }Test legitimate breakage first: the block editor’s pre-publish batch and some plugin install flows use this endpoint. Schedule the fence as short-term cover, not a permanent fix.
Enable a persistent object cache. Even with the patch applied, the architecture lesson is clear: a site with no persistent cache has every expensive query re-running per request, which dramatically widens the surface for any future query-layer injection bug. Wire Redis via
wp redis enableor Memcached viaWP_CACHEand a drop-in. Confirm with:wp cache flush && wp cache add kc_test 'hello' && wp cache get kc_test
Best Practices Summary
- Patch first, verify checksums second. The CVE affects 6.8.x for SQLi only and 6.9.x / 7.0.x for the full RCE chain; fixed releases are 6.8.6, 6.9.5, 7.0.2. Confirm what you actually run.
- Treat two-CVE chains as a single incident. A scanner that reports only CVE-2026-63030 will under-escalate 6.8 sites; reporting only CVE-2026-60137 will under-escalate 6.9/7.0 sites. The two flaws interact; ticket them as one work order.
- Enable a persistent object cache unconditionally. It is operationally a hardening measure against this class of bug; without it, query-data round-trips and any future
WP_Queryinjection widen the exposure window. - Filter the
/wp-json/batch/v1endpoint at the edge if you cannot patch. Treat the WAF rule as a patch bridge, not as a fix — Cloudflare and Aikido Zen both explicitly disclaim their rules as substitutes for updating (Cloudflare WAF advisory). - Audit your own batch endpoints. The wp2shell lesson generalises: any dispatcher that reuses matched-route state between sub-requests inherits this class of failure. Apply per-sub-request reset unconditionally; never let an unmatched sub-request inherit the previous match’s response.
- Never weaponise a public PoC against a production site. Use staging or a throwaway Docker WordPress; the disclosure clock has shifted the window but it has not removed it.
References
- WordPress 7.0.2 Security Release Notes
- GHSA-ff9f-jf42-662q — CVE-2026-63030 batch-route confusion
- GHSA-fpp7-x2x2-2mjf — CVE-2026-60137 WP_Query SQL injection
- Searchlight Cyber — wp2shell Pre-Auth RCE in WordPress Core
- Rapid7 ETR — CVE-2026-63030 wp2shell
- SOCRadar — wp2shell CISO FAQ & Fix
- Hadrian — wp2shell Pre-Auth RCE in REST Batch API
- Aikido — Unauthenticated RCE in WordPress core (wp2shell)
- Penligent — CVE-2026-63030 wp2shell patch priority & safe validation
- Cloudflare Blog — WAF protections for WordPress vulnerabilities
- The Hacker News — wp2shell WordPress Core Flaw