The vulnerability is a path traversal issue in pnpm, occurring when installing packages from file: or git: sources. The root cause is the insecure handling of symbolic links within the package being installed. The code in store/cafs/src/addFilesFromDir.ts used fs.statSync() and fs.readFileSync(), both of which follow symlinks by default. A malicious package could contain a symlink pointing to a sensitive file on the developer's machine (e.g., /etc/passwd, ~/.ssh/id_rsa). When pnpm installs this package, the addFilesFromDir and its helper function findFiles would follow the symlink and copy the contents of the target file into the project's node_modules directory, thus leaking local data.
The patch addresses this by replacing fs.statSync with fs.lstatSync to detect symlinks without following them. It then explicitly resolves the symlink's target path using fs.realpathSync and validates that this path is within the package's root directory using the is-subdir library. If the symlink points outside the package, it is skipped. The primary vulnerable functions are addFilesFromDir and findFiles, as they were responsible for the file traversal that followed these malicious symlinks.