The vulnerability exists in the extractPackageTarball function located in server/npmrc.go. The function is responsible for extracting files from a tarball as part of handling NPM packages. The core of the vulnerability lies in the line filename := path.Join(pkgDir, name), where name is a path extracted from the tarball header. The code fails to sanitize or validate the name variable before joining it with the base package directory pkgDir. This allows an attacker to include ../ path traversal sequences in the file names within a malicious tarball. When the server extracts this tarball, it will write files to arbitrary locations on the filesystem, outside of the intended destination. The provided patch confirms this analysis by introducing path.Clean() to the vulnerable line, which is the standard Go practice to prevent such path traversal attacks by cleaning the path. The exploit is made possible by using the X-Npmrc header to point the esm.sh service to an attacker-controlled registry serving the malicious package.