CVE-2026-46633: CWE-94: Improper Control of Generation of Code ('Code Injection') in twigphp Twig
Twig versions prior to 3.26.0 contain a code injection vulnerability due to improper escaping of single quotes in template names used in {% use %} tags. This allows crafted template names to inject arbitrary PHP code into compiled cache files. The issue is fixed in version 3.26.0.
AI Analysis
Technical Summary
Twig, a PHP templating engine, had a vulnerability (CVE-2026-46633) in versions before 3.26.0 where the Compiler::string() method failed to escape single quotes in template names used in {% use %} tags. This flaw permits an attacker to terminate the single-quoted string literal in the compiled PHP cache file and inject arbitrary PHP expressions, leading to code injection. The vulnerability is classified under CWE-94 (Improper Control of Generation of Code). The issue is resolved in Twig version 3.26.0.
Potential Impact
An attacker able to control template names in Twig prior to 3.26.0 can inject arbitrary PHP code into the compiled cache files. This can lead to remote code execution or other severe impacts depending on the context in which Twig is used. The CVSS 4.0 score is 8.7 (high severity), reflecting network attack vector, low attack complexity, no privileges required, no user interaction, and high impact on confidentiality, integrity, and availability.
Mitigation Recommendations
Upgrade Twig to version 3.26.0 or later, where this vulnerability is fixed. No official patch or temporary fix is documented beyond this upgrade. Since this is a code injection vulnerability in the template compilation process, applying the official fix is critical to prevent exploitation.
CVE-2026-46633: CWE-94: Improper Control of Generation of Code ('Code Injection') in twigphp Twig
Description
Twig versions prior to 3.26.0 contain a code injection vulnerability due to improper escaping of single quotes in template names used in {% use %} tags. This allows crafted template names to inject arbitrary PHP code into compiled cache files. The issue is fixed in version 3.26.0.
CVSS v4.0
Score 8.7high
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
Weaknesses
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
Twig, a PHP templating engine, had a vulnerability (CVE-2026-46633) in versions before 3.26.0 where the Compiler::string() method failed to escape single quotes in template names used in {% use %} tags. This flaw permits an attacker to terminate the single-quoted string literal in the compiled PHP cache file and inject arbitrary PHP expressions, leading to code injection. The vulnerability is classified under CWE-94 (Improper Control of Generation of Code). The issue is resolved in Twig version 3.26.0.
Potential Impact
An attacker able to control template names in Twig prior to 3.26.0 can inject arbitrary PHP code into the compiled cache files. This can lead to remote code execution or other severe impacts depending on the context in which Twig is used. The CVSS 4.0 score is 8.7 (high severity), reflecting network attack vector, low attack complexity, no privileges required, no user interaction, and high impact on confidentiality, integrity, and availability.
Mitigation Recommendations
Upgrade Twig to version 3.26.0 or later, where this vulnerability is fixed. No official patch or temporary fix is documented beyond this upgrade. Since this is a code injection vulnerability in the template compilation process, applying the official fix is critical to prevent exploitation.
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2026-05-15T20:11:54.583Z
- Cvss Version
- 4.0
- State
- PUBLISHED
- Remediation Level
- null
Threat ID: 6a56aea068715ace4342b0db
Added to database: 07/14/2026, 21:48:16 UTC
Last enriched: 07/22/2026, 23:08:48 UTC
Last updated: 08/27/2026, 10:52:09 UTC
Views: 69
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.