CVE-2024-51754
Unguarded calls to __toString() when nesting an object into an array in Twig
Also known as GHSA-6377-hfv9-hqf6
Mitigation
- Upgrade twig/twig to one of 3.11.2, 3.14.1 (or later in the same release line).
Who should check
- Projects that depend on Packagist package twig/twig (< 3.11.2)
- Anyone running twigphp Twig < 3.11.2; >= 3.12.0, < 3.14.1
Vulnerability facts
- Affected
- twig/twig < 3.11.2
- Fixed in
- 3.11.2, 3.14.1
- Exploited in the wild
- Not in CISA KEV
- Public exploit / PoC
- None known
- Remote exploitation
- Remote, login needed
- CVSS
- 2.2 (v3.1, CNA)CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:NOpen in CVSS calculator
Show all 8 CVSS metrics
- Attack vector: Network
- Attack complexity: High
- Privileges required: High
- User interaction: None
- Scope: Unchanged
- Confidentiality impact: Low
- Integrity impact: None
- Availability impact: None
- EPSS
- 0.71% chance of exploitation in 30 days (percentile 49, 2026-11-26)
- CWE
- CWE-668
- Modified
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 and fixed versions
Check your systems with an agent
Paste this into Claude Code, Cursor or another coding agent. It only reads; it changes nothing.
Check whether anything I run is affected by CVE-2024-51754. Work read-only: do not install, upgrade, delete or change anything. Details: https://flawdb.com/CVE-2024-51754.md Affected: twig/twig < 3.11.2 Fixed in: 3.11.2, 3.14.1 Steps: 1. Search this machine and project for twig/twig (Packagist), twigphp Twig: dependency manifests and lockfiles, installed packages, container images and running services. 2. For each match, note the installed version and whether it is inside the affected range. 3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
References
Vendor advisories
FAQ
Is CVE-2024-51754 being exploited?
There is no confirmed exploitation: CVE-2024-51754 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.71% chance of exploitation in the next 30 days (as of 2026-11-26).
How serious is CVE-2024-51754?
Low: CVSS 2.2 (v3.1, scored by CNA). Remote, login needed. The attack needs conditions outside the attacker's control, which makes it harder.
Which versions are affected by CVE-2024-51754?
twig/twig < 3.11.2.
Is there a fix for CVE-2024-51754?
Yes. Fixed in 3.11.2, 3.14.1. Upgrade twig/twig to one of 3.11.2, 3.14.1 (or later in the same release line).
How do I check if I'm affected by CVE-2024-51754?
Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.