Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessGain template-authoring access in sandbox
-
DeliverySubmit assignment/destructuring expression
-
ExploitSandbox skips value policy check
-
ExecutionDenied __toString() invoked on object
-
ImpactDisclose restricted string 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 | Exploitation requires that the target application runs Twig in sandbox mode AND permits a (semi-trusted) attacker to supply or author the template source that is rendered under that sandbox - this is the operative PR:L privilege. The attacker needs no allowed tag; they use assignment expressions (x = obj) or destructuring forms ([a] = list, {a} = obj) that evaluate to the assigned value, which is then coerced to a string, triggering a denied __toString(). LIMITING FACTORS: applications that do not use the Twig sandbox, or that never render untrusted template content, are not exposed; impact is confined to disclosing the string output of an object whose __toString() the policy intended to deny (LOW confidentiality, no integrity or availability impact); affects only Twig 3.23.0 through 3.31.0, so deployments on <3.23.0 or >=3.31.1 are unaffected. |
| Impact | This is a medium-severity sandbox protection-mechanism failure (CWE-693/CWE-863) in Twig, not a high-impact priority. The vendor CVSS 4.0 vector (AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:N/VA:N) scores 5.3 and is internally consistent: network-reachable, low complexity, requiring some privilege (PR:L), with only LOW confidentiality impact and no integrity or availability impact. There is no CISA KEV listing and no EPSS score in the provided data, so there is no evidence of active exploitation or a modeled exploitation probability - status is 'no public exploit identified at time of analysis', though the GHSA advisory does include illustrative bypass payloads (not flagged as working exploit code). The vuln.today priority is 'this_month', which aligns with act-when-convenient rather than act_now/emergency. The real-world risk is narrow: it only matters where Twig's sandbox mode is used as a security boundary against untrusted template authors, and the effect is limited to invoking a __toString() the policy intended to deny - an information-disclosure-class bypass, not code execution. PR:L reflects that the attacker must be able to supply template content. Net: a legitimate security regression to patch on a normal cadence, not a widespread emergency. |
| Exploit ScenarioDerived | An application lets semi-trusted users author Twig templates that are rendered in sandbox mode, relying on the sandbox to block calls to denied __toString() methods. The attacker submits a template using an assignment or destructuring expression such as {{ (x = obj) }} or {{ ({secret: s} = obj)|join }}, which evaluates to the assigned value and is then converted to a string, invoking the forbidden __toString() and leaking its output. No tag needs to be allowed; no public weaponized exploit is identified, but the advisory documents the exact trigger payloads. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – Nov 24, 2026
Sandbox policy bypass in Twig 3.23.0 through 3.31.0 lets whoever supplies the template source force the engine to invoke a __toString() method that the sandbox policy explicitly denies, exposing that object's string representation in the rendered output. The regression arrived with Twig 3.23.0's change making assignment (x = obj) and destructuring ([a] = list, {a} = obj) expressions evaluate to the value they assign; SandboxNodeVisitor wrapped filter and function results but not these new expression results, so constructs such as {{ (x = obj) }} or {{ ({secret: s} = obj)|join }} reach __toString() with no tag allowed at all. Exposure is confined to applications that render attacker-influenced template content under the Twig sandbox - the independent assessment rates it medium (CVSS 3.1 AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N, low confidentiality only), no public exploit code was identified at time of analysis, and the vendor patch ships in 3.31.1.
RemediationAI
Vendor-released patch: upgrade composer/twig/twig to 3.31.1 or later (the fix commit 6bcdbc3d4470dde23e3e2636e7053e0512387edd adds SetBinary, SequenceDestructuringSetBinary and ObjectDestructuringSetBinary to the node types wrapped by SandboxNodeVisitor::wrapNode() alongside filters and functions). Advisory details are at https://symfony.com/cve-2026-133765 and https://github.com/twigphp/Twig/security/advisories/GHSA-ccrc-gqhf-3cxc; if the dependency is transitive, pin it via your root composer.json until your framework release catches up. Where upgrading is not immediately possible, the effective compensating control is to stop rendering templates whose source can be influenced by semi-trusted users under the sandbox - restrict template authoring to trusted operators, or serve pre-compiled, reviewed templates instead of user-supplied source - with the trade-off that any legitimate user-authored template feature is lost; note that disabling only specific tags does not help here, since the advisory states no tag needs to be allowed for the bypass. Do not rely on using {% do x = obj %} or {% if (x = obj) %} as a workaround in user templates: those forms still work after the patch precisely because they do not convert the value to string, so they neither blocked the bypass nor indicate a mitigated configuration.
Affected VersionsENISA
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 1 package in euvd
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 used by Symfony and a large fraction of the PHP ecosystem. Its sandbox extension (SandboxExtension plus SandboxNodeVisitor) rewrites the parsed AST so that property/method access, filters and functions are gated at runtime by a SecurityPolicy, which includes a check before PHP coerces an object to a string via __toString(). Twig 3.23.0 introduced assignment expressions and sequence/object destructuring that yield the assigned value as an expression result, represented in the AST by SetBinary, SequenceDestructuringSetBinary and ObjectDestructuringSetBinary. The fix diff shows SandboxNodeVisitor::wrapNode() only added sandbox wrapping for FilterExpression and FunctionExpression nodes, so these three new binary nodes escaped the string-coercion check. Any context that coerces the expression to string - direct printing, concatenation, a filter input such as |upper or |join, or inclusion inside an array that is joined - therefore triggered the denied __toString(). The issue is classified CWE-693 (protection mechanism failure) and CWE-863 (incorrect authorization) in the upstream GHSA: the root cause is an incomplete authorization check in the sandbox wrapper, not a memory-safety or injection primitive. Per the advisory, {% do x = obj %} and {% if (x = obj) %} remain permitted after the fix because those contexts do not convert the value to a string. The trigger for the bypass is described in the advisory as the assignment/destructuring expression result reaching a string-coercion context; no other triggering mechanism is stated in the available sources.
Know when Twig 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:L/VI:N/VA:N/SC:N/SI:N/SA:N
Attacker must be able to author sandboxed template content (PR:L) over the network with low complexity; impact is limited to disclosing a denied __toString() output, so C:L and I/A:N.
Primary rating from Vendor (Symfony).
CVSS VectorVendor: Symfony
DescriptionCVE.org
The sandbox checks that a template may call toString() on an object before converting it to a string. Since Twig 3.23.0, assignments like x = obj, and the destructuring forms [a] = list and {a} = obj, evaluate to the value that they assign. The sandbox didn't check that value, so a sandboxed template could call a denied toString() method:
{{ (x = obj) }} {{ ({secret: s} = obj)|join }}
No tag needs to be allowed.
The sandbox now checks the result of assignments like the result of filters and functions. {% do x = obj %} and {% if (x = obj) %} still work, since they don't convert the value to a string.
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
Information disclosure occurs when an application unintentionally exposes sensitive data that aids attackers in reconnaissance or directly compromises security.
Twig before 2.4.4 allows Server-Side Template Injection (SSTI) via the search search_key parameter. Rated critical sever
Sandbox bypass in Twig template engine versions 2.16.x and 3.9.0 through 3.25.x allows attackers with template rendering
Twig is a template language for PHP. Rated high severity (CVSS 8.6), this vulnerability is remotely exploitable, no auth
Twig is a template language for PHP. Rated high severity (CVSS 7.5), this vulnerability is remotely exploitable, no auth
The displayBlock function Template.php in Sensio Labs Twig before 1.20.0, when Sandbox mode is enabled, allows remote at
Denial-of-service via resource exhaustion affects the Twig templating engine for PHP prior to 3.26.0, where the sandbox
Symfony is a PHP framework for web and console applications and a set of reusable PHP components. Rated medium severity
Sandboxed Twig templates that are permitted to use the `join` filter can disclose the private and protected properties o
Twig's security sandbox allow-list can be bypassed by a sandboxed template that uses the `embed` tag with a parent expre
A sandbox policy bypass in the Twig template engine (versions 3.21.0 through 3.30.x, fixed in 3.31.1) lets a template au
A sandbox information disclosure exists in Twig before 1.38.0 and 2.x before 2.7.0 because, under some circumstances, it
Twig's autoescaping logic can print attacker-controlled values without HTML escaping when a template contains a macro im
EUVD-2026-133914
NVD
CVE.org
EPSS
GitHub
VulDB
Exploit-DB