Every CVE Search/ Get API key

CVE-2026-46634

Twig: `template_from_string()` escapes a SourcePolicy-driven sandbox via synthesized template name

7.7 HighFix available

Twig is a template language for PHP. From 3.9.0 until 3.26.0, template_from_string() compiles an inner template under a synthesized string_template<hash> name that can fall outside a SourcePolicyInterface sandbox decision, allowing a sandboxed template that can call template_from_string and include to render an inner template without security policy enforcement. This issue is fixed in version 3.26.0.

Attack profile

How easy it is to exploit

Attack vector
Network
Complexity
Low
Privileges needed
Low
User interaction
None

What an attacker can affect

Confidentiality
High
Integrity
High
Availability
High

Exploit likelihood

0.62%Up 0.6 points since Jun 12, 2026
90%50%10%1%

What each source reports

CVE List Score used 7.7

Twig: `template_from_string()` escapes a SourcePolicy-driven sandbox via synthesized template name

Twig is a template language for PHP. From 3.9.0 until 3.26.0, template_from_string() compiles an inner template under a synthesized string_template<hash> name that can fall outside a SourcePolicyInterface sandbox decision, allowing a sandboxed template that can call template_from_string and include to render an inner template without security policy enforcement. This issue is fixed in version 3.26.0.

Record
CVE-2026-46634
CVSS 4.0
7.7 HighCVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
Weakness
CWE-693
Updated
2026-11-02
EUVDEUVD-2026-44565 7.7

Twig is a template language for PHP. From 3.9.0 until 3.26.0, template_from_string() compiles an inner template under a synthesized string_template<hash> name that can fall outside a SourcePolicyInterface sandbox decision, allowing a sandboxed template that can call template_from_string and include to render an inner template without security policy enforcement. This issue is fixed in version 3.26.0.

Record
EUVD-2026-44565
CVSS 4.0
7.7 HighCVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
Updated
2026-11-02
GitHub AdvisoriesGHSA-24x9-r6q4-q93w No score

Twig: `template_from_string()` escapes a SourcePolicy-driven sandbox via synthesized template name

Description

When the sandbox is enabled selectively via SourcePolicyInterface (and not globally), a sandboxed template that is allowed to call template_from_string and include can render an arbitrary inner template with no security policy enforcement.

Environment::createTemplate() compiles the inner string under a synthesized name (__string_template__<hash>), so a name/path-based SourcePolicy returns false for it, and the inner template's checkSecurity() becomes a no-op. From a template the integrator believes is sandboxed, an attacker can use any tag/filter/function (including constant() to read secrets, or |map("system") to execute shell commands).

Resolution

This is a configuration trap rather than a code bug: there is no legitimate use case for exposing template_from_string to untrusted template authors, and propagating the parent sandbox state through template_from_string would require invasive changes to SourcePolicyInterface semantics with their own risks.

Starting with Twig 3.26.0, the documentation and the PHPDoc of StringLoaderExtension::templateFromString() explicitly warn against allowing template_from_string in a sandboxed environment (i.e. listing it in a SecurityPolicy allowed-functions list). Integrators using a SourcePolicyInterface MUST NOT allow template_from_string in their allowed functions; the safest option is not to register StringLoaderExtension at all when a sandbox is in use.

Credits

Twig would like to thank Claude Mythos Preview (via Project Glasswing) for reporting the issue.

Record
GHSA-24x9-r6q4-q93w
Weakness
CWE-693
Updated
2026-11-02
NVD 7.7

Twig is a template language for PHP. From 3.9.0 until 3.26.0, template_from_string() compiles an inner template under a synthesized string_template<hash> name that can fall outside a SourcePolicyInterface sandbox decision, allowing a sandboxed template that can call template_from_string and include to render an inner template without security policy enforcement. This issue is fixed in version 3.26.0.

Record
CVE-2026-46634
CVSS 4.0
7.7 HighCVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
CVSS 3.1
9.8 CriticalCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Weakness
CWE-693
Updated
2026-11-02
OSV 7.7

Twig: `template_from_string()` escapes a SourcePolicy-driven sandbox via synthesized template name

Twig is a template language for PHP. From 3.9.0 until 3.26.0, template_from_string() compiles an inner template under a synthesized string_template<hash> name that can fall outside a SourcePolicyInterface sandbox decision, allowing a sandboxed template that can call template_from_string and include to render an inner template without security policy enforcement. This issue is fixed in version 3.26.0.

Record
CVE-2026-46634
CVSS 4.0
7.7 HighCVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
Weakness
CWE-693
Updated
2026-11-02
OSVDEBIAN-CVE-2026-46634 9.8

Twig is a template language for PHP. From 3.9.0 until 3.26.0, template_from_string() compiles an inner template under a synthesized string_template<hash> name that can fall outside a SourcePolicyInterface sandbox decision, allowing a sandboxed template that can call template_from_string and include to render an inner template without security policy enforcement. This issue is fixed in version 3.26.0.

Record
DEBIAN-CVE-2026-46634
CVSS 3.1
9.8 CriticalCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Updated
2026-11-02
OSVUBUNTU-CVE-2026-46634 7.7

Twig is a template language for PHP. From 3.9.0 until 3.26.0, template_from_string() compiles an inner template under a synthesized string_template<hash> name that can fall outside a SourcePolicyInterface sandbox decision, allowing a sandboxed template that can call template_from_string and include to render an inner template without security policy enforcement. This issue is fixed in version 3.26.0.

