CVE-2024-45411 — Vulnerability in twig/twig — CVE Details
Twig has a possible sandbox bypass
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (1.19%). 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-45411 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
Under some circumstances, the sandbox security checks are not run which allows user-contributed templates to bypass the sandbox restrictions.
The security issue happens when all these conditions are met:
- The sandbox is disabled globally;
- The sandbox is enabled via a sandboxed
include()function which references a template name (likeincluded.twig) and not aTemplateorTemplateWrapperinstance; - The included template has been loaded before the
include()call but in a non-sandbox context (possible as the sandbox has been globally disabled).
Resolution
The patch ensures that the sandbox security checks are always run at runtime.
Credits
We would like to thank Fabien Potencier for reporting and fixing the issue.
Advisory Timeline
- First published September 9, 2024 (808 days ago).
- Last revised October 10, 2024 — 31 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
composer require "twig/twig:^1.44.8"
composer require "twig/twig:^3.14.0"
composer require "twig/twig:^3.11.1"
composer require "twig/twig:^2.16.1"
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (4)
Affects 1 ecosystem: Packagist (1).
| Package | Fixed In |
|---|---|
| twig/twig Packagist · Affected: 1.3.0, 1.4.0, 1.5.0, 1.5.1 (+110 more) | 1.44.8 |
| twig/twig Packagist · Affected: v3.12.0, v3.13.0 | 3.14.0 |
| twig/twig Packagist · Affected: v3.0.0, v3.0.1, v3.0.2, v3.0.3 (+36 more) | 3.11.1 |
| twig/twig Packagist · Affected: v2.0.0, v2.1.0, v2.10.0, v2.11.0 (+58 more) | 2.16.1 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-693Protection Mechanism FailureMITRE
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 8.5 score means for each attack dimension.
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:H
References
- https://github.com/twigphp/Twig/security/advisories/GHSA-6j75-5wfj-gh66WEB
- https://nvd.nist.gov/vuln/detail/CVE-2024-45411ADVISORY
- https://github.com/twigphp/Twig/commit/11f68e2aeb526bfaf638e30d4420d8a710f3f7c6WEB
- https://github.com/twigphp/Twig/commit/2102dd135986db79192d26fb5f5817a566e0a7deWEB
- https://github.com/twigphp/Twig/commit/41103dcdc2daab4c83cdd05b5b4fde5b7e41e635WEB
- https://github.com/twigphp/Twig/commit/7afa198603de49d147e90d18062e7b9addcf5233WEB
- https://github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2024-45411.yamlWEB
- https://github.com/twigphp/TwigPACKAGE
- https://symfony.com/blog/twig-security-release-possible-sandbox-bypassWEB
Frequently Asked Questions
- What is CVE-2024-45411?
- Twig has a possible sandbox bypass. This vulnerability has been assigned a severity rating of MEDIUM (CVSS score: 8.5/10).
- How do I check if my project is affected by CVE-2024-45411?
- CVE-2024-45411 affects twig/twig. It has a 1.2% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2024-45411 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Significant impact if exploited, or exploitable with modest effort.
This is an above-median EPSS score — 67.7% of tracked vulnerabilities score at or below it, putting its exploitation likelihood in the upper half of the tracked corpus.
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-46639HIGH
Twig: Sandbox property and method bypass via object-destructuring assignment
- 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-48805LOW
Twig: Sandbox state regression in deprecated internal wrappers in `src/Resources/core.php`
- CVE-2026-46635LOW
Twig: Sandbox property allowlist bypass via the `column` filter (array_column on objects)