Fix sandbox bypass: PHP code injection via {% use %} template name

This commit is contained in:
Alexandre Daubois
2026-04-28 13:25:53 +02:00
committed by Fabien Potencier
parent afe54db2e5
commit e9ff55f691
2 changed files with 27 additions and 3 deletions
+3 -3
View File
@@ -248,11 +248,11 @@ final class ModuleNode extends Node
->string($key)
->raw("])) {\n")
->indent()
->write("throw new RuntimeError('Block ")
->write("throw new RuntimeError(sprintf('Block \"%s\" is not defined in trait \"%s\".', ")
->string($key)
->raw(' is not defined in trait ')
->raw(', ')
->subcompile($trait->getNode('template'))
->raw(".', ")
->raw('), ')
->repr($node->getTemplateLine())
->raw(", \$this->source);\n")
->outdent()