CVE-2026-46636
8.7Twig · Twig
A sandbox bypass vulnerability in the Twig template engine allows unauthenticated attackers to execute arbitrary methods on Markup-derived objects within sandboxed environments.
Executive summary
A critical sandbox bypass vulnerability in the Twig template engine allows unauthorized method execution, potentially leading to significant information disclosure.
Vulnerability
The vulnerability exists in the SecurityPolicy::checkMethodAllowed function, which fails to restrict method calls on subclasses of Twig\Markup. This flaw allows an unauthenticated attacker to bypass sandbox protections and invoke any public method of a Markup-derived class.
Business impact
The ability to execute arbitrary methods within a sandboxed template environment can lead to the unauthorized disclosure of sensitive data or the manipulation of application logic. With a CVSS score of 8.7, this high-severity vulnerability poses a substantial risk to application integrity and confidentiality, particularly in environments that rely on Twig for rendering user-supplied or untrusted templates.
Remediation
Immediate Action: Update the Twig library to version 3.27.0 or later to ensure the security policy correctly restricts method calls on Markup objects.
Proactive Monitoring: Review application logs for unexpected method calls or unusual activity originating from template rendering processes that handle Markup-derived objects.
Compensating Controls: If immediate patching is not feasible, restrict the passing of complex Markup-derived objects into sandboxed templates and evaluate the implementation of strict allow-lists for template-accessible objects.
Exploitation status
Public Exploit Available: No
Analyst recommendation
Given the high CVSS score and the nature of the sandbox bypass, organizations utilizing the Twig template engine should prioritize upgrading to version 3.27.0. Failure to patch this vulnerability leaves applications susceptible to unauthorized method invocation, which may be leveraged to compromise protected data or circumvent security controls embedded within the application layer.
More Twig CVEs
Sources
- https://github.com/twigphp/Twig/security/advisories/GHSA-64jr-qjx4-w2fh
- https://security-tracker.debian.org/tracker/CVE-2026-46636
- https://security-tracker.debian.org/tracker/DSA-6311-1
- https://symfony.com/blog/cve-2026-46636-sandbox-filter-tag-and-function-allow-list-bypass-when-sandbox-state-changes-bet
- http://github.com/twigphp/Twig/releases/tag/v3.27.0