Code injection in Twig
Key facts
- Attack vector
- Network
- Privileges required
- None
- User interaction
- None
- Attack complexity
- Low
- Impact type
- Code execution
- Confidentiality · integrity · availability
- High · High · High
- Fix status
- Fixed
Attack profile from CVSS 3.1 · NVD. Fix status from CNA and GitHub. Impact type from CWE-94.
Summary
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.
Why it matters now
SSVC decision points
CISA ADP · SSVC 2.0.3
- Exploitation
- None
- Automatable
- No
- Technical impact
- Total
The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| symfony | Twig | 3.0.0 to before 3.3.8; 2.0.0 to before 2.14.11 | 3.3.8, 2.14.11 | Patch available | CNA |
| — | twig/twig (Packagist) | 2.0.0 to before 2.14.11 | 2.14.11 | Patch available | GHSA-5mv2-rx3q-4w2v |
| — | twig/twig (Packagist) | 3.0.0 to before 3.3.8 | 3.3.8 | Patch available | GHSA-5mv2-rx3q-4w2v |
- Twig Vendorsymfony Affected 3.0.0 to before 3.3.8; 2.0.0 to before 2.14.11 Fixed in 3.3.8, 2.14.11 Patch available CNA
- twig/twig (Packagist) Vendor— Affected 2.0.0 to before 2.14.11 Fixed in 2.14.11 Patch available GHSA-5mv2-rx3q-4w2v
- twig/twig (Packagist) Vendor— Affected 3.0.0 to before 3.3.8 Fixed in 3.3.8 Patch available GHSA-5mv2-rx3q-4w2v
CPE configurations NVD · 4
| CPE | Versions | Role | Vendor |
|---|---|---|---|
| cpe:2.3:a:symfony:twig:*:*:*:*:*:*:*:* | 2.0.0 to before 2.14.11; 3.0.0 to before 3.3.8 | Vulnerable | symfony |
| cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:* | 34 | Vulnerable | Fedoraproject |
| cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:* | 35 | Vulnerable | Fedoraproject |
| cpe:2.3:o:debian:debian_linux:11.0:*:*:*:*:*:*:* | 11.0 | Vulnerable | Debian |
- cpe:2.3:a:symfony:twig:*:*:*:*:*:*:*:* Versions 2.0.0 to before 2.14.11; 3.0.0 to before 3.3.8 Vulnerable ·symfony
- cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:* Versions 34 Vulnerable ·Fedoraproject
- cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:* Versions 35 Vulnerable ·Fedoraproject
- cpe:2.3:o:debian:debian_linux:11.0:*:*:*:*:*:*:* Versions 11.0 Vulnerable ·Debian
Remediation
- Fix · CNA Twig (twigphp) Fixed in 3.3.8, 2.14.11
- Fix · GHSA-5mv2-rx3q-4w2v twig/twig (Packagist) Fixed in 2.14.11 Advisory →
- Fix · GHSA-5mv2-rx3q-4w2v twig/twig (Packagist) Fixed in 3.3.8 Advisory →
Vendor assessments
Timeline
- 2026-10-02 Threatist record created from CVE-2022-23614
- 2026-10-03 Alias added: GHSA-5mv2-rx3q-4w2v
References
Patch 2
Advisory 7
Other 7
- https://github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2022-23614.yaml
- https://github.com/twigphp/Twig
- https://lists.fedoraproject.org/archives/list/[email protected]/message/I2PVV5DUTRUECTIHMTWRI5Z7DVNYQ2YO
- https://lists.fedoraproject.org/archives/list/[email protected]/message/OTN4273U4RHVIXED64T7DSMJ3VYTPRE7
- https://lists.fedoraproject.org/archives/list/[email protected]/message/PECHIY2XLWUH2WLCNPDGNFMPHPRPCEDZ
- https://lists.fedoraproject.org/archives/list/[email protected]/message/SIGZCFSYLPP7UVJ4E4NLHSOQSKYNXSAD
- https://symfony.com/blog/twig-security-release-disallow-non-closures-in-the-sort-filter
More symfony Twig vulnerabilities
- TI-2026-34283 Twig: The `spaceless` filter implicitly marks its output as safe CVSS 4.0MEDIUM 5.1
- TI-2018-10028 Twig before 2.4.4 allows Server-Side Template Injection (SSTI) via the search search_key… CVSS 3.0CRITICAL 9.8
- TI-2022-18637 Twig may load a template outside a configured directory when using the filesystem loader CVSS 3.1HIGH 7.5
- TI-2026-34292 Twig: Arbitrary PHP code execution via `_self.(<string>)` macro-reference compilation CVSS 4.0HIGH 8.7
- TI-2026-34285 Twig: PHP code injection via `{% use %}` template name CVSS 4.0HIGH 8.7
- TI-2026-19691 Twig 2.16.x & 3.9.0-3.25.x Sandbox Bypass via SourcePolicyInterface CVSS 4.0HIGH 8.7
Sources
- CVE-2022-23614 · CVE Program
- CVE-2022-23614 · NVD
- FIRST EPSS
- GHSA-5mv2-rx3q-4w2v · GitHub Advisory Database · CC BY 4.0
- CVE-2022-23614 · Red Hat security data · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences