Description
Twig is an open source template language for PHP. 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. In affected versions this constraint was not properly enforced and could lead to code injection of arbitrary PHP code. Patched versions now disallow calling non Closure in the `sort` filter as is the case for some other filters. Users are advised to upgrade.
Affected products
| Vendor | Product | Affected | Fixed |
|---|---|---|---|
| twigphp | Twig | >= 3.0.0, < 3.3.8, >= 2.0.0, < 2.14.11 | — |
Fixed in Linux distributions
Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.
Debian
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Debian 14 | php-twig | 3.3.8-1 | — |
| Debian 13 | php-twig | 3.3.8-1 | — |
| Debian 12 | php-twig | 3.3.8-1 | — |
| Debian 11 | php-twig | 2.14.3-1+deb11u1 | DSA-5107-1 |
Ubuntu
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Ubuntu Pro 22.04 LTS | php-twig | 3.3.8-2ubuntu4+esm1 | USN-5947-1 |
| Ubuntu Pro 20.04 LTS | php-twig | 2.12.5-1ubuntu0.1~esm1 | USN-5947-1 |
| Ubuntu Pro 18.04 LTS | twig | 2.4.6-1ubuntu0.1~esm1 | USN-5947-1 |
Show 1 more (older releases, extended support, other products)Fewer releases
| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Ubuntu Pro 16.04 LTS | twig | 1.23.1-1ubuntu4+esm1 | USN-5947-1 |
Public exploits
Exploit or proof-of-concept code for this vulnerability is publicly available, which lowers the bar for attackers. Treat it as a reason to patch sooner.
GitHub 2 repositories
-
davwwwx/CVE-2022-23614 ★ 4 · Jul 18, 2022
PoC for CVE-2022-23614 (Twig sort filter code execution/sandbox bypass)
-
4rtamis/CVE-2022-23614 ★ 0 · Jul 4, 2023
Proof of concept for CVE-2022-23614 (command injection in Twig)
Sources: PoC-in-GitHub, Metasploit Framework, Exploit-DB — updated daily. Only links are listed; no exploit code is hosted here.
Affected packages
| Ecosystem | Package | Affected | Fixed | Record |
|---|---|---|---|---|
| Packagist | twig/twig | >= 2.0.0, < 2.14.11 | 2.14.11 | GHSA-5mv2-rx3q-4w2v |
| Packagist | twig/twig | >= 3.0.0, < 3.3.8 | 3.3.8 | GHSA-5mv2-rx3q-4w2v |
Advisories 2
- USN-5947-1 php-twig, twig vulnerabilities Ubuntu Security Notices (USN) · Jun 25, 2026
- DSA-5107-1 php-twig - security update Debian Security (DSA / DLA) · Mar 9, 2026
References
- https://github.com/twigphp/Twig/security/advisories/GHSA-5mv2-rx3q-4w2v
- https://github.com/twigphp/Twig/commit/22b9dc3c03ee66d7e21d9ed2ca76052b134cb9e9
- https://github.com/twigphp/Twig/commit/2eb33080558611201b55079d07ac88f207b466d5
- FEDORA-2022-167b9becef vendor-advisory
- FEDORA-2022-47293b1d23 vendor-advisory
- FEDORA-2022-7d871d7583 vendor-advisory
- FEDORA-2022-58abb323f0 vendor-advisory
- DSA-5107 vendor-advisory