CVE-2026-46640: CWE-94: Improper Control of Generation of Code ('Code Injection') in twigphp Twig
Twig versions from 3.15.0 up to but not including 3.26.0 contain a code injection vulnerability. This occurs because dynamic attribute syntax can concatenate attacker-controlled strings into macro references without proper validation, leading to execution of raw PHP code at template load time. The issue is fixed in version 3.26.0.
AI Analysis
Technical Summary
CVE-2026-46640 is a code injection vulnerability in the Twig PHP template engine affecting versions 3.15.0 through 3.25.x. The vulnerability arises from improper control of code generation where dynamic attribute syntax (_self.(<string>) and import-alias) allows attacker-controlled strings to be concatenated into MacroReferenceExpression names without identifier validation. This results in raw PHP code being emitted and executed during template loading. The vulnerability is resolved in Twig version 3.26.0.
Potential Impact
An attacker can inject and execute arbitrary PHP code during template load time, potentially leading to full system compromise or unauthorized actions within the application context. The vulnerability has a high CVSS 4.0 score of 8.7, indicating significant impact with network attack vector, low attack complexity, no privileges required, and no user interaction needed.
Mitigation Recommendations
Upgrade Twig to version 3.26.0 or later, where this vulnerability is fixed. No official patch or temporary fix is indicated other than upgrading. Since this is not a cloud service, remediation depends on user-side upgrade.
CVE-2026-46640: CWE-94: Improper Control of Generation of Code ('Code Injection') in twigphp Twig
Description
Twig versions from 3.15.0 up to but not including 3.26.0 contain a code injection vulnerability. This occurs because dynamic attribute syntax can concatenate attacker-controlled strings into macro references without proper validation, leading to execution of raw PHP code at template load time. The issue 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 is a code injection vulnerability in the Twig PHP template engine affecting versions 3.15.0 through 3.25.x. The vulnerability arises from improper control of code generation where dynamic attribute syntax (_self.(<string>) and import-alias) allows attacker-controlled strings to be concatenated into MacroReferenceExpression names without identifier validation. This results in raw PHP code being emitted and executed during template loading. The vulnerability is resolved in Twig version 3.26.0.
Potential Impact
An attacker can inject and execute arbitrary PHP code during template load time, potentially leading to full system compromise or unauthorized actions within the application context. The vulnerability has a high CVSS 4.0 score of 8.7, indicating significant impact with network attack vector, low attack complexity, no privileges required, and no user interaction needed.
Mitigation Recommendations
Upgrade Twig to version 3.26.0 or later, where this vulnerability is fixed. No official patch or temporary fix is indicated other than upgrading. Since this is not a cloud service, remediation depends on user-side upgrade.
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/14/2026, 22:19:24 UTC
Last updated: 07/14/2026, 22:27:30 UTC
Views: 2
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.