Skip to content
OpenAdvisories
High · 7.5 CVE-2022-39261 BIT-drupal-2022-39261DRUPAL-CORE-2022-016EUVD-2022-6700GHSA-52m2-vc4m-jj33

Twig may load a template outside a configured directory when using the filesystem loader

Published Sep 28, 2022 · Updated Apr 23, 2025 · Assigned by GitHub_M

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 products

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

Fixed in Linux distributions

Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.

ReleasePackageFixed inAdvisory
Debian 14 php-twig 3.4.3-1 —
Debian 13 php-twig 3.4.3-1 —
Debian 12 php-twig 3.4.3-1 —
Debian 11 php-twig 2.14.3-1+deb11u2 DSA-5248-1
Debian 10 twig 2.6.2-2+deb10u1 DLA-3147-1
ReleasePackageFixed inAdvisory
Ubuntu Pro 22.04 LTS php-twig 3.3.8-2ubuntu4+esm1 USN-5947-1
Ubuntu Pro 20.04 LTS php-twig 2.12.5-1ubuntu0.1~esm1 USN-5947-1
Ubuntu Pro 18.04 LTS twig 2.4.6-1ubuntu0.1~esm1 USN-5947-1
Show 1 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
Ubuntu Pro 16.04 LTS twig 1.23.1-1ubuntu4+esm1 USN-5947-1

Affected packages

EcosystemPackageAffectedFixedRecord
Packagist drupal/core >= 8.0.0, < 9.3.22 · >= 9.4.0, < 9.4.7 9.3.22, 9.4.7 DRUPAL-CORE-2022-016
Packagist twig/twig >= 1.0.0, < 1.44.7 1.44.7 GHSA-52m2-vc4m-jj33
Packagist twig/twig >= 2.0.0, < 2.15.3 2.15.3 GHSA-52m2-vc4m-jj33
Packagist twig/twig >= 3.0.0, < 3.4.3 3.4.3 GHSA-52m2-vc4m-jj33

Advisories 3

References