CVE-2022-39261:
Twig may load a template outside a configured directory when using the filesystem loader
7.5
CVSS Score
3.1
Basic Information
CVE ID
GHSA ID
EPSS Score
0.79021%
CWE
Published
9/30/2022
Updated
1/27/2023
KEV Status
No
Technology
PHP
Technical Details
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
---|---|---|---|
twig/twig | composer | >= 1.0.0, < 1.44.7 | 1.44.7 |
twig/twig | composer | >= 2.0.0, < 2.15.3 | 2.15.3 |
twig/twig | composer | >= 3.0.0, < 3.4.3 | 3.4.3 |
Vulnerability Intelligence
Miggo AI
Root Cause Analysis
The vulnerability stemmed from improper validation
order in the filesystem loader. The commit diff shows that validateName()
was called on the full $name before parsing it into namespace/shortname
. This allowed malicious namespaces like '@somewhere/../' to bypass validation
. The fix moved validation
to $shortname after parsing, proving the original function's validation
logic was flawed. The FilesystemLoader::findTemplate
method is directly implicated in the security advisory's description of namespace
-based path traversal.