GHSA-7cvr-xhm5-x998: Twig/twig Path Traversal Vulnerability
MODERATEGHSA-7cvr-xhm5-x998 is a MODERATE (CVSS 5.3) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Twig/twig libraries in the Packagist ecosystem. The issue involves twig path traversal vulnerability in the filesystem loader. Remediation is available by upgrading affected packages to version 1.12.3.
GHSA-7cvr-xhm5-x998 at a Glance
Security Impact
CVSS: 5.3
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N).
How to Fix GHSA-7cvr-xhm5-x998
To remediate this vulnerability, upgrade all affected Twig/twig dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade twig/twig to 1.12.3
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for twig/twig
How to Check if You Are Affected
To determine whether your application is affected by GHSA-7cvr-xhm5-x998, inspect your project dependencies for Twig/twig:
inspect dependencies for twig/twig
Analyze the terminal output to locate any version of Twig/twig in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.12.3), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Twig/twig, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
GHSA-7cvr-xhm5-x998 Affected Twig/twig Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
twig/twig
|
Packagist |
≥ 1.0.0
< 1.12.3
|
1.12.3
|
References
Frequently Asked Questions
What is GHSA-7cvr-xhm5-x998?
Which Twig/twig versions are affected?
What version fixes GHSA-7cvr-xhm5-x998?
Is twig/twig affected?
What is the CVSS score of GHSA-7cvr-xhm5-x998?
What CWE is associated with GHSA-7cvr-xhm5-x998?
How can I check Packagist dependencies for GHSA-7cvr-xhm5-x998?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-7cvr-xhm5-x998",
"modified" : "2024-05-30T13:42:49Z",
"published" : "2024-05-30T13:42:49Z",
"aliases" : [ ],
"summary" : "Twig Path Traversal vulnerability in the filesystem loader",
"details" : "Twig is affected by path traversal vulnerability when used with Twig_Loader_Filesystem for loading Twig templates but only if the application is using non-trusted template names (names provided by a end-user for instance).\n\nWhen affected, it is possible to go up one directory for the paths configured in the application's loader.\n\nFor instance, if the filesystem loader is configured with /path/to/templates as a path to look for templates, an attacker can force Twig to include a file stored in /path/to by prepending the path with /../ like in {% include \"/../somefile_in_path_to\" %}\n\nNote that using anything else (like ../somefile, /../../somefile, or ../../somefile) won’t work and the application will return a proper exception.\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Packagist",
"name" : "twig/twig"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "1.0.0"
}, {
"fixed" : "1.12.3"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/fabpot/Twig/commit/3d19a2eed53570776af313593aaeb5ad62cf4980.diff"
}, {
"type" : "WEB",
"url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/2013-04-08.yaml"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/twigphp/Twig"
}, {
"type" : "WEB",
"url" : "https://web.archive.org/web/20130511111630/http://blog.twig.sensiolabs.org/post/47461911874/security-release-twig-1-12-3-released"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2024-05-30T13:42:49Z",
"nvd_published_at" : null
}
}