CVE-2022-39261 json
Twig may load a template outside a configured directory when using the filesystem loader
published 4y ago modified last mo. also BIT-drupal-2022-39261 , DRUPAL-CORE-2022-016 , EUVD-2022-6700 , GHSA-52m2-vc4m-jj33
- cvss
- 7.5
- version 3.1, CNA
- cisa kev
- Not listed
- not in CISA's catalog
- epss
- 3.2%
- EPSS 3.2% chance of exploitation in 30 days, percentile 88%
- public exploits
- 0
- none known
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.
Patch / fix
- packagist twig/twig 1.44.7, 2.15.3, 3.4.3
- bitnami drupal 9.3.22, 9.4.7
- packagist drupal/core 9.3.22, 9.4.7
- symfony twig 1.44.7, 2.15.3, 3.4.3
- drupal drupal 9.3.22, 9.4.7
- php-twig Debian 14, Debian 13, Debian 12 3.4.3-1
debian advisories DEBIAN-CVE-2022-39261
- twig Ubuntu Pro 16.04 LTS 1.23.1-1ubuntu4+esm1
- twig Ubuntu Pro 18.04 LTS 2.4.6-1ubuntu0.1~esm1
- php-twig Ubuntu Pro 20.04 LTS 2.12.5-1ubuntu0.1~esm1
- php-twig Ubuntu Pro 22.04 LTS 3.3.8-2ubuntu4+esm1
ubuntu advisories UBUNTU-CVE-2022-39261
Ubuntu security data © Canonical Ltd., from https://github.com/canonical/ubuntu-security-notices via OSV; changed: normalised to fixed package versions per release. CC BY-SA 4.0
- github.com/twigphp/Twig@35f3035 commit
- drupal.org/sa-core-2022-016 advisory
Is CVE-2022-39261 in your dependencies? Fencer shows which of your repositories are affected as soon as an advisory lands, and opens the fix as a pull request.
Check with FencerVendor advisories
What the vendors themselves say about their products: affected, fixed or not affected, and what to do.
red hat product security vex CVE-2022-39261 updated cvss 7.5
twig: Possibility to load a template outside a configured directory when using the filesystem loader
-
Red Hat All currently supported Red Hat productsnot affected: vulnerable code not present
Red Hat CSAF VEX © Red Hat, Inc., from https://security.access.redhat.com/data/csaf/v2/vex/; changed: reduced to product statuses and remediations. CC BY 4.0 · csaf
CISA SSVC
- Exploitation
- none
- Automatable
- yes
- Technical impact
- partial
- Assessed
- last yr.
Exploit prediction
3.17% chance of exploitation in the next 30 days, higher than 88% of all scored CVEs (FIRST EPSS, 2026-11-09).
CVSS scores
| assigned by | version | score | vector |
|---|---|---|---|
| CNA | 3.1 | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N |
| GitHub | 3.1 | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N |
| NVD | 3.1 | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N |
| OSV | 3.1 | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N |
Affected packages
| ecosystem | package | affected | fixed in |
|---|---|---|---|
| packagist | twig/twig | >=1.0.0, <1.44.7 >=2.0.0, <2.15.3 >=3.0.0, <3.4.3 |
1.44.7 2.15.3 3.4.3 |
| bitnami | drupal | >=8.0.0, <9.3.22 >=9.4.0, <9.4.7 |
9.3.22 9.4.7 |
| packagist | drupal/core | >=8.0.0, <9.3.22 >=9.4.0, <9.4.7 |
9.3.22 9.4.7 |
Affected products
- twigphp Twig
Classification
- Weakness
-
- CWE-22 Improper Limitation of a Pathname to a Restricted Directory
References
-
github.com
/twigphp/Twig/commit/35f3035c5deb0041da7b84daf02dea074ddc7a0b
web, patch, third-party-advisory, advisory
-
drupal.org
/sa-core-2022-016
web, patch, third-party-advisory, advisory
-
debian.org
/security/2022/dsa-5248
vendor-advisory, web, third-party-advisory, advisory
-
lists.fedoraproject.org
/archives/list/package-announce%40lists.fedoraproject.org/message/AUVTXMNPSZAHS3DWZEM56V5W4NPVR6L7/
vendor-advisory, web
-
lists.fedoraproject.org
/archives/list/package-announce%40lists.fedoraproject.org/message/2OKRUHPVLIQVFPPJ2UWC3WV3WQO763NR/
vendor-advisory, web
-
lists.fedoraproject.org
/archives/list/package-announce%40lists.fedoraproject.org/message/YU4ZYX62H2NUAKKGUES4RZIM4KMTKZ7F/
vendor-advisory, web
-
lists.fedoraproject.org
/archives/list/package-announce%40lists.fedoraproject.org/message/NWRFPZSR74SYVJKBTKTMYUK36IJ3SQJP/
vendor-advisory, web
-
lists.fedoraproject.org
/archives/list/package-announce%40lists.fedoraproject.org/message/TW53TFJ6WWNXMUHOFACKATJTS7NIHVQE/
vendor-advisory, web
-
lists.fedoraproject.org
/archives/list/package-announce%40lists.fedoraproject.org/message/WV5TNNJLGG536TJH6DLCIAAZZIPV2GUD/
vendor-advisory, web
-
github.com
/twigphp/Twig/security/advisories/GHSA-52m2-vc4m-jj33
web, third-party-advisory, advisory
-
lists.debian.org
/debian-lts-announce/2022/10/msg00016.html
mailing-list, web, third-party-advisory, advisory
-
nvd.nist.gov
/vuln/detail/CVE-2022-39261
advisory, web
-
github.com
/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2022-39261.yaml
web
-
github.com
/twigphp/Twig
package
-
lists.fedoraproject.org
/archives/list/package-announce@lists.fedoraproject.org/message/2OKRUHPVLIQVFPPJ2UWC3WV3WQO763NR
web
-
lists.fedoraproject.org
/archives/list/package-announce@lists.fedoraproject.org/message/AUVTXMNPSZAHS3DWZEM56V5W4NPVR6L7
web
-
lists.fedoraproject.org
/archives/list/package-announce@lists.fedoraproject.org/message/NWRFPZSR74SYVJKBTKTMYUK36IJ3SQJP
web
-
lists.fedoraproject.org
/archives/list/package-announce@lists.fedoraproject.org/message/TW53TFJ6WWNXMUHOFACKATJTS7NIHVQE
web
-
lists.fedoraproject.org
/archives/list/package-announce@lists.fedoraproject.org/message/WV5TNNJLGG536TJH6DLCIAAZZIPV2GUD
web
-
lists.fedoraproject.org
/archives/list/package-announce@lists.fedoraproject.org/message/YU4ZYX62H2NUAKKGUES4RZIM4KMTKZ7F
web
-
symfony.com
/blog/twig-security-release-possibility-to-load-a-template-outside-a-configured-directory-when-using-the-files
web
Sources
- CVE List CVE-2022-39261
- GitHub Advisory GHSA-52m2-vc4m-jj33
- NVD CVE-2022-39261
- OSV BIT-drupal-2022-39261
- OSV DRUPAL-CORE-2022-016
Fencer Intel keeps one entry per vulnerability: the CVE id wins, then GHSA, and records that alias each other are merged, except that two CVEs always keep separate entries. The same data is available as JSON.