HighGHSA-5mv2-rx3q-4w2vCVE-2022-23614
Code injection in Twig
Published 10 Feb 2022 · Updated 16 Feb 2024
Is your project on an affected twig/twig?
Affected packages
twig/twigComposer
- Affected
- >=2.0.0 <2.14.11
- Fixed in
- 2.14.11
Update to the fixed version for your release line, for example:
composer require twig/twig:^2.14.11twig/twigComposer
- Affected
- >=3.0.0 <3.3.8
- Fixed in
- 3.3.8
Update to the fixed version for your release line, for example:
composer require twig/twig:^3.3.8Details
Description
When 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.
Resolution
We now disallow calling non Closure in the sort filter like we already did for some other filters.
Credits
We would like to thank Marlon Starkloff for reporting the issue and Fabien Potencier for fixing the issue.
Is GHSA-5mv2-rx3q-4w2v in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected twig/twig, and gives you the command that fixes it.
More advisories for twig/twig
- HighCVE-2026-49981Twig: Sandbox filter, tag and function allow-list bypass when sandbox state changes between renders for a cached `Template` · 1 Jul 2026
- MediumCVE-2026-48808Twig: Sandbox property allowlist bypass via the `column` filter under `SourcePolicyInterface` · 30 Jun 2026
- MediumCVE-2026-48807Twig: Sandbox `__toString()` policy bypass via `Traversable` in `join` and `replace` filters · 30 Jun 2026
- MediumCVE-2026-48806Twig: Sandbox `__toString()` policy bypass via dynamic mapping keys · 30 Jun 2026
- LowCVE-2026-48805Twig: Sandbox state regression in deprecated internal wrappers in `src/Resources/core.php` · 30 Jun 2026
- HighCVE-2026-47732Twig: Sandbox: multiple `__toString()` policy bypasses via unguarded string coercion points · 5 Jun 2026
References
- Linkgithub.com/twigphp/Twig/security/advisories/GHSA-5mv2-rx3q-4w2v
- Advisorynvd.nist.gov/vuln/detail/CVE-2022-23614
- Linkgithub.com/twigphp/Twig/commit/22b9dc3c03ee66d7e21d9ed2ca76052b134cb9e9
- Linkgithub.com/twigphp/Twig/commit/2eb33080558611201b55079d07ac88f207b466d5
- Linkgithub.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2022-23614.yaml
- Linkgithub.com/twigphp/Twig
- Linklists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/I2PVV5DUTRUECTIHMTWRI5Z7DVNYQ2YO
- Linklists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/OTN4273U4RHVIXED64T7DSMJ3VYTPRE7
- Linklists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/PECHIY2XLWUH2WLCNPDGNFMPHPRPCEDZ
- Linklists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/SIGZCFSYLPP7UVJ4E4NLHSOQSKYNXSAD
- Linksymfony.com/blog/twig-security-release-disallow-non-closures-in-the-sort-filter
- Linkwww.debian.org/security/2022/dsa-5107
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.