Sandboxed templates can rewrite Twig Markup objects through their constructor
Key facts
- Attack vector
- Network
- Privileges required
- Low
- User interaction
- Passive
- Attack complexity
- Low
- Attack requirements
- Present
- Impact type
- Cross-site scripting, Security bypass
- Confidentiality · integrity · availability
- None · Low · None
- Fix status
- Fixed
Attack profile from CVSS 4.0 · CNA. Fix status from CNA. Impact type from CWE-79 and CWE-863.
Summary
Twig, the PHP template engine, allows sandboxed templates to call the public constructor of Twig\Markup objects, which replaces their content. A sandboxed template with access to an application-owned Markup object can rewrite it, and the new content can then appear unescaped in trusted pages that are rendered elsewhere, such as a global in a long-running worker. This is an improper neutralization issue (CWE-79) with incorrect authorization (CWE-863), and an attacker needs low privileges and user interaction.
Written with Claude Haiku 5.5 from the sources below · 2026-11-24
Description from the CNA
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.
Why it matters now
SSVC decision points
Not available: CISA has not published SSVC decision points for this record.
Affected products
Remediation
Upgrade twig/twig to version 3.31.1, which no longer allows calling the constructor of Markup objects in the sandbox.
Written with Claude Haiku 5.5 from the sources below · 2026-11-24
- Fix · CNA twig/twig (Twig) Fixed in 3.31.1
Fixed in the same release
Records fixed by the same vendor advisory or release, as the CNA lists them.
- Release ·
twig/twig 3.31.1
7 records Highest priority Priority LOW 7 LOW
Other records, highest priority first
- TI-2026-97282 Sandbox bypass in Twig join filter exposes object propertiesPriority LOW 25
- TI-2026-97281 Twig sandbox bypass through dynamic embed parent expressionsPriority LOW 25
- TI-2026-97279 Sandbox toString() policy bypass in Twig via assignmentsPriority LOW 25
Timeline
- 2026-11-24 Threatist record created from CVE-2026-133770
References
More Twig vulnerabilities
- TI-2026-97282 Sandbox bypass in Twig join filter exposes object properties CVSS 4.0MEDIUM 5.3
- TI-2026-97281 Twig sandbox bypass through dynamic embed parent expressions CVSS 4.0MEDIUM 5.3
- TI-2026-97279 Sandbox toString() policy bypass in Twig via assignments CVSS 4.0MEDIUM 5.3
- TI-2026-97277 Sandbox toString policy bypass via is true test in Twig CVSS 4.0MEDIUM 5.3
- TI-2026-97287 Unbounded converter cache in Twig markdown-extra exhausts memory CVSS 4.0LOW 2.3
- TI-2026-97286 Sandbox bypass in Twig guard tag lets templates use disallowed tags CVSS 4.0LOW 2.3
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences