Описание
esm.sh has a path traversal in extractPackageTarball enables file writes from malicious packages
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:
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.
Ссылки
- https://github.com/esm-dev/esm.sh/security/advisories/GHSA-2657-3c98-63jq
- https://nvd.nist.gov/vuln/detail/CVE-2026-23644
- https://github.com/esm-dev/esm.sh/commit/9d77b88c320733ff6689d938d85d246a3af9af16
- https://github.com/esm-dev/esm.sh/commit/c62ab83c589e7b421a0e1376d2a00a4e48161093
- https://pkg.go.dev/vuln/GO-2025-4138
Пакеты
github.com/esm-dev/esm.sh
>= 0.0.1, <= 136
Отсутствует
github.com/esm-dev/esm.sh
< 0.0.0-20260116051925-c62ab83c589e
0.0.0-20260116051925-c62ab83c589e
Связанные уязвимости
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.