# CVE-2024-51754: Unguarded calls to __toString() when nesting an object into an array in Twig

- Severity: Low 2.2 (CVSS:3.1, scored by GitHub_M) `CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:N`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 0.43%, higher than 39% of CVEs (2026-12-01)
- Published: 2024-11-06T19:28:17.553Z
- Modified: 2026-06-17T08:06:16.223Z
- Also known as: GHSA-6377-hfv9-hqf6
- Weaknesses: CWE-668
- SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial
- Assigned by: GitHub_M

## 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.

(As written by CVE List.)

## Affected

- twigphp Twig: < 3.11.2; >= 3.12.0, < 3.14.1
- twig/twig (Packagist): before 3.11.2; from 3.12 before 3.14.1

## Every score

- GitHub_M: CVSS:3.1 2.2 Low `CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:N`
- GitHub: CVSS:3.1 2.2 Low `CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:N`
- GitHub: CVSS:4.0 Low `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`

## References

- <https://github.com/twigphp/Twig/security/advisories/GHSA-6377-hfv9-hqf6> (web)
- <https://github.com/twigphp/Twig/commit/2bb8c2460a2c519c498df9b643d5277117155a73> (web)
- <https://lists.debian.org/debian-lts-announce/2025/05/msg00039.html> (web)
- <https://nvd.nist.gov/vuln/detail/CVE-2024-51754> (advisory)
- <https://github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2024-51754.yaml> (web)
- <https://github.com/twigphp/Twig> (package)
- <https://symfony.com/blog/unguarded-calls-to-__tostring-when-nesting-an-object-into-an-array> (web)

## Sources

- CVE List: [CVE-2024-51754](https://www.cve.org/CVERecord?id=CVE-2024-51754), CVE Terms of Use, modified 2025-05-29
- GitHub Advisory Database: [GHSA-6377-hfv9-hqf6](https://github.com/advisories/GHSA-6377-hfv9-hqf6), CC-BY-4.0, modified 2025-05-29
- NVD: [CVE-2024-51754](https://nvd.nist.gov/vuln/detail/CVE-2024-51754), Public domain, modified 2026-06-17

---

Page: https://cve.day/CVE-2024-51754 · Whole record: https://cve.day/CVE-2024-51754.json · Rebuilt by cve.day 2026-11-25T22:58:47.842Z
