twig/twig security advisory
CVE-2026-46636: Sandbox filter, tag and function allow-list bypass when sandbox state changes between renders in twig/twig
CVE-2026-46636 is a high-severity template injection vulnerability in the PHP package twig/twig (CVSS 8.7), published 4 September 2026. It is fixed in 3.27.0; earlier versions are affected. It can be exploited without an account.
high 8.7 published 2026-09-04 · updated 2026-09-25
- Affected versions
- >= 1.0.0, < 3.27.0
- Fixed in
- 3.27.0
- Newest release
- 3.30.0
- Severity
- High · CVSS 8.7
- Type
- Template injection
CWE-1336 - Exploited in the wild
- Not on the CISA KEV list
checked 2026-11-04
Is your twig/twig version affected?
Who can exploit CVE-2026-46636
- Access: No account. Anyone who can send a request to an app that uses the affected code.
CVSS vector (scored by GitHub): 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
How to fix CVE-2026-46636 in twig/twig
- Find the installed version:
composer show twig/twig. If you never required it yourself,composer why twig/twigshows which package pulls it in. - Update it:
composer update twig/twig --with-all-dependencies. You need 3.27.0 or newer. - If Composer will not go that high, your composer.json constraint is holding it back. Widen it (for example
"twig/twig": "^3.27.0"if you can take that version), or upgrade the package that requires it. - Run
composer audit. It reads the same advisory data and should no longer list CVE-2026-46636. - Commit composer.lock and deploy it. On the server, run
composer install --no-devfrom the lock file, notcomposer update.
If you cannot upgrade yet
- Never pass user-controlled data to unserialize() or to template rendering, and restrict who can edit templates or settings.
- Put a web application firewall in front of the app and watch for new PHP files or admin users.
- If your app does not use the affected feature, note that in your audit, but still plan the upgrade.
The CVE-2026-46636 advisory
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.
References
- GitHub security advisory GHSA-64jr-qjx4-w2fh github.com
- Symfony security advisory symfony.com
- Security-tracker security advisory security-tracker.debian.org
- security-tracker.debian.org security-tracker.debian.org
Other twig/twig advisories
- high CVE-2026-49981: Twig: Sandbox filter, tag and function allow-list bypass when sandbox state changes between renders for a cached Template 2026-07-01
- medium CVE-2026-48807: Sandbox __toString() policy bypass via Traversable in join/replace and in/not in operators 2026-05-27
- low CVE-2026-48805: Sandbox state regression in deprecated internal wrappers in src/Resources/core.php 2026-05-27
- medium CVE-2026-48808: Sandbox property allowlist bypass via the column filter under SourcePolicyInterface 2026-05-27
- medium CVE-2026-48806: Sandbox __toString() policy bypass via dynamic mapping keys 2026-05-27
- low CVE-2026-47730: XSS in profiler HtmlDumper via unescaped template and profile names 2026-05-20
Related
Need help patching or upgrading? Laskyr does PHP and Laravel security fixes and upgrades. Tell us what you run and we reply with a plan and a price.
Ask about a fixWhere this data comes from
- Affected and fixed versions: the Packagist security advisories API (GitHub Advisory Database and FriendsOfPHP), the same data
composer audituses. Synced 2026-11-03. - Description, score, weakness and references: NIST National Vulnerability Database (NVD), checked 2026-11-04. This product uses data from the NVD API but is not endorsed or certified by the NVD.
- Exploited-in-the-wild status: the CISA Known Exploited Vulnerabilities catalog, checked 2026-11-04.
- Compiled by Daniel Lasek at Laskyr from the sources above. The summary, “who can exploit it”, “how to fix it” and hardening sections are our plain-English reading of the record and are generated from it. The quoted description is the record's own text. Spot an error? Tell us.