Code Injection in Twig - CVE-2026-46640

 

Code Injection in Twig - CVE-2026-46640

Published: May 20, 2026


Vulnerability identifier: #VU131998
CSH Severity: Medium
CVSS v4.0: CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:U/U:Green
CVE-ID: CVE-2026-46640
CWE-ID: CWE-94
Exploitation vector: Remote access
Exploit availability: No public exploit available
Vendor: Symfony
Affected software:
Twig

Detailed vulnerability description

The vulnerability allows a remote user to execute arbitrary code.

The vulnerability exists due to improper control of code generation in MacroReferenceExpression compilation when processing template source that uses `_self.()` or an import alias with a string literal dynamic attribute. A remote user can supply a specially crafted template to execute arbitrary code.

Code execution occurs at template-load time before `checkSecurity()` is called, resulting in a bypass of `SandboxExtension`.


How to mitigate CVE-2026-46640

Install security update from vendor's website.

Sources