{"id":"CVE-2024-51754","aliases":["CVE-2024-51754","GHSA-6377-hfv9-hqf6"],"related":[],"kind":"vulnerability","state":"published","title":"Unguarded calls to __toString() when nesting an object into an array in Twig","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"### Description\n\nIn 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).\n\n### Resolution\n\nThe sandbox mode now checks the `__toString()` method call on all objects.\n\nThe 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.\n\n### Credits\n\nWe would like to thank Jamie Schouten for reporting the issue and Fabien Potencier for providing the fix.","format":"markdown","source":"ghsa"},{"lang":"es","text":"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.","source":"nvd"}],"published":"2024-11-06T19:28:17.553Z","modified":"2026-06-17T08:06:16.223Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:N","score":2.2,"rating":"LOW"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:N","score":2.2,"rating":"LOW"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:N","score":2.2,"rating":"LOW"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"LOW"}],"cwes":["CWE-668"],"affected":[{"ranges":[{"version":"< 3.11.2","status":"affected"},{"version":">= 3.12.0, < 3.14.1","status":"affected"}],"vendor":"twigphp","product":"Twig","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"3.11.2"}],"ecosystem":"Packagist","package":"twig/twig","purl":"pkg:composer/twig/twig","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"3.12","status":"affected","fixed":"3.14.1"}],"ecosystem":"Packagist","package":"twig/twig","purl":"pkg:composer/twig/twig","source":"ghsa"}],"references":[{"url":"https://github.com/twigphp/Twig/security/advisories/GHSA-6377-hfv9-hqf6","tags":["web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/twigphp/Twig/commit/2bb8c2460a2c519c498df9b643d5277117155a73","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://lists.debian.org/debian-lts-announce/2025/05/msg00039.html","tags":["web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2024-51754","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2024-51754.yaml","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/twigphp/Twig","tags":["package"],"sources":["ghsa"]},{"url":"https://symfony.com/blog/unguarded-calls-to-__tostring-when-nesting-an-object-into-an-array","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2024-11-06T19:40:22.129Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-51754","url":"https://www.cve.org/CVERecord?id=CVE-2024-51754","licence":"CVE Terms of Use","modified":"2025-05-29T09:03:17.579Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-6377-hfv9-hqf6","url":"https://github.com/advisories/GHSA-6377-hfv9-hqf6","licence":"CC-BY-4.0","modified":"2025-05-29T21:34:35.218Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-51754","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-51754","licence":"Public domain","modified":"2026-06-17T08:06:16.223Z"}],"updatedAt":"2026-11-25T22:58:47.842Z","epss":{"score":0.00431,"percentile":0.39216,"date":"2026-12-01T12:00:22.000Z"}}