HighGHSA-mm6w-gr99-p3jjCVE-2026-46639

Twig: Sandbox property and method bypass via object-destructuring assignment

Published 21 May 2026 · Updated 10 Sept 2026

Is your project on an affected twig/twig?

Private repo? Upload its lockfile instead, or connect GitHub to check every repo.

Affected package

twig/twigComposer
Affected
>=3.24.0 <3.26.0
Fixed in
3.26.0
Update to the fixed version for your release line, for example:composer require twig/twig:^3.26.0

Details

Description

The object-destructuring assignment syntax introduced in Twig 3.24.0 generates a call to CoreExtension::getAttribute() with the $sandboxed argument hardcoded to false, regardless of whether a SandboxExtension is active. This permanently disables the sandbox's property and method policy checks for every destructuring expression.

ObjectDestructuringSetBinary::compile() emits:

CoreExtension::getAttribute($this->env, $this->source, ..., \Twig\Template::ANY_CALL, false, false, false, ...);
//                                                                                ^^^^^
//                                                                       sandbox check never runs

Whereas GetAttrExpression::compile() correctly passes $env->hasExtension(SandboxExtension::class).

An attacker with write access to a sandboxed Twig template can read any public property or invoke any public getter on objects passed to the template engine, bypassing SecurityPolicy restrictions. The exploit requires only the {% do %} tag to be in allowedTags, which is a common configuration.

Resolution

The destructuring compiler now forwards the active sandbox flag to getAttribute() so property/method allowlists are enforced.

Credits

Twig would like to thank Anvil Secure in collaboration with Claude and Anthropic Research for reporting and fixing the issue.

Is GHSA-mm6w-gr99-p3jj in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected twig/twig, and gives you the command that fixes it.

More advisories for twig/twig

  • HighCVE-2026-49981Twig: Sandbox filter, tag and function allow-list bypass when sandbox state changes between renders for a cached `Template` · 1 Jul 2026
  • MediumCVE-2026-48808Twig: Sandbox property allowlist bypass via the `column` filter under `SourcePolicyInterface` · 30 Jun 2026
  • MediumCVE-2026-48807Twig: Sandbox `__toString()` policy bypass via `Traversable` in `join` and `replace` filters · 30 Jun 2026
  • MediumCVE-2026-48806Twig: Sandbox `__toString()` policy bypass via dynamic mapping keys · 30 Jun 2026
  • LowCVE-2026-48805Twig: Sandbox state regression in deprecated internal wrappers in `src/Resources/core.php` · 30 Jun 2026
  • HighCVE-2026-47732Twig: Sandbox: multiple `__toString()` policy bypasses via unguarded string coercion points · 5 Jun 2026
All 24 advisories for twig/twig

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.