Sandbox Tag Allow-List Bypass via the Branch of a `guard` Tag That Isn't Selected
- State
- Published
- Severity
- 2.3 Low
- Published
- Nov 24, 2026
- Updated
- Nov 24, 2026
- Reserved
- Nov 20, 2026
Description
The guard tag compiles only one of its branches, depending on whether a callable exists. The other branch was still parsed, though. The extends, use, macro and block tags in it registered their effects on the template. The sandbox doesn't see these tags, since that branch isn't compiled. A sandboxed template allowed to use guard could therefore extend a template, import blocks and define macros, while the policy doesn't allow these tags:
{% guard filter upper %}{% else %}{% extends "parent.html" %}{% endguard %}
The templates reached this way come from the loader of the sandbox, and they are sandboxed too.
What the branch that isn't selected registers on the parser is now discarded.
| Product | Versions |
|---|---|
| twig/twig Twig | 3.15.0 to before 3.31.0 Affected |
| CVSS | Score | How It's Reached | Source |
|---|---|---|---|
| 4.0 | 2.3 Low | Symfony |
Weaknesses
- CWE-863 Incorrect Authorization
References
- CVE-2026-133772Vendor Advisory
- GHSA-qr49-4294-4gmwVendor Advisory
- https://github.com/twigphp/Twig/commit/d5011f4654042f03d8986b5b3ba12a4d85f976f8Patch
Every record here comes from the CVE Program's CVE List. © 1999-2026 The MITRE Corporation. CVE is a registered trademark of The MITRE Corporation. The records are reproduced under the CVE Program terms of use.