CVE-2026-46636 Twig: Sandbox method allowlist bypass via `Markup` subclass

High 8.7 Published Updated

Attackers can bypass Twig sandbox restrictions by using subclasses of Markup, exposing unauthorized methods to template authors.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2026-46636?

CVE-2026-46636 is a high-severity vulnerability in twigphp Twig, published on 4 Sep 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official 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

Which versions are affected by CVE-2026-46636?

How do I fix CVE-2026-46636?

Upgrade to a fixed version.

Is CVE-2026-46636 being exploited?

There is no known exploitation of CVE-2026-46636 in the wild and no public exploit code.

Sources

Also known as DEBIAN-CVE-2026-46636, GHSA-64jr-qjx4-w2fh, UBUNTU-CVE-2026-46636.

Is CVE-2026-46636 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free