Twig has unguarded calls to `__toString()` when nesting an object into an array
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 for the 3.11.x branch, and here for the 3.x branch.
Credits
We would like to thank Jamie Schouten for reporting the issue and Fabien Potencier for providing the fix.
Software afectado
Haz clic en una tecnología para ver todas sus vulnerabilidades.
| Plataforma | Paquete | Versiones vulnerables | Corregida en |
|---|---|---|---|
| Paquete de Composer | twig/twig | < 3.11.2, >= 3.12, < 3.14.1 | 3.11.2, 3.14.1 |
Referencias
- https://github.com/twigphp/Twig/security/advisories/GHSA-6377-hfv9-hqf6
- https://nvd.nist.gov/vuln/detail/CVE-2024-51754
- https://github.com/twigphp/Twig/commit/2bb8c2460a2c519c498df9b643d5277117155a73
- https://github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2024-51754.yaml
- https://github.com/twigphp/Twig
- https://lists.debian.org/debian-lts-announce/2025/05/msg00039.html
- https://symfony.com/blog/unguarded-calls-to-__tostring-when-nesting-an-object-into-an-array
- Vector CVSS
CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:N- Debilidad (CWE)
CWE-668- Plataforma
- Composer
- Paquete
twig/twig- Publicada
- 06.11.2024
- Actualizado
- 11.10.2026 10:22
Fuentes y licencias
OSV / GitHub Advisory Database - GHSA-6377-hfv9-hqf6 - CC BY 4.0
Historial de vulnerabilidades: twig/twig
Todas las vulnerabilidades publicadas de este paquete (Paquete de Composer), de la más reciente a la más antigua. Muestra si es un fallo aislado o un paquete que hay que vigilar.
- Entradas en total
- 24
- Primera → última
- 02.2022 07.2026
- Sin corrección
- 0
- Explotada en ataques
- 0
Distribución por gravedad
- Crítica 1
- Alta 8
- Media 8
- Baja 7
Divulgaciones por año
- 2022: 4
- 2023: 0
- 2024: 4
- 2025: 1
- 2026: 15
-
Twig has unguarded calls to `__toString()` when nesting an object into an array esta entrada
Identifica las vulnerabilidades de tu aplicación
Con la integración de DockRay y el inventario de software activado, DockRay compara las versiones notificadas de los componentes con las vulnerabilidades conocidas y avisa de las coincidencias confirmadas. La cobertura depende de la tecnología compatible y de los avisos disponibles.