CVE-2024-51754: Twig has unguarded calls to `__toString()` when nesting an object into an array
(updated )
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).
References
- github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2024-51754.yaml
- github.com/advisories/GHSA-6377-hfv9-hqf6
- github.com/twigphp/Twig
- github.com/twigphp/Twig/commit/2bb8c2460a2c519c498df9b643d5277117155a73
- github.com/twigphp/Twig/security/advisories/GHSA-6377-hfv9-hqf6
- lists.debian.org/debian-lts-announce/2025/05/msg00039.html
- nvd.nist.gov/vuln/detail/CVE-2024-51754
- symfony.com/blog/unguarded-calls-to-__tostring-when-nesting-an-object-into-an-array
Code Behaviors & Features
Detect and mitigate CVE-2024-51754 with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Dependency Scanning using SBOM also detects vulnerabilities from proprietary advisories that this site does not include. Learn more about Dependency Scanning using SBOM →