Low severity · published Nov 6, 2024
CVE-2024-51754
Unguarded calls to __toString() when nesting an object into an array in Twig
2.2
CVSS
0.4%
EPSS
No
On KEV
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.
CVSS vector
CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:N
Attack vector
Network
Complexity
High
Privileges
High
User interaction
None
Confidentiality
Low
Integrity
None
Availability
None
Scope
Unchanged
Exploitation
Is it being used?
Exploit prediction (EPSS)0.4% · higher than 38% of CVEs
Exploited in the wildNo evidence yet
CISA KEVNot listed
Ransomware campaign useNot known
Affected products
Which versions
TW
Twig · twigphp
< 3.11.2; >= 3.12.0, < 3.14.1 · source: vendor
References
NVD
https://nvd.nist.gov/vuln/detail/CVE-2024-51754
CVE.org
https://www.cve.org/CVERecord?id=CVE-2024-51754
github.com
https://github.com/twigphp/Twig/commit/2bb8c2460a2c519c498df9b643d5277117155a73
github.com
https://github.com/twigphp/Twig/security/advisories/GHSA-6377-hfv9-hqf6
lists.debian.org
https://lists.debian.org/debian-lts-announce/2025/05/msg00039.html
More from Twig
9.9
CVE-2026-24425
Twig 2.16.x & 3.9.0-3.25.x Sandbox Bypass via SourcePolicyInterface
9.8
CVE-2026-46634
Twig: `template_from_string()` escapes a SourcePolicy-driven sandbox via synthesized template name
9.8
CVE-2026-46633
Twig: PHP code injection via `{% use %}` template name
9.1
CVE-2026-48807
Twig: Sandbox `__toString()` policy bypass via `Traversable` in `join` and `replace` filters
9.1
CVE-2026-48806
Twig: Sandbox `__toString()` policy bypass via dynamic mapping keys
