CVE-2026-46636 PUBLISHED

Twig: Sandbox method allowlist bypass via `Markup` subclass

Assigner: GitHub_M
Reserved: 15.05.2026 Published: 04.09.2026 Updated: 04.09.2026

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.

Metrics

CVSS 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
CVSS Score: 8.7

Product Status

Vendor twigphp
Product Twig
Versions
  • Version >= 1.0.0, < 3.27.0 is affected

References

Problem Types

  • CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine CWE