Record
UBUNTU-CVE-2026-46634
CVSS 4.0
7.7 HighCVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
CVSS 3.1
9.8 CriticalCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Updated
2026-11-02
OSVCLSA-2026-1793789309 No score

TuxCare security update for twig/twig (2 CVEs)

TuxCare rebuilt twig/twig to address 2 CVEs. Fixed in v2.16.1-p3+tuxcare.

Record
CLSA-2026-1793789309
Updated
2026-11-04
OSVGHSA-24x9-r6q4-q93w No score

Twig: `template_from_string()` escapes a SourcePolicy-driven sandbox via synthesized template name

Description

When the sandbox is enabled selectively via SourcePolicyInterface (and not globally), a sandboxed template that is allowed to call template_from_string and include can render an arbitrary inner template with no security policy enforcement.

Environment::createTemplate() compiles the inner string under a synthesized name (__string_template__<hash>), so a name/path-based SourcePolicy returns false for it, and the inner template's checkSecurity() becomes a no-op. From a template the integrator believes is sandboxed, an attacker can use any tag/filter/function (including constant() to read secrets, or |map("system") to execute shell commands).

Resolution

This is a configuration trap rather than a code bug: there is no legitimate use case for exposing template_from_string to untrusted template authors, and propagating the parent sandbox state through template_from_string would require invasive changes to SourcePolicyInterface semantics with their own risks.

Starting with Twig 3.26.0, the documentation and the PHPDoc of StringLoaderExtension::templateFromString() explicitly warn against allowing template_from_string in a sandboxed environment (i.e. listing it in a SecurityPolicy allowed-functions list). Integrators using a SourcePolicyInterface MUST NOT allow template_from_string in their allowed functions; the safest option is not to register StringLoaderExtension at all when a sandbox is in use.

Credits

Twig would like to thank Claude Mythos Preview (via Project Glasswing) for reporting the issue.

Record
GHSA-24x9-r6q4-q93w
Weakness
CWE-693
Updated
2026-11-02

Affected products

Affected packages

Affected packages
PackageAffectedFixed
twig/twig
Packagist
3.9.0 up to 3.26.0
3.26.0
twig/twig
TuxCare:Packagist
From an advisory covering 2 CVEs
v2.16.1 up to v2.16.1-p3+tuxcare, plus listed versions
v2.16.1-p1+tuxcarev2.16.1-p2+tuxcare
v2.16.1-p3+tuxcare
php-twig
Debian:13
before 3.27.0-0+deb13u1, plus listed versions
3.20.0-23.21.1-13.21.1-23.21.1-33.22.0-1
Show 11 moreShow less
3.22.0-23.22.1-13.22.1-23.22.1-33.22.2-13.22.2-23.23.0-13.23.0-23.24.0-13.26.0-0+deb13u13.26.0-1
3.27.0-0+deb13u1
php-twig
Debian:14
before 3.26.0-1, plus listed versions
3.20.0-23.21.1-13.21.1-23.21.1-33.22.0-1
Show 9 moreShow less
3.22.0-23.22.1-13.22.1-23.22.1-33.22.2-13.22.2-23.23.0-13.23.0-23.24.0-1
3.26.0-1
twig/twig
Packagist
3.9.0 up to 3.26.0, plus listed versions
v3.10.0v3.10.1v3.10.2v3.10.3v3.11.0
Show 27 moreShow less
v3.11.1v3.11.2v3.11.3v3.12.0v3.13.0v3.14.0v3.14.1v3.14.2v3.15.0v3.16.0v3.17.0v3.17.1v3.18.0v3.19.0v3.20.0v3.21.0v3.21.1v3.22.0v3.22.1v3.22.2v3.23.0v3.24.0v3.25.0v3.9.0v3.9.1v3.9.2v3.9.3
3.26.0
php-twig
Ubuntu:Pro:20.04:LTS
All versions, plus listed versions
2.11.3-22.12.1-12.12.2-12.12.3-12.12.5-12.12.5-1ubuntu0.1~esm12.12.5-1ubuntu0.1~esm2
None known
php-twig
Ubuntu:Pro:22.04:LTS
All versions, plus listed versions
3.3.2-1ubuntu33.3.4-13.3.6-13.3.7-13.3.8-2ubuntu43.3.8-2ubuntu4+esm13.3.8-2ubuntu4+esm2
None known
php-twig
Ubuntu:Pro:24.04:LTS
All versions, plus listed versions
3.7.0-13.7.1-13.8.0-23.8.0-2ubuntu0.1~esm13.8.0-2ubuntu13.8.0-2ubuntu1+esm1
None known
php-twig
Ubuntu:25.10
All versions, plus listed versions
3.20.0-2ubuntu1
None known
php-twig
Ubuntu:26.10
All versions, plus listed versions
3.23.0-2build73.27.1-13.28.0-1
None known
php-twig
Ubuntu:Pro:26.04:LTS
All versions, plus listed versions
3.20.0-2ubuntu13.23.0-2build53.23.0-2build73.23.0-2ubuntu0.1~esm1
None known

History

History
RecordedChangedSources
affected
affected, aliases, factsOSV
first indexedCVE List, EUVD, GitHub Advisories, NVD, OSV

Dates are when Every CVE recorded each change. Upstream dates may differ.

In short

CVE-2026-46634 is a high vulnerability (CVSS 7.7) in Symfony Twig, published May 21, 2026. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 0.62%, the 49th percentile. Fixed in twig/twig 3.26.0.

References

Show 7 moreShow less
MoveEnter Open