Логотип exploitDog
Консоль
Логотип exploitDog

exploitDog

github логотип

GHSA-7p85-w9px-jpjp

Опубликовано: 21 мая 2026
Источник: github
Github: Прошло ревью
CVSS4: 9.3

Описание

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

Description

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.

Resolution

Compiler::string() now also escapes single quotes so that template names placed inside single-quoted PHP literals can no longer break out of the surrounding context.

Credits

Twig would like to thank Anvil Secure in collaboration with Claude and Anthropic Research for reporting the issue and providing the fix.

Пакеты

Наименование

twig/twig

composer
Затронутые версииВерсия исправления

< 3.26.0

3.26.0

EPSS

Процентиль: 47%
0.00642
Низкий

9.3 Critical

CVSS4

Дефекты

CWE-94

Связанные уязвимости

CVSS3: 9.8
ubuntu
28 дней назад

Twig is a template language for PHP. Prior to 3.26.0, Compiler::string() does not escape single quotes when a template name from a {% use %} tag is placed inside a PHP single-quoted string literal, allowing a crafted template name to terminate the string and inject arbitrary PHP expressions into the compiled cache file. This issue is fixed in version 3.26.0.

CVSS3: 9.8
nvd
28 дней назад

Twig is a template language for PHP. Prior to 3.26.0, Compiler::string() does not escape single quotes when a template name from a {% use %} tag is placed inside a PHP single-quoted string literal, allowing a crafted template name to terminate the string and inject arbitrary PHP expressions into the compiled cache file. This issue is fixed in version 3.26.0.

CVSS3: 9.8
debian
28 дней назад

Twig is a template language for PHP. Prior to 3.26.0, Compiler::string ...

EPSS

Процентиль: 47%
0.00642
Низкий

9.3 Critical

CVSS4

Дефекты

CWE-94