Sandbox bypass in Twig guard tag lets templates use disallowed tags
Key facts
- Attack vector
- Network
- Privileges required
- Low
- User interaction
- None
- Attack complexity
- Low
- Attack requirements
- Present
- Impact type
- Security bypass
- Confidentiality · integrity · availability
- Low · None · None
- Fix status
- Fixed
Attack profile from CVSS 4.0 · CNA. Fix status from CNA. Impact type from CWE-863.
Summary
Twig (twig/twig) from 3.15.0 before 3.31.0 parses the unselected branch of the guard tag. The extends, use, macro and block tags in that branch register their effects on the template while the sandbox never checks them (CWE-863). A sandboxed template allowed to use guard can therefore extend templates, import blocks and define macros that the sandbox policy forbids.
Written with Claude Haiku 5.5 from the sources below · 2026-11-24
Description from the CNA
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.
Why it matters now
SSVC decision points
Not available: CISA has not published SSVC decision points for this record.
Affected products
Remediation
The fixed version for twig/twig is 3.31.0.
Written with Claude Haiku 5.5 from the sources below · 2026-11-24
- Fix · CNA twig/twig (Twig) Fixed in 3.31.0
Fixed in the same release
Records fixed by the same vendor advisory or release, as the CNA lists them.
- Release ·
twig/twig 3.31.0
2 records Highest priority Priority LOW 2 LOW
Other records, highest priority first
- TI-2026-97285 Twig skips autoescaping for variables named like import aliasesPriority LOW 13
Timeline
- 2026-11-24 Threatist record created from CVE-2026-133772
References
More Twig vulnerabilities
- TI-2026-97282 Sandbox bypass in Twig join filter exposes object properties CVSS 4.0MEDIUM 5.3
- TI-2026-97281 Twig sandbox bypass through dynamic embed parent expressions CVSS 4.0MEDIUM 5.3
- TI-2026-97279 Sandbox toString() policy bypass in Twig via assignments CVSS 4.0MEDIUM 5.3
- TI-2026-97277 Sandbox toString policy bypass via is true test in Twig CVSS 4.0MEDIUM 5.3
- TI-2026-97287 Unbounded converter cache in Twig markdown-extra exhausts memory CVSS 4.0LOW 2.3
- TI-2026-97285 Twig skips autoescaping for variables named like import aliases CVSS 4.0LOW 2.3
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences