The vulnerability is a path traversal weakness in Deno's "Bring Your Own Node Modules" (BYONM) feature. When a user calls require() on an npm package, Deno's module resolver reads the main field of the package's package.json to find the entrypoint. A malicious package could craft a main field with ../ sequences to point to a file outside of its own directory. The vulnerable code would resolve this path and read the file, bypassing Deno's --allow-read permission checks.
The analysis identified the fixing commit by comparing the git tags of the last vulnerable version (v2.7.11) and the first patched version (v2.7.12). The key commit, 8295a2cf2aabe2ecd9ccce8a802d0d5d61095a2e, is explicitly titled "fix(node): validate resolved main path stays within package directory".
This commit patched the vulnerability in two places:
-
ext/node/polyfills/01_require.js: In the JavaScript implementation of require, the tryPackage function was modified to add a check ensuring the resolved path of the main entry does not escape the package's root directory.
-
libs/node_resolver/resolution.rs: In the core Rust implementation, the function legacy_main_resolve (as identified from the commit message) within the NpmPackageResolver was updated to validate the resolved path. It now checks if the resolved path guess still starts with the package_path, preventing traversal.
Both of these functions are directly responsible for processing the malicious package.json and were the points where the path traversal was possible. An exploit would trigger these functions, making them key indicators in a runtime profile.