Sandboxed templates can rewrite application-owned `Markup` objects through their constructor
- CVE-2026-133770
- EUVD-2026-133919
Description
The sandbox allows every method of Twig\Markup objects, including their public constructor. A sandboxed template can therefore call __construct() on any Markup object that it reaches, and replace its content: {% do banner.__construct('<script>alert(1)</script>', 'UTF-8') %} A template gains nothing by rewriting its own output. The impact is on the Markup objects that come from the application and are also rendered elsewhere, like a global in a long-running worker. Their new content then ends up in trusted pages that aren't sandboxed. The sandbox no longer allows calling the constructor of Markup objects.
Text from the CVE.org record.
Recommendation
Twig twig/twig
- If you run a version before 3.31.1update to 3.31.1 or later
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 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.