Read the docs

Sandbox bypass in Twig guard tag lets templates use disallowed tags

Priority LOW 13CWE-863Published · Updated

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

EPSS 0.00533 38th percentileScored 2026-11-30
Fix Fixed twig/twig (Twig): 3.31.0

SSVC decision points

Not available: CISA has not published SSVC decision points for this record.

Affected products

VendorProductAffected versionsFixed inStatusSource
Twigtwig/twig3.15.0 to before 3.31.03.31.0Patch availableCNA
  • twig/twig VendorTwig Affected 3.15.0 to before 3.31.0 Fixed in 3.31.0 Patch available CNA

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

  1. 2026-11-24 Threatist record created from CVE-2026-133772

References

  • 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
See all 10 →

Sources

This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences