/

CVE-2026-102657

Severity:

HIGH RISK

(7.5)

Path Traversal (CWE-22) in esm.sh Static File Server

CVE-2026-102657

Deferred

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Unauthorized file disclosure

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

The esm.sh static file server can resolve URL-decoded paths outside its configured application directory because it does not verify that the joined path remains within that directory. An unauthenticated remote attacker may be able to retrieve files readable by the server process, including when Dev is disabled.

Affected context

The issue occurs in the documented web.NewHandler static file server in web/handler.go. It is relevant when URL-decoded request paths are joined with Config.AppDir without checking that the resolved path stays within that directory. URL-encoded dot segments can bypass the plain traversal redirect performed by Go's ServeMux; the issue is reachable with Dev disabled.

Exploit preconditions

  • Attack surface: The esm.sh web server's static file handler, reachable over HTTP.
  • Required access: No authentication is required.
  • Trigger point: A request containing URL-encoded path traversal segments that are decoded and joined with Config.AppDir.
  • Why exploitation is possible: The handler does not verify that the resulting file path remains within the configured application directory. Disclosure is limited to files readable by the server process.

Why this happens

The handler joins a URL-decoded path with the configured application directory without enforcing path confinement. This is a path traversal flaw, mapped to CWE-22: Improper Limitation of a Pathname to a Restricted Directory. A pathname that includes traversal components can resolve outside the intended directory when the application does not canonicalize and validate the final path before opening it.

Potential impact

  • An attacker could retrieve files outside the application directory that are readable by the server process.
  • Exposed files may disclose sensitive information, depending on the server's filesystem permissions and contents.
  • The confirmed impact is file disclosure; code execution is not established.

General mitigation guidance

Defensive patterns for static file serving include:

  • Resolve and canonicalize requested paths, then verify the final path remains beneath the configured root before opening it.
  • Prefer file-serving APIs or designs that enforce directory confinement by default.
  • Treat URL paths as untrusted input and validate them after decoding and normalization.
  • Run the server with least-privilege filesystem permissions and limit its access to sensitive files.

How teams detect issues like this

  • Use static analysis to identify joins between request-derived paths and filesystem roots that lack a containment check.
  • Review file-serving code for validation performed before decoding or normalization, or for checks that do not apply to the final resolved path.
  • Test path-confinement policies with encoded and normalized traversal variants in controlled security tests.
  • Monitor access logs for unusual requests targeting paths outside the expected static-file namespace.

Sources

SourceLink
github.comgithub.com/esm-dev/esm.sh/commit/468b6b2a4b4dfec334cf6b33b01fcd4e5cd93bed
github.comgithub.com/esm-dev/esm.sh/commit/fc3b345e73aeaa0b7a05b6f27d91c05fdf5f9b53
github.comgithub.com/esm-dev/esm.sh/pull/1376
github.comgithub.com/esm-dev/esm.sh/releases/tag/v137_7
github.comgithub.com/esm-dev/esm.sh/security/advisories/GHSA-g3c2-rjq2-c763

Frequently asked

questions

Yes. The static file handler is reachable over HTTP, and the issue does not require authentication.

No. The described issue is reachable with Dev disabled.

Enforce confinement on the final resolved path before opening a file, or use a file-serving design that provides this protection by default.

Treat request paths as untrusted, validate them after decoding and normalization, test encoded traversal cases, and restrict the server process's filesystem permissions.

Find out what's already
exploitable in your codebase.