Twig 3.31.1 Patch Fixes Sandbox Escape Allowing Markup Object Rewriting

2 min read
Source: CVEs | Zero Wire | Cloudflare Radar
Twig 3.31.1 Patch Fixes Sandbox Escape Allowing Markup Object Rewriting
Photo: CVEs | Zero Wire | Cloudflare Radar
TL;DR

A low-severity vulnerability in the Twig templating engine, identified as CVE-2026-133770, allowed sandboxed templates to modify application-owned Markup objects. The flaw, rated 2.1 on the CVSS 4.0 scale, enabled attackers to replace content in trusted, non-sandboxed pages by calling the constructor on shared objects. Symfony released version 3.31.1 to block this constructor access.

Key points

  • The vulnerability affects Twig versions prior to 3.31.1, where the sandbox mechanism failed to restrict calls to the public constructor of Twig\Markup objects.
  • Attackers could exploit this by executing code like {% do banner.__construct('alert(1)', 'UTF-8') %} to overwrite the content of Markup objects shared across long-running workers.
  • The flaw carries a CVSS 4.0 score of 2.1 (Low), with low impact on integrity and no impact on confidentiality or availability, but requires low privileges and passive user interaction.
  • The issue is classified under CWE-79 (Improper Neutralization of Input During Web Page Generation) and CWE-863 (Incorrect Authorization), indicating a failure in input validation and access control.
  • Symfony addressed the issue by updating the sandbox to prevent the calling of the Markup constructor, with the fix available in the latest release.

Background

This incident follows a series of recent low-to-medium severity vulnerabilities in web applications and plugins, including a DumbAssets flaw (CVE-2026-134789) and a WordPress plugin issue (CVE-2026-107593) that allowed unauthorized modifications to content or links. While those cases involved different mechanisms, they highlight ongoing concerns regarding insufficient permission checks and input validation in widely used software components.

Why it matters

Although rated low severity, this vulnerability demonstrates a critical failure in sandbox isolation, allowing content injection into trusted, non-sandboxed pages. This can lead to cross-site scripting or other integrity issues in applications relying on Twig for templating, particularly in long-running worker environments where shared state is common.

What to watch

Developers using Twig should immediately upgrade to version 3.31.1 or later to apply the fix. Organizations should audit their use of shared Markup objects in sandboxed contexts to ensure no residual risks remain, and monitor for any unusual template execution patterns.

Share this article

Want the full story? Read the original reporting

Read on CVEs | Zero Wire | Cloudflare Radar