CVE-2024-51755 — Vulnerability in twig/twig — CVE Details
Twig has unguarded calls to `__isset()` and to array-accesses when the sandbox is enabled
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (0.58%). Schedule for your next planned update.
Does your project use an affected twig/twig version?
Paste your composer.lock to check it for CVE-2024-51755 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
Description
In a sandbox, and attacker can access attributes of Array-like objects as they were not checked by the security policy.
They are now checked via the property policy and the __isset() method is now called after the security check.
This is a BC break.
Resolution
The sandbox mode now ensures access to array-like's properties is allowed.
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 Nicolas Grekas for providing the fix.
Advisory Timeline
- First published November 6, 2024 (750 days ago).
- Last revised November 12, 2024 — 6 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
composer require "twig/twig:^3.14.1"
composer require "twig/twig:^3.11.2"
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (2)
Affects 1 ecosystem: Packagist (1).
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-668
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 2.2 score means for each attack dimension.
CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:N
References
- https://github.com/twigphp/Twig/security/advisories/GHSA-jjxq-ff2g-95vhWEB
- https://nvd.nist.gov/vuln/detail/CVE-2024-51755ADVISORY
- https://github.com/twigphp/Twig/commit/831c148e786178e5f2fde9db67266be3bf241c21WEB
- https://github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2024-51755.yamlWEB
- https://github.com/twigphp/TwigPACKAGE
- https://symfony.com/blog/unguarded-calls-to-__isset-and-to-array-accesses-when-the-sandbox-is-enabledWEB
Frequently Asked Questions
- What is CVE-2024-51755?
- Twig has unguarded calls to `__isset()` and to array-accesses when the sandbox is enabled. This vulnerability has been assigned a severity rating of LOW (CVSS score: 2.2/10).
- How do I check if my project is affected by CVE-2024-51755?
- CVE-2024-51755 affects twig/twig. It has a 0.6% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2024-51755 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Exploitation is difficult, or the impact is minor.
This is a below-median EPSS score — only 41.9% of tracked vulnerabilities score at or below it, so most tracked vulnerabilities are considered more likely to be exploited than this one.
Also Known As
Related CVEs
- CVE-2026-24425HIGH
Twig: Possible sandbox bypass when using a source policy
- CVE-2026-46640HIGH
Twig: Arbitrary PHP code execution via `_self.(<string>)` macro-reference compilation
- CVE-2026-49981HIGH
Twig: Sandbox filter, tag and function allow-list bypass when sandbox state changes between renders for a cached `Template`
- CVE-2026-47732HIGH
Twig: Sandbox: multiple `__toString()` policy bypasses via unguarded string coercion points
- CVE-2026-46634MEDIUM
Twig: `template_from_string()` escapes a SourcePolicy-driven sandbox via synthesized template name
- CVE-2026-47730LOW
Twig: XSS in profiler HtmlDumper via unescaped template and profile names
- CVE-2026-46628LOW
Twig: The `spaceless` filter implicitly marks its output as safe
- CVE-2026-46635LOW
Twig: Sandbox property allowlist bypass via the `column` filter (array_column on objects)