CVE-2025-59342 esm.sh writes arbitrary files via path traversal in `X-Zone-Id` header

Medium 5.5 Published Updated

Attackers can write arbitrary files to the server via path traversal in the X-Zone-Id header, potentially compromising the CDN infrastructure.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2025-59342?

CVE-2025-59342 is a medium-severity path traversal vulnerability in esm-dev esm.sh, published on 17 Sep 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official description

esm.sh is a nobuild content delivery network(CDN) for modern web development. In 136 and earlier, 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. Version 136.1 contains a patch.

Weakness: CWE-24

Which versions are affected by CVE-2025-59342?

3 open source packages ship an affected version, including github.com/esm-dev/esm.sh.

PackageAffectedFixed in
github.com/esm-dev/esm.sh GoAll versionsNone
github.com/esm-dev/esm.sh GoAll versions136.1
github.com/esm-dev/esm.sh GoAll versions136.1

How do I fix CVE-2025-59342?

Upgrade github.com/esm-dev/esm.sh to 136.1 or later.

Upgrade, and resolve every user-supplied path against an allowed base folder before opening it. More about Path traversal.

Is CVE-2025-59342 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-59342 exists.

Public exploit code: 1 Exploit-DB entry, 1 Nuclei template and 1 proofs of concept on GitHub.

Sources

Also known as GHSA-g2h5-cvvr-7gmw, GO-2025-3967.

Is CVE-2025-59342 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free