
Proof-of-concept and lab for CVE-2026-104884, a stored XSS in Contao's legacy search template, with differential vulnerable/fixed containers and a Python exploit driver.
| CVE | CVE-2026-104884 |
| Component | contao/core-bundle — ModuleSearch::compile + legacy search_default.html5 |
| Affected | < 5.3.50 (installations using the legacy HTML5 search template) |
| Fixed in | 5.3.50 — commit 9519c104 (GHSA-h57j-5f5m-789v) |
| CWE | CWE-79 (Cross-site Scripting) |
| Impact | A backend page editor stores script in a page title; the indexed title is assigned to the search result link without escaping and the legacy search_default.html5 echoes it raw, so the script executes for anonymous front-end visitors (and admins) viewing search results — stored XSS crossing the editor → anonymous-visitor boundary |
| Vector | Stored — editor-planted page title rendered in legacy search results |
| Trigger | page title <script>alert(1)</script> with the legacy search template active |
The vulnerable assignment left the link raw:
// 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>
The fix escapes the assignment:
// fixed (commit 9519c104)
$objTemplate->href = StringUtil::specialchars($arrResult[$i]['url']);
$objTemplate->link = StringUtil::specialchars($arrResult[$i]['title']);
Commit 23e8cca3136a hardened the search-result title against insert-tag/XSS,
but the legacy HTML5 template does not use that title variable for the visible
link — it prints the raw link variable, which ModuleSearch::compile()
assigned directly from the entity-decoded indexed title
($objTemplate->link = $arrResult[$i]['title']). The legacy
search_default.html5 echoes <?= $this->link ?> unescaped, so a stored page
title containing script executes for anyone viewing the search results. The
default Twig search_default.html.twig auto-escapes and does not use the raw
link, so a default Twig install is not affected; the legacy template is still
shipped and selectable (common on migrated sites). The fix wraps the link and
href assignments in StringUtil::specialchars.
| service | image | role |
|---|---|---|
srch-vuln | cve-2026-104884:vuln | real compile() assignments (pre-fix) |
srch-fixed | cve-2026-104884:fixed | real assignments (vendor fix 9519c104) |
poc | cve-2026-104884-poc:local | stdlib-only Python driver |
A PHP harness renders the real legacy search_default.html5 template with the
link/href assigned by the verbatim upstream compile() result-loop lines,
using the real StringUtil::specialchars (htmlspecialchars with
ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5). It reports whether a raw payload tag
survives in the output. Both sides differ only in the upstream assignment lines.
./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 (stdlib only):
9519c104 / use the Twig template.A standalone full-chain exploit ships at exploit/exploit.py:
python3 exploit/exploit.py --host=srch-vuln
# exit 1 on confirmed raw-HTML rendering, 0 on a safe target
| indexed title | srch-vuln (pre-fix) | srch-fixed (9519c104) |
|---|---|---|
<script>alert(1)</script> | raw_script=true | escaped (<script>...) |
| `` | raw_script=true | escaped |
Regular Page Title (benign) | no HTML | no HTML |
Captured runs: 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
network; PHP 8.3 runtime in the lab images.search_default.html5 template
to be active for the search module and a backend editor able to plant a page
title; the default Twig template is not affected.The fixed compile() wraps link/href in StringUtil::specialchars, so
script/img payloads are entity-escaped in the legacy template output; benign
titles render normally. The raw-HTML rendering path is closed. (The default Twig
search template was already auto-escaping and unaffected.)
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)