Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessSubmit HTML/JS payload into stored data field
-
ExploitTemplate renders variable via alias-name collision unescaped
-
ExecutionVictim loads affected page
-
ImpactScript executes in victim browser (session/credential theft)
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 a specific, non-default template-authoring condition, not a runtime attacker setting: the template must contain a macro import alias (e.g. '{% import _self as item %}') whose alias name is ALSO reused as an ordinary variable in a different block or macro (or a template-level import placed after the block using that name), AND that same-named variable's attribute/item/method output (item.body, item['body']) must carry attacker-supplied data. Only then does the buggy rule mark the value safe and print it unescaped. Macro calls through the alias were and remain correctly treated as safe, so they are not a vector. Limiting factors: the vulnerable pattern must already exist in the application's templates (it is uncommon and author-dependent), the attacker must control the rendered value, and a victim must load the page (UI:P/UI:R). Applications without this naming collision are not exploitable regardless of Twig version. |
| Impact | This is a genuinely low-priority issue, and the available signals agree rather than conflict. The vendor CVSS 4.0 vector (AV:N/AC:L/AT:P/PR:N/UI:P, impacts only on the subsequent system: SC:L/SI:L/SA:N) scores 2.3, reflecting a reflected/stored XSS whose impact lands in a victim's browser, not the Twig host - there is no confidentiality, integrity, or availability impact to the vulnerable system itself (VC:N/VI:N/VA:N). The vuln.today decision label is 'monitor,' consistent with the low score. No EPSS score, no CISA KEV listing, and no confirmed public exploit code were provided, so there is no evidence of active exploitation - treat this as a correctness/hardening fix rather than an emergency. The AT:P ('attack requirements present') metric is the key limiter: exploitation depends on a specific template-authoring pattern (a variable named identically to a macro import alias from another block/macro) that does NOT exist in default usage and is not attacker-controlled, so most Twig deployments are simply not affected. No signals are missing in a way that changes the conclusion; the only caveat is that EPSS is absent, so no independent exploitation-probability estimate is available. |
| Exploit ScenarioDerived | In an application whose Twig template happens to contain the vulnerable naming collision (e.g. a loop variable named 'item' while '{% import _self as item %}' appears in another block or macro), an attacker submits HTML/JavaScript into a data field that is later rendered through that variable's attribute (item.body). Because the escaper incorrectly marked it safe, the markup is printed raw and executes in the victim's browser when they view the page. No public exploit code was identified; a patch commit and a regression test fixture are the only public artifacts. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – Nov 24, 2026
Twig's autoescaping logic can print attacker-controlled values without HTML escaping when a template contains a macro import alias whose name is also reused as an ordinary variable in a different block or macro, producing reflected/stored XSS in pages rendered with that template. Only Twig branches before 3.31.0 are affected (the composer package twig/twig, per CPE cpe:2.3:a:twig:twig), and exploitation is conditional on an application already containing that specific alias/variable name collision plus attacker influence over the rendered value; the assessed vector (CVSS 3.1 AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N) reflects that precondition and the need for a victim to load the affected page. No public exploit code and no confirmed active exploitation were identified at time of analysis, and the vendor-supplied fix is a rule removal in the escaper rather than a runtime mitigation escape hatch.
RemediationAI
Vendor-released patch: upgrade twig/twig to 3.31.0 or later for the 3.x branch, as documented in the advisory (https://github.com/twigphp/Twig/security/advisories/GHSA-63v2-9rx5-wjgr) and the Symfony CVE page (https://symfony.com/cve-2026-133771); the fix commit is https://github.com/twigphp/Twig/commit/3a6745a0d88048474457fa2e69968ebd5267dd5a. Because the flaw only fires on a template-authoring condition, the practical interim control is a template audit rather than a configuration switch: locate every {% import ... as x %} and confirm that no ordinary variable, macro argument or loop variable shares that alias name in another block or macro, and move any template-level import above the block that uses the name - renaming the alias or the variable is behaviour-preserving for rendering but requires reviewing every template that imports _self or another template, which is the main cost. Where renaming is impractical, apply an explicit escape filter to the attribute, item or method output of the colliding variable ({{ item.body|e }} and {{ item['body']|e }}) so the value is escaped despite the buggy safe marking; the trade-off is a risk of double-escaping if the same expression is later rendered under a context where the value is legitimately marked safe, so the filter should be scoped to the colliding variable only. Note that the upstream resolution removes the exemption entirely and that macro calls through an alias remain safe, so no change to macro invocation code is needed. No public exploit code was identified, so emergency containment is not indicated; the vuln.today decision label for this CVE is monitor.
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 template engine whose autoescaping is implemented by two node visitors: EscaperNodeVisitor decides which expressions need an escaping filter, and SafeAnalysisNodeVisitor propagates 'safe' status through the AST. Before the fix, EscaperNodeVisitor collected the alias name of every ImportNode into a $safeVars list and pushed that list into SafeAnalysisNodeVisitor, which then marked any GetAttrExpression rooted in a ContextVariable with a matching name as safe for 'all' output contexts. That rule dates from before Twig 3.0, when macro calls through an alias required the exemption; since 3.0 macro calls have been handled separately, so the rule's only remaining effect was to whitelist ordinary variables that happened to share a name with an alias imported elsewhere in the template. The flaw is an encoding/escaping correctness problem (CWE-79, with CWE-116 improper encoding/escaping) rather than an injection into the engine itself: the trigger requires the template author to have created the name collision, and the impact materializes only when the aliased-name variable's attribute, item or method output carries attacker-supplied data. The upstream fix (commit 3a6745a0) deletes the ImportNode handling, the $safeVars property and setSafeVars() plumbing, and adds a regression fixture (import_alias_name_reused.test) covering an alias in a block, an alias in a macro with a same-named macro argument, and a template-level import placed after the block that uses the name.
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:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N
Network-delivered XSS requiring a victim to load the page (UI:R) and a specific non-default template collision (AC:H); scope changes to the browser (S:C) with limited C/I impact and no availability impact.
Primary rating from Vendor (Symfony).
CVSS VectorVendor: Symfony
DescriptionCVE.org
The escaper considered x.attr, x['key'] and x.method() safe whenever {% import ... as x %} appeared anywhere in the template. Macro calls haven't needed this rule since Twig 3.0. It only matched ordinary variables that have the name of an alias imported in another block or macro, and printed them without escaping:
{% block header %}{% import _self as item %}{{ item.hello() }}{% endblock %} {% block content %}{% for item in items %}{{ item.body }}{% endfor %}{% endblock %}
Here, item.body is printed raw. This leads to XSS when the value comes from an attacker. The same happens with an import in a macro and an argument of the same name in another macro. It also happens with a template-level import placed after the block that uses the name.
The rule is removed. Macro calls through an alias are still considered safe.
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-133920
NVD
CVE.org
EPSS
GitHub
VulDB
Exploit-DB