CVE-2024-51754
lowpriority · track · 0EPSS 0.004 · 38 %ileEUUSEPSS · scored 2026-10-28
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.
cvss
Technical severity, 0–10. One row per scoring source.
base score 0–10 · higher = more severe · hover a vector to decode
ssvc
A stakeholder decision — act, attend, or track — from exploitation and impact.
weaknesses
The CWE weakness classes this flaw belongs to.
affected products (4)
Products and version ranges known to be affected.
advisories (1)
Vendor and ecosystem advisories describing this.
- GHSA-6377-hfv9-hqf6Twig has unguarded calls to `__toString()` when nesting an object into an array2024-11-06ghsa · osvUS
### Description 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). ### Resolution The sandbox mode now checks the `__toString()` method call on all objects. The patch for this issue is available [here](https://github.com/twigphp/Twig/commit/cafc608ece310e62a35a76f17e25c04ab9ed05cc) for the 3.11.x branch, and [here](https://github.com/twigphp/Twig/commit/d4a302681bca9f7c6ce2835470d53609cdf3e23e) for the 3.x branch. ### Credits We would like to thank Jamie Schouten for reporting the issue and Fabien Potencier for providing the fix.
also known as (3)
Other names and identifiers for this entity.
sources
Which sources assert this record, and when.
references (8)
External citations — patches, advisories, analysis.
- https://github.com/twigphp/Twig/commit/2bb8c2460a2c519c498df9b643d5277117155a73cnnvd
- https://github.com/twigphp/Twig/security/advisories/GHSA-6377-hfv9-hqf6cnnvd
- https://nvd.nist.gov/vuln/detail/CVE-2024-51754cnnvd
- https://github.com/twigphp/Twig/commit/2bb8c2460a2c519c498df9b643d5277117155a73enisa_euvd
- https://github.com/twigphp/Twig/security/advisories/GHSA-6377-hfv9-hqf6enisa_euvd
- https://github.com/twigphp/Twig/commit/2bb8c2460a2c519c498df9b643d5277117155a73nvd
- https://github.com/twigphp/Twig/security/advisories/GHSA-6377-hfv9-hqf6nvd
- https://lists.debian.org/debian-lts-announce/2025/05/msg00039.htmlnvd
Attackers weaponise vulnerabilities like this against internet-exposed services. See what is exposed on your perimeter with a free passive scan.
Free scan