Loading...
Skip to main content

CVE-2026-46639 — Vulnerability in twig/twig — CVE Details

HIGH

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

Published May 21, 2026Updated September 10, 2026Source: osv

Summary

### 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: ```php 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.

Advisory Timeline

  • First published May 21, 2026 (144 days ago).
  • Last revised September 10, 2026 — 111 days after initial publication.

Remediation

Upgrade to the fixed version using your package manager.

Composer
Update twig/twig to 3.26.0 or later
composer require "twig/twig:^3.26.0"

After upgrading, run your dependency scanner again to confirm the vulnerability is resolved.

Affected Packages (1)

Affects 1 ecosystem: packagist (1).

PackageEcosystemAffectedFixed In
twig/twig
packagist
v3.24.0, v3.25.03.26.0

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

  • CWE-693
    Protection Mechanism FailureMITRE

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 8.8 score means for each attack dimension.

Attack Vector
Network
Attack Complexity
Low
Privileges Required
Low
User Interaction
None
Scope
—
Confidentiality
—
Integrity
—
Availability
—

CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N

Frequently Asked Questions

What is CVE-2026-46639?
Twig: Sandbox property and method bypass via object-destructuring assignment This vulnerability has been assigned a severity rating of HIGH (CVSS score: 8.8/10).
How do I check if my project is affected by CVE-2026-46639?
CVE-2026-46639 affects twig/twig. Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-46639 and 200,000+ other known vulnerabilities.

Severity & Exploitability

CVSS Score
8.8

High exploitability or significant impact. Prioritize remediation within days.

Also Known As

GHSA-mm6w-gr99-p3jj

Related CVEs

Check if you're affected

Scan your dependencies to see if this vulnerability affects your projects.

Scan Your Dependencies