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.

Severity (CVSS 3.1)7.5High
Exploit odds (30 days)3.2%top 11.9% of all CVEs
Exploited in the wildNo reportsCISA SSVC: none
Attack toolingNoneno public tooling known

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

EcosystemPackageFixed inAdvisory
Debian:12php-twig3.4.3-1DEBIAN-CVE-2022-39261
Debian:13php-twig3.4.3-1DEBIAN-CVE-2022-39261
Debian:14php-twig3.4.3-1DEBIAN-CVE-2022-39261
Packagistdrupal/core9.3.22, 9.4.7DRUPAL-CORE-2022-016
Packagisttwig/twig3.4.3GHSA-52m2-vc4m-jj33
Packagisttwig/twig1.44.7GHSA-52m2-vc4m-jj33
Packagisttwig/twig2.15.3GHSA-52m2-vc4m-jj33

Affected products (as reported)

VendorProductVersions
twigphp Twig => 1.0.0, < 1.44.7>= 2.0.0, < 2.15.3>= 3.0.0, < 3.4.3

Weakness: CWE-22 · Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N

References