Track vulnerabilities like this one.
Sign up free to get alerted when software you use is affected.
9.4
CVE-2026-46633: Twig templates may allow arbitrary PHP code execution
CVE-2026-46633 · published 3 months ago
Summary
Versions of the Twig template engine from 1.15.1 up to, but not including, 3.26.0 can be tricked into inserting malicious PHP code into its compiled cache files. An attacker could craft a template name that breaks the code and runs their own PHP commands, potentially compromising the server. Upgrade Twig to version 3.26.0 or later to fix the problem.
What to do
- Update twig twig to version 3.26.0.
- Update twig twig/twig to version 3.26.0.
- Update debian php-twig to version 3.5.1-1+deb12u3.
- Update debian php-twig to version 3.27.0-0+deb13u1.
- Update debian php-twig to version 3.26.0-1.
- Update twig twig/twig to version v3.11.3-p12007003+root.io.
- Update twig twig/twig to version v3.11.3-p12007004+root.io.
- Update twig twig/twig to version v3.11.3-p12007005+root.io.
- Update symfony twig to version 3.26.0 or later.
Affected software
| Ecosystem | Vendor | Product | Affected versions |
|---|---|---|---|
| composer | twig | twig |
< 3.26.0 >= 1.15.1, < 3.26.0 Fix: upgrade to 3.26.0
|
| Packagist | twig | twig/twig |
< 3.26.0 Fix: upgrade to 3.26.0
|
| Debian:11 | debian | php-twig | All versions |
| Debian:12 | debian | php-twig |
< 3.5.1-1+deb12u3 Fix: upgrade to 3.5.1-1+deb12u3
|
| Debian:13 | debian | php-twig |
< 3.27.0-0+deb13u1 Fix: upgrade to 3.27.0-0+deb13u1
|
| Debian:14 | debian | php-twig |
< 3.26.0-1 Fix: upgrade to 3.26.0-1
|
| Ubuntu:Pro:20.04:LTS | canonical | php-twig | All versions |
| Ubuntu:Pro:22.04:LTS | canonical | php-twig | All versions |
| Ubuntu:Pro:24.04:LTS | canonical | php-twig | All versions |
| Ubuntu:25.10 | canonical | php-twig | All versions |
| Ubuntu:Pro:26.04:LTS | canonical | php-twig | All versions |
| – | twigphp | twig |
< 3.26.0 >= 1.15.1, < 3.26.0 |
| – | symfony | twig |
< 3.26.0 cpe:2.3:a:symfony:twig:*:*:*:*:*:*:*:* |
| Root:Composer | twig | twig/twig |
< v3.11.3-p12007003+root.io < v3.11.3-p12007004+root.io < v3.11.3-p12007005+root.io Fix: upgrade to v3.11.3-p12007003+root.io
|
Original advisory text
Twig: PHP code injection via `{% use %}` template name
Twig is a template language for PHP. Starting in 1.15.1 and 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.
References
- https://github.com/advisories/GHSA-7p85-w9px-jpjp
- https://github.com/twigphp/Twig Product
- https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/46xxx/CVE-2026-46633... Vendor Advisory
- https://github.com/twigphp/Twig/commit/679447fa29083043665482ccf7d64372472621b8
- 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/twigphp/Twig/commit/a2c6db7ea7d2c90923e6708019ec1442526d1c30
- https://github.com/twigphp/Twig/commit/e9ff55f6910832428e48a35b2e0748189ad49ae3
- https://gist.github.com/vladko312/d61b950f168c791db4786b83dc7a81e6
- https://github.com/twigphp/Twig/releases/tag/v3.26.0
- https://security-tracker.debian.org/tracker/CVE-2026-46633 Vendor Advisory
- https://nvd.nist.gov/vuln/detail/CVE-2026-46633
- https://ubuntu.com/security/CVE-2026-46633 Third Party Advisory
- https://www.cve.org/CVERecord?id=CVE-2026-46633 Third Party Advisory
- https://symfony.com/blog/cve-2026-46633-php-code-injection-via-use-template-name Third Party Advisory
Internet-facing
14 days
Internal
At next upgrade
- Not known to be exploited
- Needs hands-on effort to exploit
- Gives an attacker full control
Severity
9.4
Critical
Type
CWE-94Code Injection
Timeline
Published14 Jul 2026
Updated5 Nov 2026
First seen21 May 2026
Sources
DEBIAN-CVE-2026-46633 · OSV
UBUNTU-CVE-2026-46633 · OSV
GHSA-7p85-w9px-jpjp · GHSA
CVE-2026-46633 · NVD
GHSA-7p85-w9px-jpjp · OSV
CVE-2026-46633 · MITRE
CVE-2026-46633 · OSV
Track software like this
Free during beta