Read the docs

Sandbox toString policy bypass via is true test in Twig

Priority LOW 25CWE-693Published · Updated

Key facts

Attack vector
Network
Privileges required
Low
User interaction
None
Attack complexity
Low
Attack requirements
None
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-693.

Summary

Twig's sandbox fails to check the result of the is true test, so a sandboxed template can print an object through a denied toString() method. The flaw affects twig/twig from 3.21.0 before 3.31.1 and is classified as CWE-693. A remote attacker with low privileges can exploit it by writing a template that applies the is true test to an object, and no tag needs to be allowed. A test in a boolean context is not affected.

Written with Claude Haiku 5.5 from the sources below · 2026-11-24

Description from the CNA

The sandbox checks that a template may call toString() on an object before converting it to a string. For an object, the is true test evaluates to the object itself, and that result wasn't checked. A sandboxed template could therefore print an object through a denied toString() method: {{ obj is true }} The same applies when the result is concatenated or passed to a filter. No tag needs to be allowed. A test in a boolean context, like {% if obj is true %}, isn't affected, since it doesn't convert the object to a string. The sandbox now checks the result of tests like the result of filters and functions.

Why it matters now

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

SSVC decision points

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

Affected products

VendorProductAffected versionsFixed inStatusSource
Twigtwig/twig3.21.0 to before 3.31.13.31.1Patch availableCNA
  • twig/twig VendorTwig Affected 3.21.0 to before 3.31.1 Fixed in 3.31.1 Patch available CNA

Remediation

Update twig/twig to version 3.31.1 or later. The sandbox now checks the result of tests in the same way as the result of filters and functions.

Written with Claude Haiku 5.5 from the sources below · 2026-11-24

  • Fix · CNA twig/twig (Twig) Fixed in 3.31.1

Fixed in the same release

Records fixed by the same vendor advisory or release, as the CNA lists them.

  • Release ·

    twig/twig 3.31.1

    7 records Highest priority Priority LOW 7 LOW

    Other records, highest priority first

    • TI-2026-97282 Sandbox bypass in Twig join filter exposes object propertiesPriority LOW 25
    • TI-2026-97281 Twig sandbox bypass through dynamic embed parent expressionsPriority LOW 25
    • TI-2026-97279 Sandbox toString() policy bypass in Twig via assignmentsPriority LOW 25

Timeline

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

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-97287 Unbounded converter cache in Twig markdown-extra exhausts memory CVSS 4.0LOW 2.3
  • TI-2026-97286 Sandbox bypass in Twig guard tag lets templates use disallowed tags 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