Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessAuthor malicious sandboxed template
-
ExploitReach shared application Markup object
-
ExecutionCall __construct() to replace its content
-
ImpactInjected script renders in trusted non-sandboxed page
Vulnerability Assessment
| Weakness |
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Output encoding, context-aware escaping
MITRE ATT&CK
2 techniques across 2 tactics: Initial Access, Execution The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | Exploitation requires all of the following, which together sharply limit real-world risk: (1) the Twig sandbox extension must be enabled and the attacker must be able to supply or author a sandboxed template (PR:L); (2) the application must expose an application-owned Twig\Markup object that the sandboxed template can reach (e.g. passed into context or available as a global); and (3) that same Markup object must be reused and rendered elsewhere in a trusted, non-sandboxed context - the advisory specifically cites a global in a long-running worker. Attacking a Markup object used only within the attacker's own sandboxed output yields nothing. Limiting factors: authenticated template-authoring capability is needed (PR:L), the shared-Markup deployment pattern is a non-default architectural precondition (AT:P), and a victim must subsequently view the poisoned trusted page (UI:P). The complete fix is updating to Twig 3.31.1, which blocks __construct() on Markup objects in the sandbox; no other mitigation is stated in the evidence. |
| Impact | This is a genuinely low-priority issue, and the signals are consistent rather than conflicting. The CVSS 4.0 vector (AV:N/AC:L/AT:P/PR:L/UI:P) and its 2.1 base score agree with the vuln.today 'monitor' decision label: network-reachable but requiring an attacker who can already supply a sandboxed template (PR:L), a specific deployment precondition (AT:P - a Markup object shared between sandboxed and trusted rendering, e.g. a global in a long-running worker), and passive victim interaction (UI:P) before any impact occurs. Impact is limited to integrity (VI:L/SI:L) with no confidentiality or availability effect. No EPSS score, no CISA KEV listing, and no verified working exploit code are present in the input, so there is no evidence of active or at-scale exploitation; the threat is conditional and architecture-dependent rather than broadly automatable. The one caveat worth stating is that the sandbox is Twig's security boundary, and this is a sandbox-escape-style authorization flaw (CWE-863) producing stored XSS (CWE-79), so for the specific deployments that render user-authored sandboxed templates AND reuse application-owned Markup objects elsewhere, the real-world consequence (script injected into trusted, non-sandboxed pages) is more serious than the 2.1 score alone conveys - the low score reflects how narrow the precondition is, not a benign outcome where it applies. |
| Exploit ScenarioDerived | An application lets semi-trusted users author Twig templates under the sandbox (e.g. email or page snippets) and also exposes an application-owned Markup object - such as a shared banner global - that is rendered on trusted, non-sandboxed pages. A malicious author calls {% do banner.__construct('<script>alert(1)</script>', 'UTF-8') %} to overwrite that object's content, so the injected script is later served to other users on the trusted page. The advisory includes this illustrative payload, but the input lists no verified working exploit code. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – Nov 24, 2026
The Twig sandbox extension can be abused to rewrite application-owned Twig\Markup objects: a sandboxed template is allowed to call __construct() on any Markup instance it can reach and replace that object's content with attacker-chosen HTML, which is then rendered unescaped in trusted, non-sandboxed pages that reuse the same object. Affected are twig/twig releases before 3.31.1 (fixed in 3.31.1) whenever the sandbox extension is enabled; real-world impact additionally requires an application-owned Markup object reachable from the sandboxed template and a deployment pattern that renders that same object elsewhere, such as a global in a long-running worker. Priority is monitor: the exploit path needs sandboxed template authoring rights, a non-default shared-Markup architecture, and a victim viewing the poisoned trusted page, and no public exploit code was identified at time of analysis.
RemediationAI
Vendor-released patch: Twig 3.31.1 (3.x branch), which stops the sandbox from permitting __construct() on Twig\Markup objects; upgrade to 3.31.1 or later. The fix commit is https://github.com/twigphp/Twig/commit/97b2e40b1165e6a42a197843f96ccb0a55f46f34 and the advisories are https://symfony.com/cve-2026-133770 and https://github.com/twigphp/Twig/security/advisories/GHSA-r34x-hh9h-9q9c. Updating is stated to be the complete fix; the evidence does not provide any alternative mitigation, and patching is the only change that restores the intended sandbox policy for Markup constructors. Because exploitation depends on being able to supply or author a sandboxed template plus a Markup object shared into a trusted rendering path, reducing who can author sandboxed templates and auditing long-running workers for global Markup objects that are rendered in both sandboxed and trusted contexts will shrink the exposure window while the upgrade is rolled out, but neither substitutes for applying 3.31.1. Patch status per vendor advisory: available.
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 a PHP templating engine, and Twig\Markup is the value object used to carry content the application has already declared safe for raw output; it is backed by __toString() and exposes a public constructor plus withContent(). The SandboxExtension delegates authorization to Sandbox\SecurityPolicy::checkMethodAllowed(), which deliberately bypasses the method/property allowlists for Template and Markup instances because Markup is treated as pre-vetted safe content. The original check exempted every Markup method except withContent(), which left the public constructor callable from an attacker-controlled sandboxed template (CWE-863, incorrect authorization / policy bypass), and the resulting content injection is a cross-context script injection issue (CWE-79) when the mutated object is later rendered by trusted code. The upstream fix (commit 97b2e40b1165e6a42a197843f96ccb0a55f46f34) changes the exemption to '__construct' ! $method && 'withcontent' ! $method and adds regression tests covering context values, mixed-case __CONSTRUCT calls, and captured set-blocks, while confirming that other Markup methods such as count and getCharset() remain callable in the sandbox. The vulnerability is therefore a sandbox policy gap in the Twig PHP library itself, not a flaw in the PHP runtime or in the templates: nothing is gained by rewriting the sandboxed template's own output, and the impact materializes only through shared, reused Markup state.
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:P/PR:L/UI:P/VC:N/VI:L/VA:N/SC:L/SI:L/SA:N
PR:L because the attacker must author a sandboxed template; AC:H for the required shared-Markup deployment condition; S:C and I:L because injected content crosses into trusted non-sandboxed pages (stored XSS), with no confidentiality or availability impact.
Primary rating from Vendor (Symfony).
CVSS VectorVendor: Symfony
DescriptionCVE.org
The sandbox allows every method of Twig\Markup objects, including their public constructor. A sandboxed template can therefore call __construct() on any Markup object that it reaches, and replace its content:
{% do banner.__construct('<script>alert(1)</script>', 'UTF-8') %}
A template gains nothing by rewriting its own output. The impact is on the Markup objects that come from the application and are also rendered elsewhere, like a global in a long-running worker. Their new content then ends up in trusted pages that aren't sandboxed.
The sandbox no longer allows calling the constructor of Markup objects.
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
Cross-Site Scripting occurs when an application accepts untrusted data and sends it to a web browser without proper validation or encoding.
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
Sandbox policy bypass in Twig 3.23.0 through 3.31.0 lets whoever supplies the template source force the engine to invoke
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
EUVD-2026-133919
NVD
CVE.org
EPSS
GitHub
VulDB
Exploit-DB