CVE-2026-133770: Sandboxed templates can rewrite application-owned `Markup` objects through their constructor
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.
Affected Software
Event History
Frequently Asked Questions
Which deployments are realistically exposed to cross-site scripting through this issue?
Deployments are exposed when sandboxed templates can reach application-owned Twig\Markup objects that are later rendered in non-sandboxed, trusted pages. The described risk is especially relevant where such objects are shared or retained, such as globals in long-running workers.
What must an attacker be able to do to exploit it?
The attacker needs control over content executed as a sandboxed Twig template and access from that template to an application-owned Markup object. They can invoke that object's public __construct() method to replace its content with attacker-controlled markup.
Are templates affected merely by being sandboxed?
No. Rewriting a template's own output does not provide an attacker additional impact. The issue requires a reachable Markup object whose modified content is subsequently rendered elsewhere outside the sandbox.
What change addresses the issue?
The sandbox should no longer permit constructor calls on Twig\Markup objects. The provided advisory states that the sandbox has been changed to disallow calling the Markup constructor.