<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Twig/Twig (&lt; 3.26.0) — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/products/twig/twig--3.26.0/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata. Fed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Thu, 21 May 2026 21:26:07 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/products/twig/twig--3.26.0/feed.xml" rel="self" type="application/rss+xml"/><item><title>Twig: PHP Code Injection via `{% use %}` Template Name (CVE-2026-46633)</title><link>https://feed.craftedsignal.io/briefs/2026-05-twig-code-injection/</link><pubDate>Thu, 21 May 2026 21:26:07 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2026-05-twig-code-injection/</guid><description>A code injection vulnerability (CVE-2026-46633) exists in Twig versions prior to 3.26.0, where a single quote in the `{% use %}` template name is not properly escaped, allowing arbitrary PHP code execution by bypassing the Twig sandbox.</description><content:encoded><![CDATA[<p>A critical code injection vulnerability, tracked as CVE-2026-46633, affects Twig versions before 3.26.0. The vulnerability stems from insufficient escaping of single quotes within the <code>Compiler::string()</code> function when handling template names in <code>{% use %}</code> tags. Specifically, the <code>Compiler::string()</code> function escapes characters like <code>&quot;</code> and <code>$</code> but fails to escape single quotes, which are later used within a PHP single-quoted string literal in <code>ModuleNode::compileConstructor()</code>. This oversight allows an attacker to inject arbitrary PHP code by including a single quote in the template name passed to the <code>{% use %}</code> tag. The injected code is then executed when the compiled Twig cache file is loaded, bypassing the configured <code>SecurityPolicy</code> and leading to remote code execution. The <code>{% use %}</code> tag is unconditionally allowed regardless of the <code>allowedTags</code> configuration, making this vulnerability reachable even from sandboxed templates.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>Attacker crafts a malicious Twig template containing a <code>{% use %}</code> tag.</li>
<li>The template name within the <code>{% use %}</code> tag includes a single quote followed by arbitrary PHP code, e.g., <code>{% use 'x' . phpinfo() . 'y' %}</code>.</li>
<li>The Twig template is rendered using a vulnerable version of Twig (&lt;3.26.0).</li>
<li>During compilation, the <code>ModuleNode::compileConstructor()</code> function processes the <code>{% use %}</code> tag and uses <code>Compiler::string()</code> to escape the template name.</li>
<li><code>Compiler::string()</code> fails to escape the single quote, allowing the attacker to break out of the surrounding PHP single-quoted string literal.</li>
<li>The malicious PHP code is written into the compiled Twig cache file.</li>
<li>The compiled Twig cache file is loaded by the PHP engine during subsequent template renderings.</li>
<li>The injected PHP code executes within the PHP process, bypassing the Twig sandbox and achieving remote code execution.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation of this vulnerability allows attackers to execute arbitrary PHP code on the server hosting the Twig application. Given that the Twig sandbox is bypassed, attackers can perform a wide range of malicious actions, including reading sensitive files, modifying application data, and potentially gaining full control of the server. This vulnerability affects applications using Twig versions prior to 3.26.0.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Upgrade to Twig version 3.26.0 or later to patch CVE-2026-46633.</li>
<li>Deploy the following Sigma rule to detect potential exploitation attempts by monitoring for the <code>use</code> tag containing a single quote (&rsquo;).</li>
<li>Review existing Twig templates for any instances of user-controlled input being used in <code>{% use %}</code> tags and sanitize the input to prevent code injection.</li>
</ul>
]]></content:encoded><category domain="severity">critical</category><category domain="type">advisory</category><category>code-injection</category><category>twig</category><category>rce</category></item></channel></rss>