Sandbox `__toString()` policy bypass via spread arguments
- State
- Published
- Severity
- 2.3 Low
- Published
- Nov 24, 2026
- Updated
- Nov 24, 2026
- Reserved
- Nov 20, 2026
Description
Since Twig 3.28.0, the sandbox skips the toString() check of an argument whose PHP parameter can't hold a string, like an int. A spread argument was mapped to a single parameter, although it fills every parameter from its position on. A sandboxed template could therefore call a denied toString() method:
{{ tag(...[1, obj]) }}
Here, the first parameter of tag() is an int, and a later one accepts strings. Applications are affected when they allow such a function, filter or test in the sandbox. No built-in callable is affected.
A spread argument is now checked unless every parameter that it can fill has a safe type.
| Product | Versions |
|---|---|
| twig/twig Twig | 3.28.0 to before 3.31.1 Affected |
| CVSS | Score | How It's Reached | Source |
|---|---|---|---|
| 4.0 | 2.3 Low | Symfony |
Weaknesses
References
- CVE-2026-133766Vendor Advisory
- GHSA-56wp-8m9q-4354Vendor Advisory
- https://github.com/twigphp/Twig/commit/7af821c372f52cc9447afeba9e042de44b738222Patch
Every record here comes from the CVE Program's CVE List. © 1999-2026 The MITRE Corporation. CVE is a registered trademark of The MITRE Corporation. The records are reproduced under the CVE Program terms of use.