Monitor vulnerabilities like this one.
Sign up free to get alerted when software you use is affected.
8.7
CVE-2026-46633: Twig: PHP Code Injection via Malformed Template Names
GHSA-7p85-w9px-jpjp
CVE-2026-46633
GHSA-7p85-w9px-jpjp
CVE-2026-46633
Summary
A security flaw in Twig allows attackers to inject malicious PHP code into templates. This can lead to unauthorized access to sensitive data and potentially allow attackers to execute code on the server. To protect against this, Twig has been updated to properly escape single quotes in template names, preventing the injection of malicious code.
What to do
- Update twig twig to version 3.26.0.
- Update twig twig/twig to version 3.26.0.
Affected software
| Ecosystem | Vendor | Product | Affected versions |
|---|---|---|---|
| composer | twig | twig |
< 3.26.0 Fix: upgrade to 3.26.0
|
| Packagist | twig | twig/twig |
< 3.26.0 Fix: upgrade to 3.26.0
|
| – | twigphp | twig | < 3.26.0 |
| – | symfony | twig |
< 3.26.0 cpe:2.3:a:symfony:twig:*:*:*:*:*:*:*:* |
Original title
Twig is a template language for PHP. Prior to 3.26.0, Compiler::string() does not escape single quotes when a template name from a {% use %} tag is placed inside a PHP single-quoted string literal,...
Original description
Twig is a template language for PHP. Prior to 3.26.0, Compiler::string() does not escape single quotes when a template name from a {% use %} tag is placed inside a PHP single-quoted string literal, allowing a crafted template name to terminate the string and inject arbitrary PHP expressions into the compiled cache file. This issue is fixed in version 3.26.0.
ghsa CVSS4.0
9.3
Vulnerability type
CWE-94
Code Injection
- https://github.com/twigphp/Twig/security/advisories/GHSA-7p85-w9px-jpjp
- https://github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-20...
- https://symfony.com/cve-2026-46633
- https://github.com/advisories/GHSA-7p85-w9px-jpjp
- https://github.com/twigphp/Twig Product
- https://github.com/twigphp/Twig/commit/679447fa29083043665482ccf7d64372472621b8 x_refsource_MISC
- https://github.com/twigphp/Twig/commit/e9ff55f6910832428e48a35b2e0748189ad49ae3 x_refsource_MISC
- https://github.com/twigphp/Twig/releases/tag/v3.26.0 x_refsource_MISC
Published: 14 Jul 2026 · Updated: 16 Jul 2026 · First seen: 21 May 2026