2.2low
Unguarded calls to __toString() when nesting an object into an array in Twig
- Severity
- 2.2low CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.43% (higher than 39% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-6377-hfv9-hqf6
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
| Product or package | Versions | Reported by |
|---|---|---|
| twigphp Twig | < 3.11.2, >= 3.12.0, < 3.14.1 | CVE List |
| twig/twig (Packagist) | before 3.11.2, from 3.12 before 3.14.1 | GitHub Advisory Database |
All scores
| GitHub_M | 2.2low CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:N |
| GitHub | 2.2low CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:N |
| GitHub | low CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:P/PR:H/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N |
Classification
SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.
What each source says
CVE List
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.
GitHub Advisory Database
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.
NVD (es)
Twig es un lenguaje de plantillas para PHP. En un entorno aislado, un atacante puede llamar a `__toString()` en un objeto incluso si la política de seguridad no permite el método `__toString()` cuando el objeto es parte de una matriz o una lista de argumentos (argumentos para una función o un filtro, por ejemplo). Este problema se ha corregido en las versiones 3.11.2 y 3.14.1. Se recomienda a todos los usuarios que actualicen. No se conocen workarounds para este problema.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2024-51754 changed 2025-05-29 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-6377-hfv9-hqf6 changed 2025-05-29 | CC-BY-4.0 |
| NVD | CVE-2024-51754 changed 2026-06-17 | Public domain |