/

CVE-2026-44594

Severity:

HIGH RISK

(7.5)

Local File Inclusion in esm.sh esbuild Plugin

CVE-2026-44594

Deferred

Vulnerability type

Category:

Local File Inclusion

CWE:

CWE-22

Impact:

Arbitrary File Read on Server Filesystem

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A Local File Inclusion vulnerability in esm.sh's esbuild plugin allows crafted npm packages to influence how the browser field in package.json is resolved, causing the server to read arbitrary files from the host filesystem.

When a malicious package is processed during the build pipeline, the CDN server may return contents of sensitive local files as part of the build response.

Affected context

The vulnerability arises in esm.sh deployments that use the esbuild-based pipeline to process third‑party npm packages and honor the browser field in package.json.

It is relevant when:

  • The CDN or build service automatically fetches and builds npm packages supplied by users or upstream registries
  • The build process runs with filesystem access to sensitive paths (e.g., configuration, credentials, or source code)
  • The browser field is resolved in a way that can reference local filesystem paths instead of only controlled, in-package files

In these conditions, a malicious package can influence resolution logic and cause unintended file reads during build.

Exploit preconditions

  • Attack surface: The esm.sh build API / CDN endpoint that accepts npm package names or versions to build.
  • Required access: Ability to publish or control an npm package that esm.sh will fetch and build (for example, pointing the CDN at an attacker-controlled package name or version).
  • Trigger point: The build process when esbuild resolves module entry points and dependency paths using the browser field in package.json.
  • Why exploitation is possible: Path resolution logic around the browser field permits references that escape the intended package scope, allowing the plugin to open and read arbitrary paths on the server filesystem (CWE-22: Path Traversal / Local File Inclusion).

Why this happens

The core issue is insufficient validation of filesystem paths derived from untrusted metadata, specifically the browser field in package.json processed by the esbuild plugin.

Instead of constraining resolution to safe, package-local paths, the plugin allows attacker-controlled values to influence which files are opened on the host system.

This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where user-influenced paths are not properly normalized, validated, or sandboxed, enabling access to arbitrary files outside the intended directory boundary.

Potential impact

  • An attacker may read sensitive configuration files present on the CDN/build host.
  • An attacker may access source code or internal scripts deployed alongside the service.
  • An attacker could obtain credentials, API keys, or secrets stored in readable files.
  • An attacker can potentially map parts of the server's filesystem structure by probing for readable paths.

General mitigation guidance

Effective mitigation centers on strict path handling and sandboxing during build:

  • Constrain resolution of the browser field and similar metadata-derived paths to the package's own directory, rejecting any absolute paths or path traversal segments (e.g., ..).
  • Normalize and validate all paths before file access, enforcing explicit allowlists of directories that builds are permitted to read from.
  • Run build processes under a dedicated, low-privilege account with access only to an isolated working directory, avoiding shared secrets or sensitive configuration in that context.
  • Consider using chroot-like jails, containers, or virtualized build sandboxes so that even if path validation fails, the accessible filesystem is limited.
  • Reduce trust in package metadata by ignoring or tightly constraining fields that can redirect resolution (like browser) when operating a multi-tenant CDN or public build service.

How teams detect issues like this

Detection usually combines code-level review with behavioral monitoring:

  • Static analysis / code review: Look for file access operations in the esbuild plugin and related code that rely on package metadata (e.g., browser, main, or custom fields) without strict validation or normalization of paths.
  • Configuration / policy checks: Enforce internal policies requiring safe path-joining utilities, package-local path enforcement, and prohibition of absolute paths or traversal segments in resolution logic.
  • Runtime monitoring: Instrument build workers to log file access patterns, especially reads outside expected working directories; alert on attempts to read known sensitive locations (/etc, home directories, secret mounts).
  • Automated tooling: Integrate SAST or custom linters into CI for the CDN/build service codebase to detect usages of untrusted metadata in path construction and file reads.

Sources

SourceLink
github.comgithub.com/esm-dev/esm.sh/security/advisories/GHSA-rg65-45m7-hq57

Frequently asked

questions

Yes. If the CDN or build service accepts package identifiers over the network and will build attacker-controlled npm packages, a remote attacker can trigger the vulnerability by publishing and referencing a malicious package.

The attacker needs the ability to publish or control a package that the service will build, or otherwise influence which npm package the esm.sh instance processes. No shell access to the server is required; control over package metadata is sufficient.

The most robust fix is to strictly sandbox and validate all filesystem accesses driven by package metadata: limit path resolution to the package directory, reject traversal/absolute paths, and run builds in isolated, least-privilege environments so that even if a bug occurs, accessible files are minimized.

Design build and CDN pipelines around explicit trust boundaries: treat all package metadata as untrusted input, centralize path normalization and validation, use defensive libraries for safe path resolution, and regularly audit build tools for any file operations influenced by user-controlled or registry-provided data.

Find out what's already
exploitable in your codebase.