{"id":"CVE-2022-39261","published":"2022-09-28T00:00:00Z","modified":"2025-04-23T16:54:59Z","title":"Twig may load a template outside a configured directory when using the filesystem loader","vendor":"twigphp","product":"Twig","tier":"tail","description":{"text":"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.","provenance":"source","from":"CVE.org"},"cvss":{"score":7.5,"severity":"HIGH","version":"3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.03242,"percentile":0.88621,"provenance":"source"},"cwes":[{"id":"CWE-22","name":"Improper Limitation of a Pathname to a Restricted Directory"}],"references":[{"url":"https://github.com/twigphp/Twig/security/advisories/GHSA-52m2-vc4m-jj33","tags":[]},{"url":"https://github.com/twigphp/Twig/commit/35f3035c5deb0041da7b84daf02dea074ddc7a0b","tags":[]},{"url":"https://www.drupal.org/sa-core-2022-016","tags":[]},{"url":"https://www.debian.org/security/2022/dsa-5248","tags":["vendor-advisory"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/AUVTXMNPSZAHS3DWZEM56V5W4NPVR6L7/","tags":["vendor-advisory"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/2OKRUHPVLIQVFPPJ2UWC3WV3WQO763NR/","tags":["vendor-advisory"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/YU4ZYX62H2NUAKKGUES4RZIM4KMTKZ7F/","tags":["vendor-advisory"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/NWRFPZSR74SYVJKBTKTMYUK36IJ3SQJP/","tags":["vendor-advisory"]},{"url":"https://lists.debian.org/debian-lts-announce/2022/10/msg00016.html","tags":["mailing-list"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/TW53TFJ6WWNXMUHOFACKATJTS7NIHVQE/","tags":["vendor-advisory"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/WV5TNNJLGG536TJH6DLCIAAZZIPV2GUD/","tags":["vendor-advisory"]}],"priority":{"score":23.0,"factors":[{"name":"EPSS percentile","points":17.72},{"name":"CVSS severity","points":5.25}]},"vendorSlug":"twigphp","affectedVersions":[{"vendor":"twigphp","product":"Twig","versions":["=> 1.0.0, < 1.44.7",">= 2.0.0, < 2.15.3",">= 3.0.0, < 3.4.3"]}],"ssvc":{"exploitation":"none","automatable":"yes","technicalImpact":"partial","timestamp":"2025-04-23T15:50:56.522548Z","from":"CISA ADP","provenance":"source"},"affected":[{"ecosystem":"Packagist","package":"twig/twig","vulnerableRanges":[">=1.0.0, <1.44.7",">=2.0.0, <2.15.3",">=3.0.0, <3.4.3"],"patched":["1.44.7","2.15.3","3.4.3"],"from":["GHSA-52m2-vc4m-jj33"],"provenance":"source"},{"ecosystem":"Packagist","package":"drupal/core","vulnerableRanges":[">=8.0.0, <9.3.22",">=9.4.0, <9.4.7"],"patched":["9.3.22","9.4.7"],"from":["DRUPAL-CORE-2022-016"],"provenance":"source"}],"summary":{"text":"Twig, a PHP template language, has a path traversal flaw in its filesystem loader that affects 1.x before 1.44.7, 2.x before 2.15.3, and 3.x before 3.4.3, where user-supplied template names are not properly validated. An unauthenticated remote attacker can exploit this over the network without user interaction, using the source or include statement with a namespaced name such as @somewhere/../some.file to read arbitrary files outside the templates directory.","provenance":"ai","model":"claude-haiku-5-5","generatedAt":"2026-11-20T06:40:51Z"},"euvd":{"id":"EUVD-2022-6700","exploited":false,"provenance":"source"},"lineage":{"packageHistory":[{"cve":"CVE-2015-7809","published":"2015-11-06","fixed":"1.20.0","kev":false},{"cve":"CVE-2019-9942","published":"2019-03-23","fixed":"2.7.0","kev":false},{"cve":"CVE-2022-23614","published":"2022-02-04","fixed":"3.3.8","kev":false,"link":{"from":"CVE-2022-23614","to":"CVE-2022-39261","relation":"successor","confidence":"low","kind":"sequence","evidence":[{"kind":"version-step","provenance":"source","package":"Packagist:twig/twig","fromFixed":"2.14.11","toFixed":"2.15.3","daysApart":236},{"kind":"version-step","provenance":"source","package":"Packagist:twig/twig","fromFixed":"3.3.8","toFixed":"3.4.3","daysApart":236}]}},{"cve":"CVE-2022-39261","published":"2022-09-28","fixed":"3.4.3","kev":false},{"cve":"CVE-2024-45411","published":"2024-09-09","fixed":"3.14.0","kev":false,"link":{"from":"CVE-2022-39261","to":"CVE-2024-45411","relation":"successor","confidence":"low","kind":"sequence","evidence":[{"kind":"version-step","provenance":"source","package":"Packagist:twig/twig","fromFixed":"1.44.7","toFixed":"1.44.8","daysApart":712},{"kind":"version-step","provenance":"source","package":"Packagist:twig/twig","fromFixed":"2.15.3","toFixed":"2.16.1","daysApart":712}]}},{"cve":"CVE-2024-51754","published":"2024-11-06","fixed":"3.14.1","kev":false},{"cve":"CVE-2024-51755","published":"2024-11-06","fixed":"3.14.1","kev":false}],"package":"Packagist:twig/twig"}}