Mend.io Vulnerability Database
The largest open source vulnerability database
What is a Vulnerability ID?
New vulnerability? Tell us about it!
CVE-2026-46633
Published:June 01, 2026
Updated:June 01, 2026
Description "Compiler::string()" escapes """, "$", "", NUL and TAB when generating PHP double-quoted string literals, but does not escape single quotes. In "ModuleNode::compileConstructor()", the template name from a "{% use %}" tag is compiled via "subcompile()" -> "string()" and placed inside a surrounding PHP single-quoted string literal. A template name containing a single quote terminates that surrounding string early, allowing arbitrary PHP expressions to be injected into the compiled cache file. The injected code executes within the PHP process when the cache file is first loaded, bypassing the Twig sandbox entirely and achieving remote code execution. "SecurityPolicy" unconditionally allows "{% use %}" regardless of the configured "allowedTags", so this primitive is reachable from sandboxed templates as well. Resolution "Compiler::string()" now also escapes single quotes so that template names placed inside single-quoted PHP literals can no longer break out of the surrounding context. Credits Twig would like to thank Anvil Secure in collaboration with Claude and Anthropic Research for reporting the issue and providing the fix.
Affected Packages
https://github.com/twigphp/Twig.git (GITHUB):
Affected version(s) >=v0.9.0 <v3.26.0
Fix Suggestion:
Update to version v3.26.0
twig/twig (PHP):
Affected version(s) >=dev-ci-fix <v3.26.0
Fix Suggestion:
Update to version v3.26.0
twig/twig (PHP):
Affected version(s) >=v0.9.0 <v3.26.0
Fix Suggestion:
Update to version v3.26.0
Do you need more information?
Contact Us
CVSS v4
Base Score:
9.3
Attack Vector
NETWORK
Attack Complexity
LOW
Attack Requirements
NONE
Privileges Required
NONE
User Interaction
NONE
Vulnerable System Confidentiality
HIGH
Vulnerable System Integrity
HIGH
Vulnerable System Availability
HIGH
Subsequent System Confidentiality
NONE
Subsequent System Integrity
NONE
Subsequent System Availability
NONE
CVSS v3
Base Score:
9.8
Attack Vector
NETWORK
Attack Complexity
LOW
Privileges Required
NONE
User Interaction
NONE
Scope
UNCHANGED
Confidentiality
HIGH
Integrity
HIGH
Availability
HIGH
Weakness Type (CWE)
Improper Control of Generation of Code ('Code Injection')