Skip to content
OpenAdvisories
High · 8.8 Public exploit CVE-2022-23614 EUVD-2022-0842GHSA-5mv2-rx3q-4w2v

Code injection in Twig

Published Feb 4, 2022 · Updated Apr 23, 2025 · Assigned by GitHub_M

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

VendorProductAffectedFixed
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.

ReleasePackageFixed inAdvisory
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
ReleasePackageFixed inAdvisory
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)
ReleasePackageFixed inAdvisory
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.

Third-party code, not reviewed by us. Public PoCs are sometimes fake or contain malware. Read the code first and run it only in an isolated lab, against systems you are authorised to test.

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

EcosystemPackageAffectedFixedRecord
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

References