CVE-2026-46640: CWE-94: Improper Control of Generation of Code ('Code Injection') in twigphp Twig
Twig, a PHP template language, has a code injection vulnerability (CWE-94) in versions from 3.15.0 up to but not including 3.26.0. The issue arises from improper validation of dynamic attribute syntax that allows attacker-controlled strings to be concatenated into MacroReferenceExpression names, resulting in raw PHP code execution at template load time. This vulnerability is rated high severity with a CVSS score of 8.7. The vulnerability is fixed in version 3.26.0.
AI Analysis
Technical Summary
CVE-2026-46640 describes a code injection vulnerability in Twig versions >=3.15.0 and <3.26.0. The flaw occurs because the _self.(<string>) and import-alias dynamic attribute syntax can incorporate attacker-controlled strings into MacroReferenceExpression names without proper identifier validation. This leads to raw PHP code being emitted into the generated template source and executed when the template loads. The vulnerability allows remote code execution with no user interaction required and low attack complexity, but requires some privileges (PR:L). The issue is resolved in Twig 3.26.0.
Potential Impact
An attacker able to supply crafted input to the vulnerable Twig template syntax can cause arbitrary PHP code execution at template load time. This can lead to full compromise of the application environment running Twig templates. The vulnerability has a high CVSS score (8.7) indicating significant impact, including high confidentiality, integrity, and availability impacts.
Mitigation Recommendations
This vulnerability is fixed in Twig version 3.26.0. Users should upgrade to version 3.26.0 or later to remediate this issue. No other official remediation or temporary fix is indicated. Patch status is confirmed by the vendor advisory stating the issue is fixed in 3.26.0.
CVE-2026-46640: CWE-94: Improper Control of Generation of Code ('Code Injection') in twigphp Twig
Description
Twig, a PHP template language, has a code injection vulnerability (CWE-94) in versions from 3.15.0 up to but not including 3.26.0. The issue arises from improper validation of dynamic attribute syntax that allows attacker-controlled strings to be concatenated into MacroReferenceExpression names, resulting in raw PHP code execution at template load time. This vulnerability is rated high severity with a CVSS score of 8.7. The vulnerability is fixed in version 3.26.0.
CVSS v4.0
Score 8.7high
Affected software
Weaknesses
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
CVE-2026-46640 describes a code injection vulnerability in Twig versions >=3.15.0 and <3.26.0. The flaw occurs because the _self.(<string>) and import-alias dynamic attribute syntax can incorporate attacker-controlled strings into MacroReferenceExpression names without proper identifier validation. This leads to raw PHP code being emitted into the generated template source and executed when the template loads. The vulnerability allows remote code execution with no user interaction required and low attack complexity, but requires some privileges (PR:L). The issue is resolved in Twig 3.26.0.
Potential Impact
An attacker able to supply crafted input to the vulnerable Twig template syntax can cause arbitrary PHP code execution at template load time. This can lead to full compromise of the application environment running Twig templates. The vulnerability has a high CVSS score (8.7) indicating significant impact, including high confidentiality, integrity, and availability impacts.
Mitigation Recommendations
This vulnerability is fixed in Twig version 3.26.0. Users should upgrade to version 3.26.0 or later to remediate this issue. No other official remediation or temporary fix is indicated. Patch status is confirmed by the vendor advisory stating the issue is fixed in 3.26.0.
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2026-05-15T20:11:54.584Z
- Cvss Version
- 4.0
- State
- PUBLISHED
- Remediation Level
- null
Threat ID: 6a56aea268715ace4342b10b
Added to database: 07/14/2026, 21:48:18 UTC
Last enriched: 07/22/2026, 23:08:59 UTC
Last updated: 08/26/2026, 22:52:11 UTC
Views: 58
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.