Skip to content
OpenAdvisories
Low · 2.2 CVE-2024-51754 EUVD-2024-3201GHSA-6377-hfv9-hqf6

Unguarded calls to __toString() when nesting an object into an array in Twig

Published Nov 6, 2024 · Updated May 29, 2025 · Assigned by GitHub_M

Description

Twig is a template language for PHP. In a sandbox, an attacker can call `__toString()` on an object even if the `__toString()` method is not allowed by the security policy when the object is part of an array or an argument list (arguments to a function or a filter for instance). This issue has been patched in versions 3.11.2 and 3.14.1. All users are advised to upgrade. There are no known workarounds for this issue.

Affected products

VendorProductAffectedFixed
twigphp Twig < 3.11.2, >= 3.12.0, < 3.14.1 —

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.14.2-1 —
Debian 13 php-twig 3.14.2-1 —
Debian 12 php-twig 3.5.1-1+deb12u3 —
Debian 11 php-twig 2.14.3-1+deb11u4 DLA-4186-1
ReleasePackageFixed inAdvisory
Ubuntu Pro 24.04 LTS php-twig 3.8.0-2ubuntu0.1~esm1 USN-7456-1
Ubuntu Pro 22.04 LTS php-twig 3.3.8-2ubuntu4+esm2 USN-7456-1
Ubuntu Pro 20.04 LTS php-twig 2.12.5-1ubuntu0.1~esm2 USN-7456-1
Show 2 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
Ubuntu Pro 18.04 LTS twig No fix yet —
Ubuntu Pro 16.04 LTS twig No fix yet —

Affected packages

EcosystemPackageAffectedFixedRecord
Packagist twig/twig < 3.11.2 3.11.2 GHSA-6377-hfv9-hqf6
Packagist twig/twig >= 3.12, < 3.14.1 3.14.1 GHSA-6377-hfv9-hqf6

Advisories 2

References