Vulnerability · Published Sep 28, 2022 · Assigned by GitHub_M
CVE-2022-39261Twig may load a template outside a configured directory when using the filesystem loader
High 7.5
In plain English
A high-severity path traversal in Twig from twigphp. There are no confirmed reports of exploitation so far. The chance it is exploited in the next 30 days is estimated at 3.2% (higher than 88% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.
Official 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 packages & fixed versions
| Ecosystem | Package | Fixed in | Advisory |
|---|---|---|---|
| Debian:12 | php-twig | 3.4.3-1 | DEBIAN-CVE-2022-39261 |
| Debian:13 | php-twig | 3.4.3-1 | DEBIAN-CVE-2022-39261 |
| Debian:14 | php-twig | 3.4.3-1 | DEBIAN-CVE-2022-39261 |
| Packagist | drupal/core | 9.3.22, 9.4.7 | DRUPAL-CORE-2022-016 |
| Packagist | twig/twig | 3.4.3 | GHSA-52m2-vc4m-jj33 |
| Packagist | twig/twig | 1.44.7 | GHSA-52m2-vc4m-jj33 |
| Packagist | twig/twig | 2.15.3 | GHSA-52m2-vc4m-jj33 |
Affected products (as reported)
Weakness: CWE-22 · Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
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