Skip to content
OpenAdvisories
High USN-5947-1 3 CVEs

php-twig, twig vulnerabilities

Published Mar 13, 2023 · Updated Jun 25, 2026

Summary

Fabien Potencier discovered that Twig was not properly enforcing sandbox
policies when dealing with objects automatically cast to strings by PHP.
An attacker could possibly use this issue to expose sensitive information.
This issue was only fixed in Ubuntu 16.04 ESM and Ubuntu 18.04 ESM.
(CVE-2019-9942)

Marlon Starkloff discovered that Twig was not properly enforcing closure
constraints in some of its array filtering functions. An attacker could
possibly use this issue to execute arbitrary code. This issue was only
fixed in Ubuntu 20.04 ESM. (CVE-2022-23614)

Dariusz Tytko discovered that Twig was not properly verifying input data
utilized when defining pathnames used to access files in a system. An
attacker could possibly use this issue to access unauthorized resources
and expose sensitive information. (CVE-2022-39261)

Fixed packages 4

ReleasePackageFixed in
Ubuntu · Pro 16.04 LTS Pro:16.04:LTS twig 1.23.1-1ubuntu4+esm1
Ubuntu · Pro 18.04 LTS Pro:18.04:LTS twig 2.4.6-1ubuntu0.1~esm1
Ubuntu · Pro 20.04 LTS Pro:20.04:LTS php-twig 2.12.5-1ubuntu0.1~esm1
Ubuntu · Pro 22.04 LTS Pro:22.04:LTS php-twig 3.3.8-2ubuntu4+esm1

Vulnerabilities 3

  • High 8.8
    CVE-2022-23614 Public exploit

    Code injection in Twig

    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…

  • High 7.5

    Twig may load a template outside a configured directory when using the filesystem loader

    Twig is a template language for PHP. Versions 1.x prior to 1.44.7, 2.x prior to 2.15.3, and 3.x prior to 3.4.3 encounter an issue when the filesystem loader loads templates for which the name is a user input. It is possible to use the `source` or `include` st…

  • Low 3.7

    Twig Sandbox Information Disclosure

    A sandbox information disclosure exists in Twig before 1.38.0 and 2.x before 2.7.0 because, under some circumstances, it is possible to call the __toString() method on an object even if not allowed by the security policy in place.

References

  • report
    https://ubuntu.com/security/CVE-2019-9942
  • report
    https://ubuntu.com/security/CVE-2022-23614
  • report
    https://ubuntu.com/security/CVE-2022-39261