CVE-2026-46639
JSON

7.1high

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

Severity
7.1high CVSS:4.0 by GitHub_M
Exploit likelihood
0.43% (higher than 38% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-mm6w-gr99-p3jj

Description

Twig is a template language for PHP. From 3.24.0 until 3.26.0, object-destructuring assignment compiles CoreExtension::getAttribute() with the sandbox argument hardcoded to false, disabling property and method policy checks and allowing an attacker with write access to a sandboxed Twig template to read public properties or invoke public getters on objects passed to the template engine. This issue is fixed in version 3.26.0.

Affected

Product or packageVersionsReported by
twigphp Twig>= 3.24.0, < 3.26.0CVE List
twig/twig (Packagist)from 3.24.0 before 3.26.0GitHub Advisory Database
symfony twigfrom 3.24.0 before 3.26.0NVD

All scores

GitHub_M7.1high CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:L/VA:N/SC:N/SI:N/SA:N
GitHubhigh CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
NVD6.5medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N

Classification

CWE-693

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

Twig is a template language for PHP. From 3.24.0 until 3.26.0, object-destructuring assignment compiles CoreExtension::getAttribute() with the sandbox argument hardcoded to false, disabling property and method policy checks and allowing an attacker with write access to a sandboxed Twig template to read public properties or invoke public getters on objects passed to the template engine. This issue is fixed in version 3.26.0.

GitHub Advisory Database
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.

NVD (es)

Twig es un lenguaje de plantillas para PHP. Desde la versión 3.24.0 hasta la 3.26.0, la asignación de desestructuración de objetos compila CoreExtension::getAttribute() con el argumento sandbox codificado a false, deshabilitando las comprobaciones de políticas de propiedades y métodos y permitiendo a un atacante con acceso de escritura a una plantilla Twig en un sandbox leer propiedades públicas o invocar captadores públicos en objetos pasados al motor de plantillas. Este problema está solucionado en la versión 3.26.0.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-46639 changed 2026-07-15CVE Terms of Use
GitHub Advisory DatabaseGHSA-mm6w-gr99-p3jj changed 2026-09-10CC-BY-4.0
NVDCVE-2026-46639 changed 2026-10-24Public domain