Description
Twig is a template language for PHP. Versions 1.x prior to 1.44.7, 2.x prior to 2.15.3, and 3.x prior to 3.4.3 encounter an issue when the filesystem loader loads templates for which the name is a user input. It is possible to use the `source` or `include` statement to read arbitrary files from outside the templates' directory when using a namespace like `@somewhere/../some.file`. In such a case, validation is bypassed. Versions 1.44.7, 2.15.3, and 3.4.3 contain a fix for validation of such template names. There are no known workarounds aside from upgrading.
Affected products
| Vendor | Product | Affected | Fixed |
|---|---|---|---|
| twigphp | Twig | => 1.0.0, < 1.44.7, >= 2.0.0, < 2.15.3, >= 3.0.0, < 3.4.3 | — |
Fixed in Linux distributions
Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.
Debian
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Debian 14 | php-twig | 3.4.3-1 | — |
| Debian 13 | php-twig | 3.4.3-1 | — |
| Debian 12 | php-twig | 3.4.3-1 | — |
| Debian 11 | php-twig | 2.14.3-1+deb11u2 | DSA-5248-1 |
| Debian 10 | twig | 2.6.2-2+deb10u1 | DLA-3147-1 |
Ubuntu
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Ubuntu Pro 22.04 LTS | php-twig | 3.3.8-2ubuntu4+esm1 | USN-5947-1 |
| Ubuntu Pro 20.04 LTS | php-twig | 2.12.5-1ubuntu0.1~esm1 | USN-5947-1 |
| Ubuntu Pro 18.04 LTS | twig | 2.4.6-1ubuntu0.1~esm1 | USN-5947-1 |
Show 1 more (older releases, extended support, other products)Fewer releases
| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Ubuntu Pro 16.04 LTS | twig | 1.23.1-1ubuntu4+esm1 | USN-5947-1 |
Affected packages
| Ecosystem | Package | Affected | Fixed | Record |
|---|---|---|---|---|
| Packagist | drupal/core | >= 8.0.0, < 9.3.22 · >= 9.4.0, < 9.4.7 | 9.3.22, 9.4.7 | DRUPAL-CORE-2022-016 |
| Packagist | twig/twig | >= 1.0.0, < 1.44.7 | 1.44.7 | GHSA-52m2-vc4m-jj33 |
| Packagist | twig/twig | >= 2.0.0, < 2.15.3 | 2.15.3 | GHSA-52m2-vc4m-jj33 |
| Packagist | twig/twig | >= 3.0.0, < 3.4.3 | 3.4.3 | GHSA-52m2-vc4m-jj33 |
Advisories 3
- USN-5947-1 php-twig, twig vulnerabilities Ubuntu Security Notices (USN) · Jun 25, 2026
- DSA-5248-1 php-twig - security update Debian Security (DSA / DLA) · Mar 9, 2026
- DLA-3147-1 twig - security update Debian Security (DSA / DLA) · Mar 9, 2026
References
- https://github.com/twigphp/Twig/security/advisories/GHSA-52m2-vc4m-jj33
- https://github.com/twigphp/Twig/commit/35f3035c5deb0041da7b84daf02dea074ddc7a0b
- https://www.drupal.org/sa-core-2022-016
- DSA-5248 vendor-advisory
- FEDORA-2022-4490a4772d vendor-advisory
- FEDORA-2022-d39b2a755b vendor-advisory
- FEDORA-2022-1695454935 vendor-advisory
- FEDORA-2022-9d8ee4a6de vendor-advisory
- [debian-lts-announce] 20221011 [SECURITY] [DLA 3147-1] twig security update mailing-list
- FEDORA-2022-c6fe3ebd94 vendor-advisory
- FEDORA-2022-73b9fb7a77 vendor-advisory