CVE-2022-39261
Twig may load a template outside a configured directory when using the filesystem loader
- State
- Published
- Severity
- 7.5 High
- Published
- Sep 28, 2022
- Updated
- Apr 23, 2025
- Reserved
- Sep 2, 2022
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.
Scores
| CVSS | Score | Vector | Source |
|---|---|---|---|
| 3.1 | 7.5 High | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N | GitHub_M |
Weaknesses
- CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Products
| Product | Versions |
|---|---|
Twigtwigphp |
|
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-5248vendor-advisory
- FEDORA-2022-4490a4772dvendor-advisory
- FEDORA-2022-d39b2a755bvendor-advisory
- FEDORA-2022-1695454935vendor-advisory
- FEDORA-2022-9d8ee4a6devendor-advisory
- [debian-lts-announce] 20221011 [SECURITY] [DLA 3147-1] twig security updatemailing-list
- FEDORA-2022-c6fe3ebd94vendor-advisory
- FEDORA-2022-73b9fb7a77vendor-advisory
Every record here comes from the CVE Program’s CVE List. © 1999–2026 The MITRE Corporation. CVE is a registered trademark of The MITRE Corporation. The records are reproduced under the CVE Program terms of use.