CVE-2026-46640 PUBLISHED

Twig: Arbitrary PHP code execution via `_self.(<string>)` macro-reference compilation

Assigner: GitHub_M
Reserved: 15.05.2026 Published: 14.07.2026 Updated: 15.07.2026

Twig is a template language for PHP. From 3.15.0 until 3.26.0, _self.(<string>) and import-alias dynamic attribute syntax can concatenate an attacker-controlled string into a MacroReferenceExpression name without identifier validation, causing raw PHP to be emitted into the generated template source and executed at template-load time. This issue is fixed in version 3.26.0.

Metrics

CVSS Vector: 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
CVSS Score: 8.7

Product Status

Vendor twigphp
Product Twig
Versions
  • Version >= 3.15.0, < 3.26.0 is affected

References

Problem Types

  • CWE-94: Improper Control of Generation of Code ('Code Injection') CWE