Sandboxed templates can rewrite application-owned `Markup` objects through their constructor

State
Published
Severity
2.1 Low
Published
Nov 24, 2026
Updated
Nov 24, 2026
Reserved
Nov 20, 2026

Read the record on cve.org

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.

ProductVersions
twig/twig Twigbefore 3.31.1 Affected

Weaknesses

  • CWE-79 Improper Neutralization of Input During Web Page Generation
  • CWE-863 Incorrect Authorization

References

Every record here comes from the CVE Program's CVE List. © 1999-2026 The MITRE Corporation. CVE is a registered trademark of The MITRE Corporation. The records are reproduced under the CVE Program terms of use.

© 2026 NVIDIA, the NVIDIA logo, and NVIDIA Inception are trademarks and/or registered trademarks of NVIDIA Corporation in the U.S. and other countries.