# GHSA-567W-CX2V-JC85: Description The sandbox checks that a template may call toString() on an object before converting it to a string

- Database: GitHub
- Severity: CVSS 5.3 (Medium)
- Published: 2026-11-24
- Modified: 2026-11-24

## Tracked as

- [CVE-2026-133763](https://cve.now/CVE-2026-133763.md): twig/twig sandbox policy bypass via the is true test

## Affected versions

- twig/twig (Packagist): from 3.21.0, fixed in 3.31.1

## Description

### 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:

```twig
{{ 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.

### Resolution

The sandbox now checks the result of tests like the result of filters and functions.

The patch for this issue is available [here](https://github.com/twigphp/Twig/commit/a41bd2dd466d771cc384b9730be6190eb5a4f4d0) for branch 3.x.

### Credits

We would like to thank [Eric Labrador Sainz](https://github.com/e1abrador), [杨延健](https://github.com/Bingoyyj) and [Inanna Malick](https://github.com/inanna-malick) for independently reporting the issue, and Fabien Potencier for providing the fix.

## References

- https://github.com/twigphp/Twig/security/advisories/GHSA-567w-cx2v-jc85

Page: https://cve.now/GHSA-567W-CX2V-JC85

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
