Twig CVE-2026-46639
HIGHAttack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessObtain template-author privilege on sandboxed Twig app
-
DeliveryCraft template using object-destructuring with {% do %}
-
ExploitSubmit/save template to trigger compilation
-
ExecutionDestructuring compiler emits getAttribute() with sandbox=false
-
PersistRender bypasses SecurityPolicy allowlist
-
ImpactExfiltrate restricted properties/getter return values via rendered output
Vulnerability Assessment
| Weakness |
CWE
OWASP Top 10:2025
A06:2025 - Insecure Design
ASVS 5.0
V15 - Secure Coding and Architecture Protection mechanism completeness
|
| Exploitation Conditions | Requires (1) the target application to use Twig 3.24.0-3.25.x with SandboxExtension enabled, (2) an attacker able to write or submit Twig template source that will be rendered by the sandboxed environment (e.g., user-editable email templates, CMS theme overrides, multi-tenant template authoring), and (3) the {% do %} tag included in SandboxExtension's allowedTags, which the vendor describes as a common configuration. Limiting factors: installations that do not enable SandboxExtension are not exploitable via this bug (they have no sandbox to bypass in the first place); installations that exclude {% do %} from allowedTags are not exploitable; and the impact is bounded to public properties and public getters of objects already exposed to the template - private members and methods outside the template variable scope are not reachable. |
| Impact | No CVSS vector or EPSS score is provided, and the CVE is not on the CISA KEV list, so quantitative scoring is unavailable. Qualitatively, the vulnerability is meaningful but conditional: it requires an attacker to control a Twig template body inside a sandboxed environment AND for the {% do %} tag to be in allowedTags - a common but not universal configuration. Impact is confidentiality-oriented (read arbitrary public properties / invoke any public getter on exposed objects), not direct RCE, though leaked secrets, tokens, or internal state can be chained into broader compromise depending on what objects the host application passes to templates. Realistic priority is high for multi-tenant SaaS, CMS platforms, and any product letting end users author templates; low for installations that do not use SandboxExtension or do not expose template editing to untrusted users. |
| Exploit ScenarioDerived | A low-privileged tenant on a multi-tenant CMS that allows users to edit Twig email or page templates submits a template containing an object-destructuring assignment such as {% do { secret: app.user.apiToken } = somePassedObject %} (or a destructuring expression that reads a getter like getPassword()). Because the destructuring compiler emits getAttribute() with $sandboxed=false, SecurityPolicy's property/method allowlist is bypassed and the attacker exfiltrates session tokens, API keys, or internal user data through the rendered output. No public PoC has been published, but the advisory provides the exact compiler-level root cause, making PoC development straightforward. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – May 21, 2026
Sandbox escape in Twig 3.24.0 through 3.25.x lets an attacker with write access to a sandboxed template read arbitrary public properties and invoke any public getter on objects exposed to the template, bypassing the SandboxExtension's SecurityPolicy allowlists. The flaw exists because the object-destructuring compiler hardcodes the $sandboxed flag to false when emitting CoreExtension::getAttribute() calls, so policy checks never run for destructuring expressions whenever the {% do %} tag is permitted. No public exploit identified at time of analysis, but the issue was responsibly disclosed with vendor-confirmed root cause and an upstream patch.
RemediationAI
Vendor-released patch: upgrade twig/twig to 3.26.0 or later via Composer (composer require twig/twig:^3.26 or composer update twig/twig), which forwards the active sandbox flag from the destructuring compiler to CoreExtension::getAttribute() so allowlists are enforced. Advisory details are at https://github.com/twigphp/Twig/security/advisories/GHSA-mm6w-gr99-p3jj and https://symfony.com/cve-2026-46639. If immediate upgrade is not possible, remove the {% do %} tag from SandboxExtension's allowedTags (this blocks the exploit path but breaks any legitimate templates relying on {% do %}), or disable user-submitted template authoring entirely until the package is updated; additionally, audit which objects are passed into sandboxed templates and remove any exposing sensitive properties or getters as a hardening step.
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 1 package in composer
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
Twig is the PHP templating engine maintained by Symfony/SensioLabs and embedded in CMSes and frameworks (Drupal, Symfony, Craft CMS, eZ Platform, Shopware, Grav, etc.) where untrusted users can submit templates protected by SandboxExtension. The sandbox relies on SecurityPolicy allowlists enforced at runtime by CoreExtension::getAttribute(), which only checks allowlists when its $sandboxed argument is true. Twig 3.24.0 introduced object-destructuring assignment, whose compiler ObjectDestructuringSetBinary::compile() emits getAttribute() calls with $sandboxed hardcoded to false rather than the correct $env->hasExtension(SandboxExtension::class) check used by GetAttrExpression::compile(). The CWE-693 (Protection Mechanism Failure) classification captures the root cause: an existing security control silently does not run on a new code path.
Know when PHP gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:L/VA:N/SC:N/SI:N/SA:N
Primary rating from Vendor (https://github.com/twigphp/Twig) · only source for this CVE.
CVSS VectorVendor: https://github.com/twigphp/Twig
Lifecycle Timeline
1DescriptionCVE.org
Description
The object-destructuring assignment syntax introduced in Twig 3.24.0 generates a call to CoreExtension::getAttribute() with the $sandboxed argument hardcoded to false, regardless of whether a SandboxExtension is active. This permanently disables the sandbox's property and method policy checks for every destructuring expression.
ObjectDestructuringSetBinary::compile() emits:
CoreExtension::getAttribute($this->env, $this->source, ..., \Twig\Template::ANY_CALL, false, false, false, ...);
// ^^^^^
// sandbox check never runsWhereas GetAttrExpression::compile() correctly passes $env->hasExtension(SandboxExtension::class).
An attacker with write access to a sandboxed Twig template can read any public property or invoke any public getter on objects passed to the template engine, bypassing SecurityPolicy restrictions. The exploit requires only the {% do %} tag to be in allowedTags, which is a common configuration.
Resolution
The destructuring compiler now forwards the active sandbox flag to getAttribute() so property/method allowlists are enforced.
Credits
Twig would like to thank Anvil Secure in collaboration with Claude and Anthropic Research for reporting and fixing the issue.
Executive ViewAI
Twig versions 3.24.0 through 3.25.x contain a sandbox escape vulnerability allowing template writers to access arbitrary object properties and methods; no public exploit identified at time of analysis. Organizations using Twig with user-supplied or untrusted template sources face risk of unauthorized data disclosure through compromised template authorship.
No vendor-released patch identified at time of analysis. Interim mitigations: (1) restrict template write access to verified internal personnel only, (2) limit objects exposed to sandboxed templates-expose only essential properties, (3) implement code review for template modifications, (4) evaluate alternative templating engines if user-supplied templates are non-critical to operations.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
Authentication bypass attacks exploit flaws in the verification mechanisms that control access to systems and applications.
Affected Products (CPE)CVE.org
In PHP versions 7.1.x below 7.1.33, 7.2.x below 7.2.24 and 7.3.x below 7.3.11 in certain configurations of FPM setup it
sapi/cgi/cgi_main.c in PHP before 5.3.12 and 5.4.x before 5.4.2, when configured as a CGI script (aka php-cgi), does not
(1) boardData102.php, (2) boardData103.php, (3) boardDataJP.php, (4) boardDataNA.php, and (5) boardDataWW.php in Netgear
The '/common/download_agent_installer.php' script in the Quest KACE System Management Appliance 8.0.318 is accessible by
ProjectSend versions prior to r1720 are affected by an improper authentication vulnerability. Rated critical severity (C
Roundcube Webmail contains a critical PHP object deserialization vulnerability (CVE-2025-49113, CVSS 9.9) that allows au
Util/PHP/eval-stdin.php in PHPUnit before 4.8.28 and 5.x before 5.6.3 allows remote attackers to execute arbitrary PHP c
Palo Alto Networks PAN-OS management web interface contains an authentication bypass allowing unauthenticated attackers
Nagios XI version xi-5.7.5 is affected by OS command injection. Rated high severity (CVSS 8.8), this vulnerability is re
Nagios XI version xi-5.7.5 is affected by OS command injection. Rated high severity (CVSS 8.8), this vulnerability is re
The get_referers function in /opt/ws/bin/sblistpack in Sophos Web Appliance before 3.7.9.1 and 3.8 before 3.8.1.1 allows
The Backup Migration plugin for WordPress is vulnerable to Remote Code Execution in all versions up to, and including, 1
GHSA-mm6w-gr99-p3jj
NVD
CVE.org
EPSS
Exploit-DB