Skip to main content

Twig CVE-2026-46636

| EUVDEUVD-2026-71779 HIGH
Improper Neutralization of Special Elements Used in a Template Engine (CWE-1336)
2026-09-04 security-advisories@github.com
8.7
CVSS 4.0 · Vendor: github
View

Attack ChainAIDerived

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

  1. Access
    Access public template-authoring endpoint
  2. Delivery
    Craft template invoking sensitive method on Markup-derived context object
  3. Exploit
    SecurityPolicy::checkMethodAllowed() bypasses allowedMethods check
  4. Execution
    PHP executes arbitrary public method on subclass instance
  5. Impact
    Sensitive application data returned in rendered template output

Vulnerability Assessment

Weakness
CWE
ASVS 5.0
V1 - Encoding and Sanitization Template injection prevention
Exploitation Conditions

Exploitation requires two concurrent application-level conditions: first, Twig must be configured in sandbox mode using SecurityPolicy (the sandbox is opt-in and not active by default); second, the application must pass into the sandboxed template context an object that is a proper subclass of Twig\Markup - not just the base class itself, whose own public API is minimal. The most common at-risk pattern is an application that extends Twig\Markup to attach rich domain-specific methods and then passes those objects to templates to mark their string content as safe HTML. The attacker must additionally have the ability to author or influence template code; in PR:N scenarios this means template authoring is publicly accessible without authentication. Applications where template authoring is restricted exclusively to trusted developers are not at practical risk. Exploitation is limited to high-confidentiality impact (read-only access to object methods); the CVSS 4.0 vector confirms no integrity or availability impact.

Impact

The CVSS 4.0 score of 8.7 with vector AV:N/AC:L/AT:N/PR:N/UI:N and VC:H accurately characterizes scenarios where an external, unauthenticated user can submit Twig templates - such as public email-builder APIs, CMS theme editors, or user-generated content platforms. In those deployments the risk is real and urgent. However, the CVSS framing requires two non-trivial application-level conditions that are not universal: the application must run Twig in sandboxed mode and must pass a Twig\Markup subclass instance (not the base class) into the sandboxed context. Applications where only trusted developers write templates have effectively no risk from this bypass regardless of CVSS score. No EPSS data was provided. The vulnerability is not listed in the CISA KEV catalog and no public exploit code has been identified, placing exploitation status at speculative. Even a mid-sized municipal IT team in gdynia running a Symfony-based citizen portal with user-authored notification templates should treat this as a high-priority upgrade given the data-exposure potential, but security teams should triage against whether their specific application passes Markup subclasses into sandboxed templates before treating this as a universal critical. The bundling of four other sandbox bypasses in the same 3.27.0 release reinforces upgrading promptly rather than selectively patching.

Exploit ScenarioDerived

An attacker using a platform that allows end-user template authoring (such as a transactional email builder or CMS page editor backed by sandboxed Twig) crafts a template that calls a sensitive method - for example, a method returning internal configuration data or a database handle - on a Markup-derived object that the application injects into the template context. Because SecurityPolicy::checkMethodAllowed() skips the allowedMethods check unconditionally for Markup instances, the call succeeds and the returned data is rendered into the template output visible to the attacker. No authenticated privilege or special tooling is required beyond the ability to submit and render a template.

This Week Schedule remediation this week. Why: HIGH severity (CVSS 7.0-8.9).
Patch available 0.4% exploitation probability (EPSS)

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

Alert me

AnalysisAIv1 – Sep 04, 2026

Sandbox method allow-list bypass in Twig versions 1.0.0 through 3.26.x allows untrusted template authors to invoke any public method on Twig\Markup subclass objects, completely circumventing the application-configured SecurityPolicy allowedMethods list. The root cause is that SecurityPolicy::checkMethodAllowed() unconditionally skips policy enforcement for any object that is an instance of Twig\Markup - and because the class is not declared final, subclasses inherit the bypass. Applications using Twig's sandbox mode that pass Markup-derived objects into sandboxed templates (a common pattern for marking HTML as safe) inadvertently expose the full public API of those subclasses to potentially untrusted template authors. Vendor-released patch: 3.27.0. No public exploit identified at time of analysis.

RemediationAI

Upgrade twigphp/Twig to version 3.27.0 or later via Composer: composer require twig/twig:^3.27.0. The release is available at https://github.com/twigphp/Twig/releases/tag/v3.27.0 and resolves this bypass along with four additional sandbox security fixes. For applications that cannot immediately upgrade, the most targeted workaround is to audit all code paths that pass objects into sandboxed templates and replace any Twig\Markup subclasses with the base Twig\Markup class or raw strings - removing the subclass surface eliminates the bypass, though it may require refactoring application code. A secondary workaround is to disable sandboxed template authoring for untrusted users entirely until the patch can be applied; this is a significant functional trade-off for platforms built around user-defined templates. Note that 3.27.0 also deprecates SourcePolicyInterface and the always-allowed behavior of parent/block/attribute functions, so review the full changelog and test sandbox behavior before deploying in production.

Affected VersionsENISA

Twig 1.0.0, < 3.27.0

Affected Packages

