CVE-2026-133771
Published:November 24, 2026
Updated:November 26, 2026
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.
Affected Packages
https://github.com/twigphp/Twig.git (GITHUB):
Affected version(s) >=v1.9.1 <v3.31.0 || >=v2.0.0 <v3.31.0 || >=v3.0.0-BETA1 <v3.31.0Fix Suggestion:
Update to version v3.31.0https://github.com/twigphp/Twig.git (GITHUB):
Affected version(s) =v4.0.0-alpha1 <v4.0.0-beta1Fix Suggestion:
Update to version v4.0.0-beta1twig/twig (PHP):
Affected version(s) >=v2.0.0 <v3.31.0 || >=v1.9.1 <v3.31.0 || >=v3.0.0-BETA1 <v3.31.0Fix Suggestion:
Update to version v3.31.0twig/twig (PHP):
Affected version(s) =v4.0.0-alpha1 <v4.0.0-beta1Fix Suggestion:
Update to version v4.0.0-beta1Related ResourcesĀ (7)
Do you need more information?
Contact UsCVSS v4
Base Score:
2.3
Attack Vector
NETWORK
Attack Complexity
LOW
Attack Requirements
PRESENT
Privileges Required
NONE
User Interaction
PASSIVE
Vulnerable System Confidentiality
NONE
Vulnerable System Integrity
NONE
Vulnerable System Availability
NONE
Subsequent System Confidentiality
LOW
Subsequent System Integrity
LOW
Subsequent System Availability
NONE
CVSS v3
Base Score:
6.1
Attack Vector
NETWORK
Attack Complexity
LOW
Privileges Required
NONE
User Interaction
REQUIRED
Scope
CHANGED
Confidentiality
LOW
Integrity
LOW
Availability
NONE
Weakness Type (CWE)
EPSS
Base Score:
0.67