Twig may load a template outside a configured directory when using the filesystem loader
Key facts
- Attack vector
- Network
- Privileges required
- None
- User interaction
- None
- Attack complexity
- Low
- Impact type
- Information disclosure
- Confidentiality · integrity · availability
- High · None · None
- Fix status
- Fixed
Attack profile from CVSS 3.1 · CNA. Fix status from CNA and GitHub. Impact type from CWE-22 and the CVSS impact.
Summary
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.
Why it matters now
SSVC decision points
CISA ADP · SSVC 2.0.3
- Exploitation
- None
- Automatable
- Yes
- Technical impact
- Partial
The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| symfony | Twig | => 1.0.0, < 1.44.7; 2.0.0 to before 2.15.3; 3.0.0 to before 3.4.3 | 2.15.3, 3.4.3 | Patch available | CNA |
| — | twig/twig (Packagist) | 1.0.0 to before 1.44.7 | 1.44.7 | Patch available | GHSA-52m2-vc4m-jj33 |
| — | twig/twig (Packagist) | 2.0.0 to before 2.15.3 | 2.15.3 | Patch available | GHSA-52m2-vc4m-jj33 |
| — | twig/twig (Packagist) | 3.0.0 to before 3.4.3 | 3.4.3 | Patch available | GHSA-52m2-vc4m-jj33 |
- Twig Vendorsymfony Affected => 1.0.0, < 1.44.7; 2.0.0 to before 2.15.3; 3.0.0 to before 3.4.3 Fixed in 2.15.3, 3.4.3 Patch available CNA
- twig/twig (Packagist) Vendor— Affected 1.0.0 to before 1.44.7 Fixed in 1.44.7 Patch available GHSA-52m2-vc4m-jj33
- twig/twig (Packagist) Vendor— Affected 2.0.0 to before 2.15.3 Fixed in 2.15.3 Patch available GHSA-52m2-vc4m-jj33
- twig/twig (Packagist) Vendor— Affected 3.0.0 to before 3.4.3 Fixed in 3.4.3 Patch available GHSA-52m2-vc4m-jj33
CPE configurations NVD · 7
| CPE | Versions | Role | Vendor |
|---|---|---|---|
| cpe:2.3:a:symfony:twig:*:*:*:*:*:*:*:* | 1.0.0 to before 1.44.7; 2.0.0 to before 2.15.3; 3.0.0 to before 3.4.3 | Vulnerable | symfony |
| cpe:2.3:a:drupal:drupal:*:*:*:*:*:*:*:* | 8.0.0 to before 9.3.22; 9.4.0 to before 9.4.7 | Vulnerable | Drupal |
| cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:* | 35 | Vulnerable | Fedoraproject |
| cpe:2.3:o:fedoraproject:fedora:36:*:*:*:*:*:*:* | 36 | Vulnerable | Fedoraproject |
| cpe:2.3:o:fedoraproject:fedora:37:*:*:*:*:*:*:* | 37 | Vulnerable | Fedoraproject |
| cpe:2.3:o:debian:debian_linux:10.0:*:*:*:*:*:*:* | 10.0 | Vulnerable | Debian |
| cpe:2.3:o:debian:debian_linux:11.0:*:*:*:*:*:*:* | 11.0 | Vulnerable | Debian |
- cpe:2.3:a:symfony:twig:*:*:*:*:*:*:*:* Versions 1.0.0 to before 1.44.7; 2.0.0 to before 2.15.3; 3.0.0 to before 3.4.3 Vulnerable ·symfony
- cpe:2.3:a:drupal:drupal:*:*:*:*:*:*:*:* Versions 8.0.0 to before 9.3.22; 9.4.0 to before 9.4.7 Vulnerable ·Drupal
- cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:* Versions 35 Vulnerable ·Fedoraproject
- cpe:2.3:o:fedoraproject:fedora:36:*:*:*:*:*:*:* Versions 36 Vulnerable ·Fedoraproject
- cpe:2.3:o:fedoraproject:fedora:37:*:*:*:*:*:*:* Versions 37 Vulnerable ·Fedoraproject
- cpe:2.3:o:debian:debian_linux:10.0:*:*:*:*:*:*:* Versions 10.0 Vulnerable ·Debian
- cpe:2.3:o:debian:debian_linux:11.0:*:*:*:*:*:*:* Versions 11.0 Vulnerable ·Debian
Remediation
- Fix · CNA Twig (twigphp) Fixed in 2.15.3, 3.4.3
- Fix · GHSA-52m2-vc4m-jj33 twig/twig (Packagist) Fixed in 1.44.7 Advisory →
- Fix · GHSA-52m2-vc4m-jj33 twig/twig (Packagist) Fixed in 2.15.3 Advisory →
- Fix · GHSA-52m2-vc4m-jj33 twig/twig (Packagist) Fixed in 3.4.3 Advisory →
Vendor assessments
Timeline
- 2026-10-02 Threatist record created from CVE-2022-39261
- 2026-10-03 Alias added: GHSA-52m2-vc4m-jj33
References
Patch 2
Advisory 10
- https://github.com/twigphp/Twig/security/advisories/GHSA-52m2-vc4m-jj33
- DSA-5248
- FEDORA-2022-4490a4772d
- FEDORA-2022-d39b2a755b
- FEDORA-2022-1695454935
- FEDORA-2022-9d8ee4a6de
- [debian-lts-announce] 20221011 [SECURITY] [DLA 3147-1] twig security update
- FEDORA-2022-c6fe3ebd94
- FEDORA-2022-73b9fb7a77
- https://nvd.nist.gov/vuln/detail/CVE-2022-39261
Other 9
- https://github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2022-39261.yaml
- https://github.com/twigphp/Twig
- https://lists.fedoraproject.org/archives/list/[email protected]/message/2OKRUHPVLIQVFPPJ2UWC3WV3WQO763NR
- https://lists.fedoraproject.org/archives/list/[email protected]/message/AUVTXMNPSZAHS3DWZEM56V5W4NPVR6L7
- https://lists.fedoraproject.org/archives/list/[email protected]/message/NWRFPZSR74SYVJKBTKTMYUK36IJ3SQJP
- https://lists.fedoraproject.org/archives/list/[email protected]/message/TW53TFJ6WWNXMUHOFACKATJTS7NIHVQE
- https://lists.fedoraproject.org/archives/list/[email protected]/message/WV5TNNJLGG536TJH6DLCIAAZZIPV2GUD
- https://lists.fedoraproject.org/archives/list/[email protected]/message/YU4ZYX62H2NUAKKGUES4RZIM4KMTKZ7F
- https://symfony.com/blog/twig-security-release-possibility-to-load-a-template-outside-a-configured-directory-when-using-the-filesystem-loader
More symfony Twig vulnerabilities
- TI-2026-34283 Twig: The `spaceless` filter implicitly marks its output as safe CVSS 4.0MEDIUM 5.1
- TI-2022-07667 Code injection in Twig CVSS 3.1CRITICAL 9.8
- TI-2018-10028 Twig before 2.4.4 allows Server-Side Template Injection (SSTI) via the search search_key… CVSS 3.0CRITICAL 9.8
- TI-2026-34292 Twig: Arbitrary PHP code execution via `_self.(<string>)` macro-reference compilation CVSS 4.0HIGH 8.7
- TI-2026-34285 Twig: PHP code injection via `{% use %}` template name CVSS 4.0HIGH 8.7
- TI-2026-19691 Twig 2.16.x & 3.9.0-3.25.x Sandbox Bypass via SourcePolicyInterface CVSS 4.0HIGH 8.7
Sources
- CVE-2022-39261 · CVE Program
- CVE-2022-39261 · NVD
- FIRST EPSS
- GHSA-52m2-vc4m-jj33 · GitHub Advisory Database · CC BY 4.0
- CVE-2022-39261 · Red Hat security data · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences