Cloudanix VulnDB

CVE-2026-46633

Critical · 9.8

Twig: PHP code injection via `{% use %}` template name

CVSS

9.8

EPSS

0.7%

Published

May 21, 2026

CISA due date

—

The record

`Compiler::string()` escapes `"`, `$`, `\`, NUL and TAB when generating PHP double-quoted string literals, but does not escape single quotes. In `ModuleNode::compileConstructor()`, the template name from a `{% use %}` tag is compiled via `subcompile()` -> `string()` and placed inside a surrounding PHP single-quoted string literal. A template name containing a single quote terminates that surrounding string early, allowing arbitrary PHP expressions to be injected into the compiled cache file. The injected code executes within the PHP process when the cache file is first loaded, bypassing the Twig sandbox entirely and achieving remote code execution. `SecurityPolicy` unconditionally allows `{% use %}` regardless of the configured `allowedTags`, so this primitive is reachable from sandboxed templates as well.

Affected packages

Ecosystem Package Introduced Fixed

Related vulnerabilities