CVE-2022-23614: Twig/twig Code Injection Vulnerability
HIGHCVE-2022-23614 is a HIGH (CVSS 8.8) code injection vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Twig/twig libraries in the Packagist ecosystem. The issue involves code injection in twig. Remediation is available by upgrading affected packages to version 2.14.11, 3.3.8.
CVE-2022-23614 at a Glance
Security Impact
CVSS: 8.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H).
How to Fix CVE-2022-23614
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 2.14.11
Upgrade twig/twig to 3.3.8
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 CVE-2022-23614, 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 2.14.11), 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-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. 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
CVE-2022-23614 Affected Twig/twig Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
twig/twig
|
Packagist |
≥ 2.0.0
< 2.14.11
|
2.14.11
|
|
twig/twig
|
Packagist |
≥ 3.0.0
< 3.3.8
|
3.3.8
|
References
Frequently Asked Questions
What is CVE-2022-23614?
Which Twig/twig versions are affected?
What version fixes CVE-2022-23614?
Is twig/twig affected?
What is the CVSS score of CVE-2022-23614?
What CWE is associated with CVE-2022-23614?
How can I check Packagist dependencies for CVE-2022-23614?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-5mv2-rx3q-4w2v",
"modified" : "2022-02-11T19:16:32Z",
"published" : "2022-02-10T22:21:48Z",
"aliases" : [ "CVE-2022-23614" ],
"summary" : "Code injection in Twig",
"details" : "# Description\n\nWhen in a sandbox mode, the `arrow` parameter of the `sort` filter must be a closure to avoid attackers being able to run arbitrary PHP functions.\n\n# Resolution\n\nWe now disallow calling non Closure in the `sort` filter like we already did for some other filters.\n\n# Credits\n\nWe would like to thank Marlon Starkloff for reporting the issue and Fabien Potencier for fixing the issue.\n ",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Packagist",
"name" : "twig/twig"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.0.0"
}, {
"fixed" : "2.14.11"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Packagist",
"name" : "twig/twig"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "3.0.0"
}, {
"fixed" : "3.3.8"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/twigphp/Twig/security/advisories/GHSA-5mv2-rx3q-4w2v"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-23614"
}, {
"type" : "WEB",
"url" : "https://github.com/twigphp/Twig/commit/22b9dc3c03ee66d7e21d9ed2ca76052b134cb9e9"
}, {
"type" : "WEB",
"url" : "https://github.com/twigphp/Twig/commit/2eb33080558611201b55079d07ac88f207b466d5"
}, {
"type" : "WEB",
"url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2022-23614.yaml"
}, {
"type" : "WEB",
"url" : "https://github.com/twigphp/Twig"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/I2PVV5DUTRUECTIHMTWRI5Z7DVNYQ2YO"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/OTN4273U4RHVIXED64T7DSMJ3VYTPRE7"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/PECHIY2XLWUH2WLCNPDGNFMPHPRPCEDZ"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/SIGZCFSYLPP7UVJ4E4NLHSOQSKYNXSAD"
}, {
"type" : "WEB",
"url" : "https://symfony.com/blog/twig-security-release-disallow-non-closures-in-the-sort-filter"
}, {
"type" : "WEB",
"url" : "https://www.debian.org/security/2022/dsa-5107"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-74", "CWE-94" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2022-02-07T16:43:09Z",
"nvd_published_at" : "2022-02-04T23:15:00Z"
}
}