
CVE-2026-104883 的概念验证与实验环境:一个被委派的 Contao 用户管理器自行授予 theme_import 权限,从而升级为 PHP RCE,并配有漏洞版/修复版的差分测试框架。
| CVE | CVE-2026-104883 |
| 组件 | contao/core-bundle — CheckTemplateEditorSaveListener / TemplateEditorModuleVoter(tl_user、tl_user_group) |
| 受影响版本 | < 5.3.50(以及修复前的 5.7.x 系列) |
| 修复版本 | 5.3.50 — 提交 211498f28(GHSA-r9qp-pqx5-8369) |
| CWE | CWE-269(权限管理不当)、CWE-863(授权不正确) |
| 影响 | 被委派的用户/组管理员(该角色明确不被授予模板/代码访问权限)可以自我授予具备 RCE 能力的 theme_import 能力——以及 layout、unfiltered_html 等——从而提升至在服务器上执行任意 PHP 代码 |
| 攻击向量 | 已认证的低权限后台用户编辑自己的账户/组 |
| 触发条件 | 保存 themes = ['theme_import'](themes 字段没有防护) |
5.7.3 的加固仅防护了 modules / tpl_editor:
// vulnerable CheckTemplateEditorSaveListener — registered only on fields.modules.save
if (!\is_array($newModules) || !\in_array('tpl_editor', $newModules, true)) {
return $value; // themes/theme_import is never inspected -> grant accepted
}
该修复会防护每一个隐式管理员字段和值:
// fixed CheckImplicitAdminSaveListener (commit 211498f28)
private const IMPLICIT_ADMIN_VALUES = [
'modules' => ['tpl_editor'],
'themes' => ['theme_import', 'layout'],
'elements' => ['unfiltered_html'],
'frontendModules' => ['unfiltered_html', 'listing'],
'alexf' => [/* list_table, list_where, unfilteredHtml, ... */],
];
// registered on fields.modules/themes/elements/frontendModules/alexf.save;
// throws AccessDeniedException (ERR.grantAdminOnly) for a non-admin self-grant.
提交 2b83a60f7763(5.7.3)通过添加 TemplateEditorModuleVoter 和保存回调加固了模板编辑器,使非管理员无法自行授予 tpl_editor 后端模块(可编辑的、支持 PHP 的模板允许服务器端代码执行)。该保护仅覆盖 modules 字段和字面值 tpl_editor。同样具备 RCE 能力的 theme_import 能力位于另一个字段——themes 复选框字段(tl_user_group.php / tl_user.php)——该字段既没有 save_callback,也没有投票器。TemplateEditorModuleVoter 是唯一为 tl_user_group 注册的 DataContainer 投票器,且不覆盖 themes。因此,被委派的用户管理员可以将 themes 添加到模块字段,并将 theme_import 添加到主题字段(两者均被接受——只有 tpl_editor 被阻止),重新认证,并获得任意 PHP 执行能力。修复方案将监听器重命名为 CheckImplicitAdminSaveListener,将其注册到 modules/themes/elements/frontendModules/alexf,并拒绝非管理员对每个隐式管理员值的自行授予。
| 服务 | 镜像 | 角色 |
|---|---|---|
ct-vuln | cve-2026-104883:vuln | 真实的 CheckTemplateEditorSaveListener(修复前) |
ct-fixed | cve-2026-104883:fixed | 真实的 CheckImplicitAdminSaveListener(厂商修复) |
poc | cve-2026-104883-poc:local | 仅使用标准库的 Python 驱动程序 |
一个 PHP 测试框架从每个标签逐字加载真实的上游监听器类,并以非管理员身份(isGranted('ROLE_ADMIN') = false)在给定字段/值上调用 __invoke($value, $dc),且无先前访问权限。Symfony/Contao 依赖被桩替代;监听器逻辑本身未被改动。两侧仅在上游监听器源代码上有所不同。
./run-lab.sh build # builds both sides (php:8.3-cli)
./run-lab.sh up # cve104883lab network: ct-vuln / ct-fixed
./run-lab.sh sweep
./run-lab.sh down
poc/poc.py(仅使用标准库):
themes=['theme_import'] 保存被接受时退出码为 1,被拒绝时为 0;3 表示无 worker,2 表示不可达/不确定。theme_import → 重新认证 → 任意 PHP 执行。tpl_editor(两者均受防护)、theme_import / layout / unfiltered_html(绕过)、良性模块对照。211498f28。一个独立的完整链路利用程序位于 exploit/exploit.py:
python3 exploit/exploit.py --host=ct-vuln
# exit 1 on confirmed implicit-admin self-grant, 0 on a safe target
| 非管理员保存 | ct-vuln(修复前) | ct-fixed(211498f28) |
|---|---|---|
modules = ['tpl_editor'] | 拒绝(ERR.grantTemplateEditor) | 拒绝(ERR.grantAdminOnly) |
themes = ['theme_import'] | 允许(绕过) | 拒绝 |
themes = ['layout'] | 允许 | 拒绝 |
elements = ['unfiltered_html'] | 允许 | 拒绝 |
modules = ['news'](良性) | 允许 | 允许 |
捕获的运行记录: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。
cve104883lab
网络上运行受限容器;实验镜像中使用 PHP 8.3 运行时。user 或 group 后端模块);无需管理员
访问权限。修复后的 CheckImplicitAdminSaveListener 会拒绝
modules/themes/elements/frontendModules/alexf 中所有隐式管理员
自我授权(tpl_editor、theme_import、layout、unfiltered_html、listing,以及
alexf 列表字段),针对的是此前没有访问权限的非管理员。良性值仍可
保存。早先仅针对 tpl_editor 的防护使 theme_import / layout /
unfiltered_html 保持开放;该修复将所有这些都关闭。不再存在隐式管理员
自我授权路径。
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 listener source
lab/vendor/ verbatim listener class from pre-fix / fix commits
lab/stubs.php minimal Symfony/Contao dependency stubs
lab/harness.php invokes the real listener as a non-admin
lab/service.py HTTP wrapper (POST /check)
evidence/ captured runs of every mode on both sides
TRACKING.md excluded (working record)
2b83a60f7763(5.7.3,仅 tpl_editor)