Skip to main content
Menu
Advisories

Description The sandbox checks that a template may call toString() on an object before converting it to a string

GHSA-RC9G-XWX4-RMFHPublished Updated GitHub

Description

The sandbox checks that a template may call __toString() on an object before converting it to a string. It didn't check the input of tests. The PHP callable of a test may convert this input to a string, for example when its parameter is typed as string. PHP then calls __toString() on an object without the sandbox checking it first:

{{ obj is upperish }}

Applications are affected when they register such a test and allow it in the sandbox. No built-in test is affected.

Resolution

The sandbox now checks the input of tests like the input of filters. The built-in tests that never convert their input to a string still skip the check.

The patch for this issue is available here for branch 3.x.

Credits

We would like to thank Arpit Jain for reporting the issue, and Fabien Potencier for providing the fix.

Affected versions

References

GitHub · twigphp/Twig