CVE-2026-133771

NameCVE-2026-133771
DescriptionThe 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.
SourceCVE (at NVD; CERT, ENISA, LWN, oss-sec, fulldisc, Debian ELTS, Red Hat, Ubuntu, Gentoo, SUSE bugzilla/CVE, GitHub advisories/code/issues, web search, more)

Vulnerable and fixed packages

The table below lists information on source packages.

Source PackageReleaseVersionStatus
php-twig (PTS)bookworm, bookworm (security)3.5.1-1+deb12u3vulnerable
trixie (security), trixie3.27.0-0+deb13u1vulnerable
forky3.30.0-1vulnerable
sid3.31.1-1fixed

The information below is based on the following data on fixed versions.

PackageTypeReleaseFixed VersionUrgencyOriginDebian Bugs
php-twigsource(unstable)3.31.0-1

Notes

https://symfony.com/blog/cve-2026-133771-missing-autoescaping-for-a-variable-named-like-a-macro-import-alias-of-another-scope
https://github.com/twigphp/Twig/security/advisories/GHSA-63v2-9rx5-wjgr
https://github.com/twigphp/Twig/commit/3a6745a0d88048474457fa2e69968ebd5267dd5a (v3.31.0)

Search for package or bug name: Reporting problems