CVE-2026-133771twig/twig Cross-site Scripting (XSS)
NVD
Vulnerability Summary
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.
{% 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.
CVSS v4.0 Base Metrics — Score 2.3 (LOW)
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:NAttack VectorNetwork
Attack ComplexityLow
Attack RequirementsPresent
Privileges RequiredNone
User InteractionPassive
Confidentiality (Vulnerable System)None
Integrity (Vulnerable System)None
Availability (Vulnerable System)None
Confidentiality (Subsequent System)Low
Integrity (Subsequent System)Low
Availability (Subsequent System)None
Affected & Patched Versions
- twig/twig < 3.31.0
- twig/twig 3.31.0
What to do
Fix it during your normal patch cycle. No exploitation is confirmed yet.
- Check whether you run twig/twig and which version.
- Update to a patched version listed above, then confirm the new version.
Timeline
- Nov 24, 2026Published
- Nov 24, 2026Record last modified
Score, severity and exploitation changes are tracked from the day Watchtower started logging them.
Get notified about new twig/twig CVEsYou are reading CVE-2026-133771. Get an email when KEV listings, exploits or new CVEs match your stack.
Set up CVE alertsExternal References
Data last checked: Nov 24, 2026 14:13 UTC