Arbitrary Code Injection Affecting twig/twig package, versions >=3.15.0, <3.26.0


Severity

Recommended
0.0
critical
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

EPSS
0.41% (33rd percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Arbitrary Code Injection vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-PHP-TWIGTWIG-16776789
  • published20 May 2026
  • disclosed20 May 2026
  • creditClaude Mythos

Introduced: 20 May 2026

CVE-2026-46640  (opens in a new tab)
CWE-94  (opens in a new tab)

How to fix?

Upgrade twig/twig to version 3.26.0 or higher.

Overview

twig/twig is a flexible, fast, and secure template language for PHP.

Affected versions of this package are vulnerable to Arbitrary Code Injection via the obj.(expr) dynamic attribute syntax and MacroReferenceExpression::compile(). An attacker can execute arbitrary PHP code by supplying a crafted string literal expression on _self or an imported template alias, causing attacker-controlled input to be emitted directly into generated PHP source during macro compilation without identifier validation. The injected code executes when the compiled template is loaded, bypassing checkSecurity() and completely escaping the sandbox.

CVSS Base Scores

version 4.0
version 3.1