The vulnerability is a path traversal issue in pnpm's handling of the 'bin' field in a package.json file. The root cause lies in two functions within 'pkg-manager/package-bins/src/index.ts': 'commandsFromBin' and 'normalizeBinName'.
The 'commandsFromBin' function was responsible for processing the bin entries. Its filtering logic explicitly allowed any bin name starting with an '@' symbol to bypass URI-component encoding validation. This was the entry point for the vulnerability.
This unfiltered input was then passed to the 'normalizeBinName' function. This function would strip the npm scope from the bin name (e.g., '@scope/'), but it failed to remove any path traversal sequences that followed. For example, an input of '@scope/../../evil' would result in an output of '../../evil'.
This malicious, normalized path was then used to create a symlink or shim in the 'node_modules/.bin' directory, allowing an attacker to write files to arbitrary locations on the filesystem relative to the project root, leading to potential remote code execution or configuration file overwrites.
The patch addresses this by completely rewriting the 'commandsFromBin' function. The new implementation performs validation after normalizing the bin name, ensuring that any path traversal sequences are detected and rejected. The separate 'normalizeBinName' function was removed entirely, and its logic was integrated into the new, more secure 'commandsFromBin' function.