| CVE | CVE-2026-104884 |
| 组件 | contao/core-bundle — ModuleSearch::compile + 旧版 search_default.html5 |
| 受影响版本 | < 5.3.50(使用旧版 HTML5 搜索模板的安装) |
| 修复版本 | 5.3.50 — 提交 9519c104(GHSA-h57j-5f5m-789v) |
| CWE | CWE-79(跨站脚本) |
| 影响 | 后台页面编辑者在页面标题中存储脚本;被索引的标题在未转义的情况下被赋值给搜索结果的 link,而旧版 search_default.html5 将其原样输出,因此脚本会在查看搜索结果的匿名前端访客(以及管理员)处执行——存储型 XSS 跨越了编辑者 → 匿名访客的边界 |
| 向量 | 存储型 — 编辑者植入的页面标题在旧版搜索结果中渲染 |
| 触发条件 | 页面标题为 <script>alert(1)</script>,且旧版搜索模板处于启用状态 |
存在漏洞的赋值使链接保持原样:
// ModuleSearch::compile() — pre-fix
$objTemplate->href = $arrResult[$i]['url'];
$objTemplate->link = $arrResult[$i]['title']; // raw indexed title
<!-- legacy search_default.html5 -->
<h3><a href="<?= $this->href ?>" title="<?= $this->title ?>"><?= $this->link ?></a></h3>
修复方案对该赋值进行了转义:
// fixed (commit 9519c104)
$objTemplate->href = StringUtil::specialchars($arrResult[$i]['url']);
$objTemplate->link = StringUtil::specialchars($arrResult[$i]['title']);
提交 23e8cca3136a 对搜索结果标题进行了加固,以抵御插入标签/XSS 攻击,但旧版 HTML5 模板并未使用该 title 变量来生成可见链接——它直接输出原始的 link 变量,而该变量由 ModuleSearch::compile() 直接从实体解码后的索引标题($objTemplate->link = $arrResult[$i]['title'])赋值。旧版 search_default.html5 未转义地回显 <?= $this->link ?>,因此任何查看搜索结果的用户都会执行包含脚本的存储页面标题。默认的 Twig search_default.html.twig 会自动转义,且不使用原始的 link,因此默认的 Twig 安装不受影响;但旧版模板仍随附发布且可选择使用(在迁移过的站点上很常见)。修复方案将 link 和 href 的赋值包裹在 StringUtil::specialchars 中。
| 服务 | 镜像 | 角色 |
|---|---|---|
srch-vuln | cve-2026-104884:vuln | 真实的 compile() 赋值(修复前) |
srch-fixed | cve-2026-104884:fixed | 真实赋值(厂商修复 9519c104) |
poc | cve-2026-104884-poc:local | 仅使用标准库的 Python 驱动 |
一个 PHP 测试框架使用逐字取自上游 compile() 结果循环行的 link/href 赋值,渲染真实的旧版 search_default.html5 模板,并使用真实的 StringUtil::specialchars(带 ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5 的 htmlspecialchars)。它会报告原始 payload 标签是否在输出中存活。两侧仅在 upstream 赋值行上有所不同。
./run-lab.sh build # builds both sides (php:8.3-cli)
./run-lab.sh up # cve104884lab network: srch-vuln / srch-fixed
./run-lab.sh sweep
./run-lab.sh down
poc/poc.py(仅使用标准库):
9519c104 / 使用 Twig 模板。一个独立的完整攻击链利用程序位于 exploit/exploit.py:
python3 exploit/exploit.py --host=srch-vuln
# exit 1 on confirmed raw-HTML rendering, 0 on a safe target
| 索引标题 | srch-vuln(修复前) | srch-fixed(9519c104) |
|---|---|---|
<script>alert(1)</script> | raw_script=true | 已转义(<script>...) |
| `` | raw_script=true | 已转义 |
Regular Page Title(良性) | 无 HTML | 无 HTML |
捕获的运行:evidence/check-*-run.txt、evidence/exploit-*-run.txt、
evidence/probe-*-run.txt、evidence/mitigation-*-run.txt、
evidence/exploit-standalone-run.txt、evidence/exploit-standalone-fixed-run.txt、
evidence/versions.txt、evidence/0day-sweep.txt。
cve104884lab
网络上运行的有界容器;实验镜像中的 PHP 8.3 运行时。search_default.html5 模板,
并且需要一个能够植入页面标题的后端编辑器;默认的 Twig 模板不受影响。修复后的 compile() 将 link/href 包裹在 StringUtil::specialchars 中,因此
script/img 载荷在旧版模板输出中会被实体转义;良性
标题正常渲染。原始 HTML 渲染路径已被关闭。(默认的 Twig
搜索模板本就已自动转义,不受影响。)
README.md this write-up
run-lab.sh environment driver (build / up / sweep / down)
Makefile convenience targets
poc/poc.py the PoC (check / exploit / probe / mitigation)
exploit/exploit.py standalone full-chain exploit
lab/lab.Dockerfile builds both sides from upstream source
lab/vendor/ verbatim compile() assignments + legacy template
lab/stubs.php real StringUtil::specialchars + template renderer
lab/harness.php renders the legacy template, detects raw payload tags
lab/service.py HTTP wrapper (POST /search)
evidence/ captured runs of every mode on both sides
TRACKING.md excluded (working record)