CVE-2026-46633
Twig: PHP code injection via `{% use %}` template name
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.
Attack profile
How easy it is to exploit
- Attack vector
- Network
- Complexity
- Low
- Privileges needed
- Low
- User interaction
- None
What an attacker can affect
- Confidentiality
- High
- Integrity
- High
- Availability
- High
Exploit likelihood
What each source reports
CVE List Score used
8.7
Twig: PHP code injection via `{% use %}` template name
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.
- Record
CVE-2026-46633- CVSS 4.0
- 8.7 High
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 - Weakness
- CWE-94
- Updated
- 2026-11-02
EUVDEUVD-2026-44558
8.7
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.
- Record
EUVD-2026-44558- CVSS 4.0
- 8.7 High
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 - Updated
- 2026-11-04
GitHub AdvisoriesGHSA-7p85-w9px-jpjp
9.3
Twig: PHP code injection via `{% use %}` template name
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.
- Record
GHSA-7p85-w9px-jpjp- CVSS 4.0
- 9.3 Critical
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N - CVSS 3.1
- 9.8 Critical
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H - Weakness
- CWE-94
- Updated
- 2026-11-04
NVD
8.7
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.
- Record
CVE-2026-46633- CVSS 4.0
- 8.7 High
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:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X - CVSS 3.1
- 9.8 Critical
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H - Weakness
- CWE-94
- Updated
- 2026-11-04
OSV
8.7
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.
- Record
CVE-2026-46633- CVSS 4.0
- 8.7 High
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 - Weakness
- CWE-94
- Updated
- 2026-11-07
OSVDEBIAN-CVE-2026-46633
9.8
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.
- Record
DEBIAN-CVE-2026-46633- CVSS 3.1
- 9.8 Critical
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H - Updated
- 2026-11-04
Show 6 moreShow less
OSVGHSA-7p85-w9px-jpjp
9.3
Twig: PHP code injection via `{% use %}` template name
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.
- Record
GHSA-7p85-w9px-jpjp- CVSS 4.0
- 9.3 Critical
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N - CVSS 3.1
- 9.8 Critical
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H - Weakness
- CWE-94
- Updated
- 2026-11-04
OSVUBUNTU-CVE-2026-46633
8.7
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.
- Record
UBUNTU-CVE-2026-46633- CVSS 4.0
- 8.7 High
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 - CVSS 3.1
- 9.8 Critical
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H - Updated
- 2026-11-05
OSVCLSA-2026-1783991054 No score
TuxCare security update for twig/twig (11 CVEs)
TuxCare rebuilt twig/twig to address 11 CVEs. Fixed in v2.16.1-p1+tuxcare.
- Record
CLSA-2026-1783991054- Updated
- 2026-11-02
OSVCLSA-2026-1784682913 No score
TuxCare security update for twig/twig (10 CVEs)
TuxCare rebuilt twig/twig to address 10 CVEs. Fixed in v2.15.6-p2+tuxcare.
- Record
CLSA-2026-1784682913- Updated
- 2026-11-02
OSVCLSA-2026-1786534048 No score
TuxCare security update for twig/twig (8 CVEs)
TuxCare rebuilt twig/twig to address 8 CVEs. Fixed in v1.44.8-p1+tuxcare.
- Record
CLSA-2026-1786534048- Updated
- 2026-11-02
OSVROOT-APP-COMPOSER-CVE-2026-46633 No score
CVE-2026-46633 in twig/twig - Patched by Root
Root has patched CVE-2026-46633 in the twig/twig package for Root:Composer. Multiple fixed versions available.
- Record
ROOT-APP-COMPOSER-CVE-2026-46633- Updated
- 2026-11-02
Affected products
Affected packages
| Package | Affected | Fixed |
|---|---|---|
twig/twigPackagist |
1.15.1 up to 3.26.0 | 3.26.0 |
twig/twigTuxCare:Packagist From an advisory covering 11 CVEs |
v2.16.1 up to v2.16.1-p1+tuxcare | v2.16.1-p1+tuxcare |
twig/twigTuxCare:Packagist From an advisory covering 10 CVEs |
v2.15.6 up to v2.15.6-p2+tuxcare, plus listed versions v2.15.6-p1+tuxcare |
v2.15.6-p2+tuxcare |
twig/twigTuxCare:Packagist From an advisory covering 8 CVEs |
v1.44.8 up to v1.44.8-p1+tuxcare | v1.44.8-p1+tuxcare |
php-twigDebian:12 |
before 3.5.1-1+deb12u3, plus listed versions 3.5.1-13.5.1-1+deb12u13.5.1-1+deb12u2 |
3.5.1-1+deb12u3 |
php-twigDebian:13 |
before 3.27.0-0+deb13u1, plus listed versions 3.20.0-23.21.1-13.21.1-23.21.1-33.22.0-1 Show 11 moreShow less3.22.0-23.22.1-13.22.1-23.22.1-33.22.2-13.22.2-23.23.0-13.23.0-23.24.0-13.26.0-0+deb13u13.26.0-1 |
3.27.0-0+deb13u1 |
php-twigDebian:14 |
before 3.26.0-1, plus listed versions 3.20.0-23.21.1-13.21.1-23.21.1-33.22.0-1 Show 9 moreShow less3.22.0-23.22.1-13.22.1-23.22.1-33.22.2-13.22.2-23.23.0-13.23.0-23.24.0-1 |
3.26.0-1 |
twig/twigPackagist |
1.15.1 up to 3.26.0, plus listed versions v1.15.1v1.16.0v1.16.1v1.16.2v1.16.3 Show 45 moreShow lessv1.17.0v1.18.0v1.18.1v1.18.2v1.19.0v1.20.0v1.21.0v1.21.1v1.21.2v1.22.0v1.22.1v1.22.2v1.22.3v1.23.0v1.23.1v1.23.2v1.23.3v1.24.0v1.24.1v1.24.2v1.25.0v1.26.0v1.26.1v1.27.0v1.28.0v1.28.1v1.28.2v1.29.0v1.30.0v1.31.0v1.32.0v1.33.0v1.33.1v1.33.2v1.34.0v1.34.1v1.34.2v1.34.3v1.34.4v1.35.0v1.35.1v1.35.2v1.35.3v1.35.4v1.36.0 |
3.26.0 |
twig/twigRoot:Composer |
before v3.11.3-p12007001+root.io | v3.11.3-p12007001+root.iov3.11.3-p12007002+root.iov3.11.3-p12007003+root.iov3.11.3-p12007004+root.iov3.11.3-p12007005+root.io |
php-twigUbuntu:Pro:20.04:LTS |
All versions, plus listed versions 2.11.3-22.12.1-12.12.2-12.12.3-12.12.5-12.12.5-1ubuntu0.1~esm12.12.5-1ubuntu0.1~esm2 |
None known |
Show 5 moreShow less
| Package | Affected | Fixed |
|---|---|---|
php-twigUbuntu:Pro:22.04:LTS |
All versions, plus listed versions 3.3.2-1ubuntu33.3.4-13.3.6-13.3.7-13.3.8-2ubuntu43.3.8-2ubuntu4+esm13.3.8-2ubuntu4+esm2 |
None known |
php-twigUbuntu:Pro:24.04:LTS |
All versions, plus listed versions 3.7.0-13.7.1-13.8.0-23.8.0-2ubuntu0.1~esm13.8.0-2ubuntu13.8.0-2ubuntu1+esm1 |
None known |
php-twigUbuntu:25.10 |
All versions, plus listed versions 3.20.0-2ubuntu1 |
None known |
php-twigUbuntu:26.10 |
All versions, plus listed versions 3.23.0-2build73.27.1-13.28.0-1 |
None known |
php-twigUbuntu:Pro:26.04:LTS |
All versions, plus listed versions 3.20.0-2ubuntu13.23.0-2build53.23.0-2build73.23.0-2ubuntu0.1~esm1 |
None known |
History
| Recorded | Changed | Sources |
|---|---|---|
| affected | OSV | |
| references | OSV | |
| references | EUVD, NVD | |
| affected, facts, references | GitHub Advisories, OSV | |
| first indexed | CVE List, EUVD, GitHub Advisories, NVD, OSV |
Dates are when Every CVE recorded each change. Upstream dates may differ.
In short
CVE-2026-46633 is a high vulnerability (CVSS 8.7) in Symfony Twig, published May 21, 2026. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 0.77%, the 55th percentile. Fixed in twig/twig 3.26.0.
References
github.com/twigphp/Twig/security/advisories/GHSA-7p85-w9px-jpjp
github.com/twigphp/Twig/commit/679447fa29083043665482ccf7d64372472621b8
github.com/twigphp/Twig/commit/e9ff55f6910832428e48a35b2e0748189ad49ae3
github.com/twigphp/Twig/releases/tag/v3.26.0
github.com/twigphp/Twig/commit/a2c6db7ea7d2c90923e6708019ec1442526d1c30
gist.github.com/vladko312/d61b950f168c791db4786b83dc7a81e6
Show 10 moreShow less
github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2026-46633.yaml
symfony.com/cve-2026-46633
nvd.nist.gov/vuln/detail/CVE-2026-46633
github.com/advisories/GHSA-7p85-w9px-jpjp
github.com/CVEProject/cvelistV5/tree/main/cves/2026/46xxx/CVE-2026-46633.json
security-tracker.debian.org/tracker/CVE-2026-46633
github.com/twigphp/Twig
ubuntu.com/security/CVE-2026-46633
cve.org/CVERecord?id=CVE-2026-46633
symfony.com/blog/cve-2026-46633-php-code-injection-via-use-template-name
Left out here: 156 versions. The JSON record has them.