Sandbox `__toString()` policy bypass via the `is true` test
- CVE-2026-133763
- EUVD-2026-133912
Description
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.
Text from the CVE.org record.
Recommendation
Twig twig/twig
- If you run a version from 3.21.0 to before 3.31.1update to 3.31.1 or laterMinor version change: check the release notes
Taken from the version ranges of the CVE.org record. Check the vendor advisory: nothing is said about versions the ranges do not list. Breaking-change risk is read from the version numbers only.
Affected
Twig twig/twig
Affected versions Fixed in from 3.21.0 to before 3.31.1 3.31.1
Product versions from the CVE.org record.
Timeline
- Published
Related news
No article from the followed outlets names this vulnerability.