CVE-2026-46639: Twig sandbox bypass in object-destructuring assignment

CVE-2026-46639 · Severity: high · CVSS 4 · Published 2026-07-14

Twig is a popular template engine for PHP used to generate web pages. A security flaw in its sandbox mode allows users who can edit templates to bypass security restrictions and access sensitive data or functions they should not be able to reach. This could lead to the unauthorized disclosure of information or the execution of unintended actions within the application.

Technologies: twig/twig (Packagist). Vendors: Packagist.

Quick answers

Is CVE-2026-46639 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-46639 being exploited in the wild.
How severe is CVE-2026-46639?
High severity, with a CVSS score of 4, published 14 July 2026.
Which products and versions are affected?
twig/twig (Packagist) >= 3.24.0, < 3.26.0, ECOSYSTEM:introduced=3.24.0,fixed=3.26.0.
Is there a fix for CVE-2026-46639?
Yes. twig/twig (Packagist): upgrade to 3.26.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-46639 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2026-46639?
Check whether you run twig/twig (Packagist) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • twig/twig (Packagist): upgrade to 3.26.0 or later
    composer require twig/twig:^3.26.0

Technical details

A vulnerability exists in Twig's object-destructuring assignment syntax where the compiler hardcodes the sandbox argument to 'false' when calling CoreExtension::getAttribute(). This bypasses the SecurityPolicy checks enforced by the SandboxExtension, even when the extension is active. An attacker with the ability to modify or provide a sandboxed Twig template (requiring only the '{% do %}' tag to be allowed) can exploit this to read any public property or call any public getter method on objects passed to the template. The root cause is located in ObjectDestructuringSetBinary::compile(), which fails to check if the environment has the SandboxExtension enabled. The issue is resolved in version 3.26.0 by correctly forwarding the active sandbox flag.

Affected products

  • twigphp Twig >= 3.24.0, < 3.26.0

Identifiers

  • CVE-2026-46639
  • GHSA-mm6w-gr99-p3jj

Timeline

  • 2026-05-20: patched: Version 3.26.0 released
  • 2026-05-20: advisory: GitHub Security Advisory GHSA-mm6w-gr99-p3jj published
  • 2026-07-14: disclosed: CVE-2026-46639 published to NVD

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.