PT-2026-42173 · Twig · Twig
Published
2026-05-20
·
Updated
2026-06-07
·
CVE-2026-46633
CVSS v4.0
9.3
Critical
| Vector | AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N |
Name of the Vulnerable Software and Affected Versions
Twig (affected versions not specified)
Description
The
Compiler::string() function fails to escape single quotes when generating PHP double-quoted string literals. In ModuleNode::compileConstructor(), template names from a {% use %} tag are processed via subcompile() and string(), then placed within a PHP single-quoted string literal. A template name containing a single quote can terminate the string prematurely, allowing the injection of arbitrary PHP expressions into the compiled cache file. This leads to remote code execution within the PHP process when the cache file is loaded, bypassing the Twig sandbox because SecurityPolicy allows the {% use %} tag regardless of the allowedTags configuration.Recommendations
Update to the version where
Compiler::string() escapes single quotes to prevent template names from breaking out of the surrounding PHP literals.Exploit
Fix
Code Injection
Found an issue in the description? Have something to add? Feel free to write us 👾
Weakness Enumeration
Related Identifiers
Affected Products
Twig