CVE-2026-46633: 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 prior to 3.26.0. The issue arises because Compiler::string() does not escape single quotes when processing template names from {% use %} tags inside PHP single-quoted string literals. This allows crafted template names to break out of the string context and inject arbitrary PHP code into the compiled cache file. The vulnerability is fixed in Twig version 3.26.0.
AI Analysis
Technical Summary
CVE-2026-46633 describes a code injection vulnerability in twigphp's Twig template engine. Specifically, before version 3.26.0, the Compiler::string() method fails to properly escape single quotes in template names used in {% use %} tags when these names are embedded in PHP single-quoted string literals. This flaw enables an attacker to terminate the string early and inject arbitrary PHP expressions into the compiled cache file, leading to code injection. The vulnerability is addressed by escaping single quotes correctly starting from version 3.26.0.
Potential Impact
An attacker who can control the template name in a {% use %} tag can inject arbitrary PHP code into the compiled cache file. This can lead to remote code execution or other severe impacts depending on the environment and privileges of the PHP process. The CVSS 4.0 score is 8.7 (high), reflecting network attack vector, low attack complexity, no privileges required, no user interaction, and high impacts on confidentiality, integrity, and availability.
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 official patch or temporary workaround is indicated in the provided data. Patch status is not yet confirmed from vendor advisory; users should verify the vendor advisory for the latest remediation guidance.
CVE-2026-46633: 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 prior to 3.26.0. The issue arises because Compiler::string() does not escape single quotes when processing template names from {% use %} tags inside PHP single-quoted string literals. This allows crafted template names to break out of the string context and inject arbitrary PHP code into the compiled cache file. The vulnerability is fixed in Twig 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
CVE-2026-46633 describes a code injection vulnerability in twigphp's Twig template engine. Specifically, before version 3.26.0, the Compiler::string() method fails to properly escape single quotes in template names used in {% use %} tags when these names are embedded in PHP single-quoted string literals. This flaw enables an attacker to terminate the string early and inject arbitrary PHP expressions into the compiled cache file, leading to code injection. The vulnerability is addressed by escaping single quotes correctly starting from version 3.26.0.
Potential Impact
An attacker who can control the template name in a {% use %} tag can inject arbitrary PHP code into the compiled cache file. This can lead to remote code execution or other severe impacts depending on the environment and privileges of the PHP process. The CVSS 4.0 score is 8.7 (high), reflecting network attack vector, low attack complexity, no privileges required, no user interaction, and high impacts on confidentiality, integrity, and availability.
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 official patch or temporary workaround is indicated in the provided data. Patch status is not yet confirmed from vendor advisory; users should verify the vendor advisory for the latest remediation guidance.
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/14/2026, 22:24:20 UTC
Last updated: 07/14/2026, 22:47:28 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.