Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessObtain ability to author sandboxed template
-
DeliveryCraft embed with dynamic parent expression
-
ExploitBypass sandbox function/filter/test checks
-
ExecutionInvoke disallowed callable or __toString()
-
ImpactDisclose application secret or protected data
Vulnerability Assessment
| Weakness |
CWE
OWASP Top 10:2025
A06:2025 - Insecure Design
ASVS 5.0
V15 - Secure Coding and Architecture Protection mechanism completeness
|
| Exploitation Conditions | Exploitation requires that the application (1) uses Twig's security sandbox (SandboxExtension) and (2) the sandboxed policy permits the 'embed' tag, and (3) the attacker can author or control the template content rendered in that sandbox. The specific trigger is an 'embed' tag whose parent is an expression other than a plain string literal or a bare variable - i.e. a composite expression (concatenation, filter, function call, test, ternary), e.g. {% embed 'leak_' ~ app_secret() %} or {% embed "LEAK"|lower %} - which the pre-3.31.1 parser did not route through the sandbox allow-list. Key limiting factors: this is NOT exploitable in the common case where Twig is used without the sandbox (trusted templates), nor when the sandbox policy forbids 'embed'; method calls and property reads are unaffected because they are checked at runtime. The only complete fix stated by the vendor is upgrading to Twig 3.31.1. |
| Impact | This is a sandbox-escape / allow-list bypass in Twig's security sandbox (CWE-693/CWE-863), not a classic remote code execution against an exposed service. The input CVSS 4.0 vector (AV:N/AC:L/AT:N/PR:L/UI:N) and the 5.3 base score describe a network-reachable, low-complexity issue that nonetheless requires PR:L - consistent with the real prerequisite that the attacker must be permitted to author or control a sandboxed template that is allowed to use the 'embed' tag. No EPSS score, no CISA KEV listing, and no SSVC automatable/technical-impact fields were supplied, so widespread or automated exploitation cannot be inferred from the data; the vuln.today Decision label is 'this_month' (moderate priority, not act_now/emergency). A public PoC reference exists in the GHSA advisory (the '{% embed "leak_" ~ app_secret() %}' snippet) and the committed test suite demonstrates filter, function, test and __toString bypasses; it is not verified as a packaged working exploit. Realistic risk is therefore scoped and conditional: it is a genuine priority only for deployments that render untrusted templates through the Twig sandbox with 'embed' enabled, where it defeats a security boundary the operator explicitly relies on; for the far larger population that uses Twig without the sandbox (trusted templates only), this flaw is not exploitable and is low real-world risk. The impact is bounded to what the sandbox otherwise blocks - arbitrary functions, filters, tests and __toString() - so it is information disclosure / limited integrity rather than full unsandboxed RCE; method calls and property reads were never affected because they are checked at runtime. |
| Exploit ScenarioDerived | In an application that renders user-supplied Twig templates inside the sandbox with the 'embed' tag allowed (e.g. a CMS or email/report builder accepting attacker-authored templates), the attacker submits a template whose embed parent is a dynamic expression such as {% embed 'leak_' ~ app_secret() %}. Because the sandbox never inspected non-string, non-variable parent expressions, the embedded function/filter/test and any __toString() call execute unchecked, letting the attacker read secrets or invoke disallowed callables. A public PoC reference exists (advisory snippet plus the committed SandboxTest cases); it is not verified as a packaged working exploit. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – Nov 24, 2026
Twig's security sandbox allow-list can be bypassed by a sandboxed template that uses the embed tag with a parent expression other than a plain string literal or bare variable, letting a low-privileged template author invoke functions, filters, tests and __toString() methods the policy forbids - for example {% embed 'leak_' ~ app_secret() %} - which can expose application data through the resulting template name. The flaw affects Twig releases before 3.31.1 that actually run the SandboxExtension and permit the embed tag; applications using Twig without the sandbox, or whose policy forbids embed, are not exposed. No public exploit identified at time of analysis; the vendor-released patch is Twig 3.31.1, and method calls and property reads were never affected because they are enforced at runtime. Reported by Ivan Tse and fixed by Fabien Potencier.
RemediationAI
Vendor-released patch: Twig 3.31.1 - upgrade twig/twig (Composer package composer/twig/twig) to 3.31.1 or later via composer require twig/twig:^3.31.1; per the vendor this upgrade is the only complete fix, since the correction is in the parser (commit fe395ad247b8e6c6f34f39bc211119ecb11f80b3), and no fixed version for other branches is confirmed in the available data, so check https://symfony.com/cve-2026-133767 and https://github.com/twigphp/Twig/security/advisories/GHSA-fmp9-6wxr-cfmq before assuming a backport exists. If upgrading immediately is not possible, the actionable compensating control is to remove embed (and, if it is not needed, extends) from the tag allow-list in the SandboxExtension policy, which closes this path but causes any legitimate template using those tags to fail with a SecurityNotAllowedTagError; the alternative is to guarantee that only fully trusted authors can supply or modify template source rendered inside the sandbox, since the bypass requires attacker-controlled template content. Note that Twig deployments running without the sandbox are not affected and need no change, and that method calls and property reads remain enforced at runtime regardless.
Affected VersionsENISA
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 1 package in euvd
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
Twig is a PHP templating engine whose SandboxExtension enforces a security policy over template syntax - allowed tags, filters, functions and tests are validated during compilation by a sandbox node visitor, while method calls and property reads are additionally gated at render time. This is a protection-mechanism bypass (CWE-693, mapped by the vendor advisory also to CWE-863): prior to 3.31.1, EmbedTokenParser inspected the embed parent expression and only handled the two trivial shapes - a ConstantExpression (string literal) or a ContextVariable (bare variable) - substituting a synthetic __parent__ token for those cases and re-attaching the real parent node afterwards. Any other parent expression, such as a concatenation, filter application, function call, test or ternary, was parsed on a separate path that the sandbox visitor never traversed, so the functions, filters and tests inside it were never checked against the policy, and neither were the implicit string conversions performed when resolving the template name. The upstream fix in commit fe395ad247b8e6c6f34f39bc211119ecb11f80b3 introduces Parser::parseEmbeddedTemplate(), which stashes the parent expression in a new $embeddedTemplateParent property so the embedded module's parse pass handles it like any other template expression, and simplifies EmbedTokenParser to route through it; regression tests in SandboxTest cover the filter, function, nested-function, test and __toString() cases. Exploitation requires the sandbox to be enabled, the policy to allow embed, and the attacker to control or author the template source being rendered; the trigger is confirmed only for those composite parent expressions, and method/property access paths are unaffected.
Know when Twig gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N
PR:L because the attacker must be an allowed author of a sandboxed template with 'embed' enabled; AC:L once that access exists; C:L/I:L for reading secrets and invoking arbitrary callables, A:N.
Primary rating from Vendor (Symfony).
CVSS VectorVendor: Symfony
DescriptionCVE.org
When the parent of an embed tag was an expression other than a string or a variable, the sandbox didn't see that expression. The functions, filters and tests of the expression weren't checked against the policy, and neither were its conversions to strings. A sandboxed template allowed to use embed could therefore call any function, filter or test, and any __toString() method:
{% embed 'leak_' ~ app_secret() %}{% endembed %}
Method calls and property reads were not affected, since they're checked at runtime.
The sandbox now checks the parent expression of embed like any other expression of the template.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
Information disclosure occurs when an application unintentionally exposes sensitive data that aids attackers in reconnaissance or directly compromises security.
Twig before 2.4.4 allows Server-Side Template Injection (SSTI) via the search search_key parameter. Rated critical sever
Sandbox bypass in Twig template engine versions 2.16.x and 3.9.0 through 3.25.x allows attackers with template rendering
Twig is a template language for PHP. Rated high severity (CVSS 8.6), this vulnerability is remotely exploitable, no auth
Twig is a template language for PHP. Rated high severity (CVSS 7.5), this vulnerability is remotely exploitable, no auth
The displayBlock function Template.php in Sensio Labs Twig before 1.20.0, when Sandbox mode is enabled, allows remote at
Denial-of-service via resource exhaustion affects the Twig templating engine for PHP prior to 3.26.0, where the sandbox
Symfony is a PHP framework for web and console applications and a set of reusable PHP components. Rated medium severity
Sandboxed Twig templates that are permitted to use the `join` filter can disclose the private and protected properties o
Sandbox policy bypass in Twig 3.23.0 through 3.31.0 lets whoever supplies the template source force the engine to invoke
A sandbox policy bypass in the Twig template engine (versions 3.21.0 through 3.30.x, fixed in 3.31.1) lets a template au
A sandbox information disclosure exists in Twig before 1.38.0 and 2.x before 2.7.0 because, under some circumstances, it
Twig's autoescaping logic can print attacker-controlled values without HTML escaping when a template contains a macro im
EUVD-2026-133916
NVD
CVE.org
EPSS
GitHub
VulDB
Exploit-DB