CVE-2026-133771: Missing autoescaping for a variable named like a macro import alias of another scope

Published Nov 24, 2026
·
Updated

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 Software

1 affected component
Twig Twig

Event History

Nov 24, 2026
CVE Published
via MITRE·01:07 PM
Data Sourced
via MITRE·01:07 PM
DescriptionWeakness
Data Sourced
via NVD·01:17 PM
DescriptionSeverityWeakness

Frequently Asked Questions

1

Which template constructs should be reviewed for exposure?

Review templates where an import alias in one block or macro has the same name as an ordinary variable in another scope. References to that ordinary variable through a property, array key, or method call can be emitted without escaping.

2

What is required for this to become an XSS issue?

The affected ordinary variable must contain attacker-controlled data and be rendered through the alias-colliding name. The vulnerable cases include property access, keyed access, and method calls on that variable.

3

Are legitimate macro calls through an import alias affected?

No. Macro calls through an alias are still considered safe; the issue applies to ordinary variables that happen to reuse an alias name from a different scope.

4

Can import placement or scope cause an otherwise unrelated variable to be treated as safe?

Yes. The issue occurs when an alias is imported in another block or macro, and it can also occur when a template-level import appears after the block that uses the same name. A macro argument sharing the name of an alias imported in another macro is also affected.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203