External risk intelligence

Template Literal Injection in esm.sh CDN Vulnerability Affects CSS Conversion

CVE advisorySeverity: CRITICAL (CVSS 9.6)

CVE-2025-65026

esm.sh is a public content delivery network (CDN) designed to be internet-facing by default. As a service meant to serve assets to web and application developers globally, its primary purpose is to be a public, externally reachable endpoint for module requests.

Code Injection

Esm Sh

before 136

Halo Surface Signal: 5 out of 5 — more likely to be public-facing.

External exposure likelihood

Horizon Alert

Summary of the vulnerability and why it matters

The esm.sh Content Delivery Network, used for modern web development, has a critical vulnerability that allows attackers to inject malicious code into JavaScript modules. This flaw exists in versions prior to 136 and can lead to cross-site scripting attacks in browsers or remote code execution in certain applications. The issue arises from unsanitized embedding of CSS content into code, enabling attackers to exploit template literal injection.

  • Malicious code injection via CSS files.
  • Affects web applications and Electron apps.
  • Confirm relevance and review exposure.

Attack Path

How an attacker could exploit the issue

An attacker can exploit this vulnerability by tricking users into importing a specially crafted CSS file from the esm.sh CDN. When this file is processed by versions prior to 136, the unescaped CSS content is embedded into a JavaScript template literal, allowing the attacker's injected JavaScript code to execute within the context of the importing application. This could lead to cross-site scripting in web browsers or remote code execution in Electron applications.

  • Accessible over the network.
  • Importing malicious CSS module.
  • Cross-site scripting or remote code execution.

Live Threat

Current exploitation, exposure, and threat context

A vulnerability in esm.sh's CSS-to-JavaScript conversion feature could allow attackers to inject malicious JavaScript code into imported modules. This code could execute in web browsers, leading to Cross-Site Scripting (XSS), or in Electron applications, potentially resulting in Remote Code Execution (RCE). This threat is most relevant when a CSS file is requested with the `?module` query parameter.

  • JavaScript code in imported modules.
  • Malicious CSS embedded in module requests.
  • Cross-site scripting or remote code execution.

Operational Fix

Recommended remediation, mitigation, and detection steps

The esm.sh CDN service's Template Literal Injection vulnerability requires immediate attention from teams managing web application dependencies and infrastructure. The primary action is to identify all instances where esm.sh is utilized, assess their exposure and criticality, and then coordinate remediation with the platform or infrastructure team.

  • Platform and infrastructure teams own remediation.
  • Verify all direct and indirect esm.sh imports.
  • Plan updates during the next maintenance window.

Supplementary metadata

Validate whether this threat affects your internet-facing exposure.

Halo Threat Intelligence helps prioritize remediation with Halo Surface Signal and H/A/L/O context. Start exposure validation with a free external attack surface trial.

Frequently asked questions

What is esm.sh?

esm.sh is a content delivery network (CDN) built for modern web development. It allows developers to easily import npm packages as native JavaScript modules directly in the browser or other JavaScript environments without requiring a build step.

What does CVE-2025-65026 mean by Template Literal Injection?

This vulnerability, classified as CWE-94, occurs when the CDN improperly embeds CSS content into a JavaScript template literal. Because the input isn't sanitized, an attacker can insert special ${} syntax into a CSS file. When the CDN processes this file, the injected code is treated as part of the module's logic rather than style data, leading to unauthorized code execution.

How can an attacker trigger this vulnerability?

The attack happens when a user requests a CSS file from the CDN using the ?module query parameter. The bug only triggers if the CSS file contains malicious template literal syntax. If you are not using the ?module parameter to transform CSS files, this specific conversion path is not triggered.

Is my application at risk according to Halo Surface Signal?

Halo Surface Signal notes that esm.sh is a public CDN designed to be internet-facing by default. Because it is intended to serve assets globally, any application relying on versions prior to 136 is potentially reachable and at risk if it imports these transformed modules from the CDN.

How do I secure my project against this issue?

The fix is to ensure you are using version 136 or later of the esm.sh service. You should audit your project dependencies to identify where esm.sh is being used, verify the version being fetched, and coordinate with your team to update to the patched version.

References