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

Published Sep 4, 2026
·
Updated

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.

Affected Software

2 affected componentsFixes available
Twig>=1.0.0<3.27.0
debian/php-twig<=3.5.1-1+deb12u3
3.27.0-0+deb13u13.28.0-1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade debian/php-twig to a version that resolves this vulnerability.

    Fixed in 3.27.0-0+deb13u1Fixed in 3.28.0-1
  2. Upgrade

    Upgrade Twig (Twig") to a version that resolves this vulnerability.

    Fixed in 3.27.0

Event History

Sep 4, 2026
CVE Published
via MITRE·10:07 PM
Data Sourced
via MITRE·10:07 PM
DescriptionWeakness
Data Sourced
via Debian·10:15 PM
DescriptionAffected Software
Data Sourced
via NVD·10:17 PM
DescriptionSeverityWeakness

Frequently Asked Questions

1

Which applications are exposed to this bypass?

Applications are exposed only if they render sandboxed Twig templates and pass an instance of a class derived from Twig\Markup into those templates. This commonly occurs when an application uses such an object to designate HTML as safe.

2

What access does an attacker need to exploit it?

An attacker needs the ability to cause method calls in a sandboxed template against a supplied Markup-derived object. Public methods of that subclass can then be invoked even when they are absent from the configured allowedMethods list.

3

Are default sandbox method restrictions sufficient to prevent exploitation?

No. For instances of Twig\Markup and its subclasses, the affected check unconditionally allowed method calls, bypassing the configured allowedMethods restrictions.

4

What can be done before upgrading?

Do not pass objects derived from Twig\Markup into sandboxed templates. Where feasible, pass only the required string or data values instead of the object, preventing template authors from accessing the subclass's public methods.

5

How can I determine whether an application is affected?

Review sandboxed template rendering paths for values that are instances of Twig\Markup subclasses, and identify the installed Twig version. Versions from 1.0.0 through versions before 3.27.0 are affected.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203