
Contao의 레거시 검색 템플릿에 존재하는 저장형 XSS인 CVE-2026-104884에 대한 개념 증명(PoC) 및 실습 환경으로, 취약 버전과 수정 버전 컨테이너를 차등 구성하고 Python 익스플로잇 드라이버를 포함합니다.
| 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 (Cross-site Scripting) |
| 영향 | 백엔드 페이지 편집자가 페이지 제목에 스크립트를 저장하고, 인덱싱된 제목이 이스케이프 없이 검색 결과 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은 검색 결과 제목을 insert-tag/XSS에 대해 강화했지만,
레거시 HTML5 템플릿은 표시되는 링크에 해당 title 변수를 사용하지 않습니다.
대신 ModuleSearch::compile()이 엔티티 디코딩된 색인 제목
($objTemplate->link = $arrResult[$i]['title'])에서 직접 할당한 원시 link 변수를 출력합니다. 레거시
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 하네스는 실제 레거시 search_default.html5 템플릿을
업스트림 compile() 결과 루프 라인 그대로 할당된
link/href과 함께 렌더링하며,
실제 StringUtil::specialchars(ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5를 사용하는 htmlspecialchars)을 사용합니다.
이 하네스는 원시 페이로드 태그가 출력에서 살아남는지 여부를 보고합니다. 양측은 업스트림 할당 라인에서만 차이가 있습니다.
./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)