Twig CVE-2026-46639
HIGHSeverity 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/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
Primary rating from Vendor (https://github.com/twigphp/Twig) · only source for this CVE.
CVSS VectorVendor: https://github.com/twigphp/Twig
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/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
Lifecycle Timeline
4DescriptionCVE.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.
AnalysisAI
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.
Technical ContextAI
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.
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.
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
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
NetAlertX (formerly PiAlert) versions 23.01.14 through 24.x before 24.10.12 allow unauthenticated command injection thro
The GiveWP - Donation Plugin and Fundraising Platform plugin for WordPress is vulnerable to PHP Object Injection in all
Same weakness CWE-693 – Protection Mechanism Failure
View allSame technique Authentication Bypass
View allShare
External POC / Exploit Code
Leaving vuln.today
GHSA-mm6w-gr99-p3jj