CVE-2026-133771

published 24 Nov 2026 · updated 24 Nov 2026

Missing autoescaping for a variable named like a macro import alias of another scope

2.3LowCVSS 2.3EPSS 1%

No exploitation in the wild has been reported. EPSS puts the chance of exploitation in the next 30 days at 1%. Fixed in 3.31.0.

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

Vendors, products and packages with version ranges

VendorProductVersionsFixed
twig<3.31.03.31.0

Timeline

Every event on this vulnerability

Embed

A live severity badge for an advisory, README or ticket

CVE-2026-133771 severity on Zeptric[![CVE-2026-133771](https://zeptric.io/badge/cve/CVE-2026-133771.svg)](https://zeptric.io/cve/CVE-2026-133771)