From 0507840b67d6375f791ead7e00e7424ec12f901e Mon Sep 17 00:00:00 2001 From: Matt Robinson Date: Mon, 9 Jan 2012 11:40:00 +0000 Subject: [PATCH] Prevent parameters from overwriting the template filename. Fixes a potential arbitrary file execution exploit. --- src/Symfony/Component/Templating/PhpEngine.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Templating/PhpEngine.php b/src/Symfony/Component/Templating/PhpEngine.php index 32c8c4564d..1953866bad 100644 --- a/src/Symfony/Component/Templating/PhpEngine.php +++ b/src/Symfony/Component/Templating/PhpEngine.php @@ -150,15 +150,20 @@ class PhpEngine implements EngineInterface, \ArrayAccess protected function evaluate(Storage $template, array $parameters = array()) { $__template__ = $template; + + if (isset($parameters['__template__'])) { + throw new \InvalidArgumentException('Invalid parameter (__template__)'); + } + if ($__template__ instanceof FileStorage) { - extract($parameters); + extract($parameters, EXTR_SKIP); $view = $this; ob_start(); require $__template__; return ob_get_clean(); } elseif ($__template__ instanceof StringStorage) { - extract($parameters); + extract($parameters, EXTR_SKIP); $view = $this; ob_start(); eval('; ?>'.$__template__.'