# GHSA-R34X-HH9H-9Q9C: Sandboxed templates can rewrite application-owned Markup objects through their constructor

- Database: GitHub
- Severity: CVSS 2.1 (Low)
- Published: 2026-11-24
- Modified: 2026-11-24

## Tracked as

- [CVE-2026-133770](https://cve.now/CVE-2026-133770.md): twig/twig cross-site scripting via sandboxed template Markup objects

## Affected versions

- twig/twig (Packagist): fixed in 3.31.1

## Description

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

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

### Resolution

The sandbox no longer allows calling the constructor of `Markup` objects.

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

### Credits

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

## References

- https://github.com/twigphp/Twig/security/advisories/GHSA-r34x-hh9h-9q9c

Page: https://cve.now/GHSA-R34X-HH9H-9Q9C

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