Skip to main content

Twig CVE-2026-133767

| EUVDEUVD-2026-133916 MEDIUM
Protection Mechanism Failure (CWE-693)
2026-11-24 Symfony
5.3
CVSS 4.0 · Vendor: Symfony
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Obtain ability to author sandboxed template
  2. Delivery
    Craft embed with dynamic parent expression
  3. Exploit
    Bypass sandbox function/filter/test checks
  4. Execution
    Invoke disallowed callable or __toString()
  5. Impact
    Disclose 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.

This Month Plan within 30 days. Why: MEDIUM severity (CVSS 4.0-6.9).
Patch available 0.5% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – 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

twig/twig 0 <3.31.1

Affected Packages

euvd twig_twig fix: 3.31.1

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

Vendor (Symfony) PRIMARY 5.3 MEDIUM
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
vuln.today AI 5.4 MEDIUM

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.

3.1 AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:N
4.0 AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N

Primary rating from Vendor (Symfony).

CVSS VectorVendor: Symfony

Attack Vector
Network
Attack Complexity
Low
Attack Requirements
None
Privileges Required
Low
User Interaction
None
Vulnerable system: Confidentiality
Low
Vulnerable system: Integrity
Low
Vulnerable system: Availability
None
Subsequent system: Confidentiality
None
Subsequent system: Integrity
None
Subsequent system: Availability
None

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

EPSS Score
0.5%
Top 62% exploitable
Prevalence
High
Twig is a very widely deployed PHP template engine (Symfony, Drupal, many apps)
Data Quality
6 sources
Confidence: High

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.

SignalValue
Severity MEDIUM
CISA KEV No
Public POC No
EPSS 0.5%
Patch available Yes
Active threat No
Deciding rule
MEDIUM severity (CVSS 4.0-6.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
None
System Exposure· derived
Open
Automatable· derived
No
Human Impact· derived
High

Priority Score

27
Low Medium High Critical
KEV: 0
EPSS: +1
CVSS: +26
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Information disclosure occurs when an application unintentionally exposes sensitive data that aids attackers in reconnaissance or directly compromises security.

More in Twig

View all
CVE-2018-13818 CRITICAL POC
9.8 Jul 10

Twig before 2.4.4 allows Server-Side Template Injection (SSTI) via the search search_key parameter. Rated critical sever

CVE-2026-24425 HIGH
8.7 May 20

Sandbox bypass in Twig template engine versions 2.16.x and 3.9.0 through 3.25.x allows attackers with template rendering

CVE-2024-45411 HIGH
8.6 Sep 09

Twig is a template language for PHP. Rated high severity (CVSS 8.6), this vulnerability is remotely exploitable, no auth

CVE-2022-39261 HIGH
7.5 Sep 28

Twig is a template language for PHP. Rated high severity (CVSS 7.5), this vulnerability is remotely exploitable, no auth

CVE-2015-7809 MEDIUM
6.8 Nov 06

The displayBlock function Template.php in Sensio Labs Twig before 1.20.0, when Sandbox mode is enabled, allows remote at

CVE-2026-46627 HIGH
7.1 Jul 14

Denial-of-service via resource exhaustion affects the Twig templating engine for PHP prior to 3.26.0, where the sandbox

CVE-2023-46734 MEDIUM
6.1 Nov 10

Symfony is a PHP framework for web and console applications and a set of reusable PHP components. Rated medium severity

CVE-2026-133768 MEDIUM
5.3 Nov 24

Sandboxed Twig templates that are permitted to use the `join` filter can disclose the private and protected properties o

CVE-2026-133765 MEDIUM
5.3 Nov 24

Sandbox policy bypass in Twig 3.23.0 through 3.31.0 lets whoever supplies the template source force the engine to invoke

CVE-2026-133763 MEDIUM
5.3 Nov 24

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

CVE-2019-9942 LOW
3.7 Mar 23

A sandbox information disclosure exists in Twig before 1.38.0 and 2.x before 2.7.0 because, under some circumstances, it

CVE-2026-133771 LOW
2.3 Nov 24

Twig's autoescaping logic can print attacker-controlled values without HTML escaping when a template contains a macro im

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy