CVEfocus › CVE database › CVE-2022-39261

CVE-2022-39261Twig may load a template outside a configured directory when using the filesystem loader

CVSS 7.5 HighEPSS 3.2% (higher than 89% of CVEs)Published 2022-09-28Updated 2025-04-23Assigner: GitHub_M

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.

CWE-22

What to do

Fixed builds are available from Debian, Packagist: see the table below for the fixed version per release.

Ubuntu has not shipped a fix for every release yet.

Is your server affected? One read-only command checks every installed package against this CVE and all others, using each vendor's fixed versions. Get started or get a free API key.

curl -sS "https://api.cvefocus.com/v1/check?format=text" -H "Authorization: Bearer $CVEFOCUS_KEY" \
  -H "Content-Type: text/plain" --data-binary @inventory.txt

Vendor status at a glance

4Fixed
4Fix pending
1Not affected

Status by vendor and release

From each vendor's own security data and VEX statements. "Fixed" means a fixed build is published for that release.

ReleasePackageStatusFixed versionAdvisory
Ubuntu 25.10php-twigNot affected
vulnerable_code_not_present
Ubuntu 22.04php-twigFix pending3.3.8-2ubuntu4+esm1 (Ubuntu Pro)UBUNTU-CVE-2022-39261
Ubuntu 20.04php-twigFix pending2.12.5-1ubuntu0.1~esm1 (Ubuntu Pro)UBUNTU-CVE-2022-39261
Ubuntu 18.04twigFix pending2.4.6-1ubuntu0.1~esm1 (Ubuntu Pro)UBUNTU-CVE-2022-39261
Ubuntu 16.04twigFix pending1.23.1-1ubuntu4+esm1 (Ubuntu Pro)UBUNTU-CVE-2022-39261
Debian 14php-twigFixed3.4.3-1DEBIAN-CVE-2022-39261
Debian 13php-twigFixed3.4.3-1DEBIAN-CVE-2022-39261
Debian 12php-twigFixed3.4.3-1DEBIAN-CVE-2022-39261
Packagist librarytwig/twigFixed3.4.3GHSA-52m2-vc4m-jj33

What the vendor says

As published in the CVE record by GitHub_M, the CVE's assigner (usually the vendor). Check the vendor's advisory before acting.

Vendor advisories:

References

About this page

Compiled by CVEfocus from the CVE List, the security data and VEX statements of Ubuntu, Debian, Red Hat, AlmaLinux, Rocky Linux and Microsoft, CISA's Known Exploited Vulnerabilities catalog and FIRST EPSS, refreshed several times a day (data status). Information only; see the disclaimer. Official record: cve.org · NVD.