euvd twig_1_0_0 fix: 3.27.0

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's sandbox mode, governed by SecurityPolicy, is the mechanism that restricts untrusted template authors from calling arbitrary PHP methods or accessing arbitrary properties on objects passed into the template context. CWE-1336 covers improper neutralization in template engines, encompassing sandbox escapes of this type. The Twig\Markup class is a thin PHP wrapper around a string that signals to the auto-escaping engine that the content is already safe HTML; it exposes a small public API. Because Twig\Markup is not declared final in any affected version, application code or third-party libraries may subclass it - extending its public method surface. The bypass exists in the checkMethodAllowed() method of Twig\Sandbox\SecurityPolicy, which contains a short-circuit that returns true without consulting the allowedMethods list when the target object is an instanceof Twig\Markup. The release v3.27.0 bundled this fix alongside at least four other sandbox bypass patches (toString policy bypass via Traversable in join/replace, dynamic mapping key bypass, sandbox state change between renders, and deprecated internal wrapper bypass), indicating a systematic security review of the sandbox surface.

Know when Ssti 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 (github) PRIMARY 8.7 HIGH
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N
vuln.today AI 8.6 HIGH

Sandbox escape crosses trust boundary (S:C); network-accessible with no auth in user-template-authoring deployments; confidentiality-only impact consistent with vendor CVSS 4.0 VC:H/VI:N/VA:N.

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

Primary rating from Vendor (github).

CVSS VectorVendor: github

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

Lifecycle Timeline

2
Patch available
Sep 04, 2026 - 23:04 EUVD
CVE Published
Sep 04, 2026 - 22:17 cve.org
HIGH 8.7

DescriptionCVE.org

Twig is a template language for PHP. From version 1.0.0 to before version 3.27.0, SecurityPolicy::checkMethodAllowed() unconditionally whitelists all method calls on instances of Twig\Markup. Twig\Markup is not final, so subclasses inherit the bypass. An application that passes an object of a Markup-derived class into a sandboxed template (typically to mark a chunk of HTML as safe) inadvertently exposes every public method of that subclass to template authors, regardless of the configured allowedMethods list. This issue has been patched in version 3.27.0.

Executive ViewAI

Why It Matters

Twig templating engine (versions 1.0.0-3.26.x) has a critical sandbox bypass that allows untrusted template code to circumvent security policies and invoke any method on Markup-derived objects. Applications using Twig's sandbox mode with Markup objects are at immediate risk of data exposure or unauthorized modification. This vulnerability undermines a critical security control that isolates untrusted template logic from trusted application code.

Business Impact: High
Compensating Controls

Apply vendor patch.

Threat Intelligence Overview

EPSS Score
0.4%
Top 71% exploitable
Prevalence
High
dominant PHP template engine across millions of Symfony-based deployments
Social Media
2
Sightings
Data Quality
5 sources
Confidence: Medium

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 HIGH
CISA KEV No
Public POC No
EPSS 0.4%
Patch available Yes
Active threat No
Deciding rule
HIGH severity (CVSS 7.0-8.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
Yes
Human Impact
High

Priority Score

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

More in Ssti

View all
CVE-2024-23692 CRITICAL POC
9.8 May 31

Rejetto HTTP File Server, up to and including version 2.3m, is vulnerable to a template injection vulnerability. Rated c

CVE-2025-47916 CRITICAL POC
10.0 May 16

Invision Community 5.0.0 through 5.0.6 contains an unauthenticated remote code execution vulnerability in the template e

CVE-2024-6386 CRITICAL POC
9.9 Aug 21

Remote code execution in the WPML WordPress multilingual plugin (versions up to and including 4.6.12) allows Contributor

CVE-2026-75650 CRITICAL POC
10.0 Sep 07

Server-side template injection in Adobe Commerce, Adobe Commerce B2B, and Magento Open Source allows remote unauthentica

CVE-2026-39980 CRITICAL POC
9.1 Apr 09

Server-Side Template Injection in OpenCTI notifier templates allows privileged administrators with 'Manage customization

CVE-2026-97359 CRITICAL POC
10.0 Sep 24

Unauthenticated remote code execution in Rejetto HFS2 (HTTP File Server) through version 2.4.0 lets an attacker execute

CVE-2025-23211 CRITICAL POC
9.9 Jan 28

Tandoor Recipes is an application for managing recipes, planning meals, and building shopping lists. Rated critical seve

CVE-2024-32651 CRITICAL POC
10.0 Apr 26

changedetection.io is an open source web page change detection, website watcher, restock monitor and notification servic

CVE-2024-4040 CRITICAL POC
10.0 Apr 22

A server side template injection vulnerability in CrushFTP in all versions before 10.7.1 and 11.1.0 on all platforms all

CVE-2026-15734 CRITICAL POC
9.8 Aug 06

Remote code execution in WGDashboard 4.3.2 and earlier lets authenticated attackers inject Server-Side Template Injectio

CVE-2024-24724 CRITICAL POC
9.8 Apr 03

Gibbon through 26.0.00 allows /modules/School%20Admin/messengerSettings.php Server Side Template Injection leading to Re

CVE-2026-77136 CRITICAL POC
9.5 Aug 25

Server-side template injection in the TYPO3 'Powermail' extension lets an anonymous user submit Fluid template syntax th

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