ZeroHour

CVE-2026-46636

mass

Sandbox allowedMethods bypass in Twig PHP template engine

CVSS 4.0
8.7 high
EPSS
<1%p29
Published
()
Modified
AI analysis

Twig's sandbox security policy unconditionally whitelists every method call on instances of Twig\Markup, and because Twig\Markup is not final, this blanket allowance is inherited by any subclass. The flaw is triggered when an application passes an object of a Markup-derived class into a sandboxed template, which is a common pattern for marking HTML chunks as safe; template authors can then call any public method of that subclass regardless of the configured allowedMethods list. An attacker who can influence template content in such an application could invoke otherwise-restricted public methods, and the CVSS 4.0 score of 8.7 indicates a high potential confidentiality impact with no integrity or availability impact. Any application running an affected Twig version (1.0.0 through before 3.27.0) that uses the sandbox extension together with Markup subclasses is exposed. There is currently no known public proof-of-concept, no CISA KEV listing, and a low EPSS exploitation probability of 0.4%, indicating no confirmed exploitation in the wild.

What to do: Upgrade Twig to version 3.27.0 or later, which fixes the checkMethodAllowed() bypass. If upgrading is not immediately possible, avoid passing objects of Twig\Markup-derived classes into sandboxed templates, or restrict template authors from invoking methods on those objects. Audit all uses of the sandbox extension (sandboxed templates, e.g. via includes or inline sandboxing) to identify Markup subclass inputs and confirm which public methods become reachable to template authors.

Affected
Twig (twig/twig PHP template engine) Twig1.0.0 up to and excluding 3.27.0 (all 1.x, 2.x, and 3.x releases prior to 3.27.0)
Estimated exposure
mass≈1M+ PHP applications bundle Twig (default engine for Symfony and Drupal), though only the subset using the sandbox extension with Markup subclasses is… — Twig is the default templating engine for Symfony and Drupal 8+ and has hundreds of millions of Packagist downloads, so the population of installs carrying the affected library is in the millions, while the vulnerable condition (sandboxed…

Order-of-magnitude estimate by the model from install counts, market share and public scan data it knows; verify before quoting.

Description

Twig is a template language for PHP. From version 1.0.0 to before version 3.27.0, SecurityPolicy::checkMethodAllowed() unconditionally whitelists all method calls on instances of Twig\Markup. Twig\Markup is not final, so subclasses inherit the bypass. An application that passes an object of a Markup-derived class into a sandboxed template (typically to mark a chunk of HTML as safe) inadvertently exposes every public method of that subclass to template authors, regardless of the configured allowedMethods list. This issue has been patched in version 3.27.0.

Weakness
CWE-1336
Vector
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X

In the news

No ingested article mentions this CVE yet.