5.5medium
Deno: BYONM module resolution allows `package.json` main path traversal to bypass `--allow-read` restrictions
- Severity
- 5.5medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.17% (higher than 6% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-968w-xfqw-vp9q
Description
Deno is a JavaScript, TypeScript, and WebAssembly runtime. Prior to 2.7.12, when Deno was run in BYONM mode (nodeModulesDir: "manual"), the module resolver did not validate that a package's resolved entrypoint stayed within its node_modules/<pkg>/ directory. A malicious package.json whose main field contained .. segments was able to resolve to an arbitrary path on disk, and the resolver then read that file without consulting the --allow-read allowlist. This let a require("evil-pkg") call return the contents of a file that a direct Deno.readTextFileSync(...) call would have been blocked from reading. This vulnerability is fixed in 2.7.12.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| denoland deno | < 2.7.12 | CVE List |
| deno (crates.io) | before 2.7.12 | GitHub Advisory Database |
| deno deno | before 2.7.12 | NVD |
All scores
| GitHub_M | 5.5medium CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N |
| GitHub | 5.5medium CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N |
Classification
SSVC (CISA-ADP): exploitation poc, automatable no, technical impact partial.
What each source says
CVE List
Deno is a JavaScript, TypeScript, and WebAssembly runtime. Prior to 2.7.12, when Deno was run in BYONM mode (nodeModulesDir: "manual"), the module resolver did not validate that a package's resolved entrypoint stayed within its node_modules/<pkg>/ directory. A malicious package.json whose main field contained .. segments was able to resolve to an arbitrary path on disk, and the resolver then read that file without consulting the --allow-read allowlist. This let a require("evil-pkg") call return the contents of a file that a direct Deno.readTextFileSync(...) call would have been blocked from reading. This vulnerability is fixed in 2.7.12.
GitHub Advisory Database
Summary
When Deno was run in BYONM mode (nodeModulesDir: "manual"), the module resolver did not validate that a package's resolved entrypoint stayed within its node_modules/<pkg>/ directory. A malicious package.json whose main field contained .. segments was able to resolve to an arbitrary path on disk, and the resolver then read that file without consulting the --allow-read allowlist. This let a require("evil-pkg") call return the contents of a file that a direct Deno.readTextFileSync(...) call would have been blocked from reading.
Details
In BYONM mode, Deno resolved npm packages directly from a user-managed node_modules tree. Resolution of require("pkg") proceeded by reading pkg/package.json, taking the main field, joining it to the package directory, and loading the result as a module.
The path joined from main was not constrained to the package root. A package.json such as:
{ "main": "../../../secret.json" }
resolved to node_modules/pkg/../../../secret.json, escaping node_modules entirely. The BYONM permission check accepted any path that contained a node_modules component and did not reject .. traversal, so the resolved path was loaded without a read-permission check.
Because resolution loaded JSON entrypoints by parsing their contents and returning them through require, this exposed the contents of arbitrary .json files reachable by the OS user to the requiring code, even when --allow-read had been narrowed to a specific directory.
The same file accessed via Deno.readTextFileSync was correctly blocked. The bug was that module resolution did not enforce the same read-permission boundary that the filesystem APIs enforced.
Proof of concept
The reporter supplied a self-contained PoC. Layout:
/tmp/deno_byonm_poc/
├── app/
│ ├── deno.json (BYONM enabled)
│ ├── exploit.ts (require("evil-pkg"))
│ └── node_modules/
│ └── evil-pkg/
│ └── package.json (main: "../../../secret.json")
└── secret.json (outside --allow-read scope)
Run:
deno run --no-prompt --allow-read=/tmp/deno_byonm_poc/app exploit.ts
Observed:
Deno.readTextFileSync("/tmp/deno_byonm_poc/secret.json")— blocked, as expected.require("evil-pkg")— returned the parsed contents ofsecret.json, bypassing the read allowlist.
A control run with BYONM disabled (--no-config) blocked the require call.
Impact
The vulnerability allowed a hostile npm package installed under a BYONM node_modules to read JSON files outside the directories granted via --allow-read, up to the privileges of the OS user running Deno. In practice this exposed configuration and credential files (.env.json, cloud credentials, package lockfiles, etc.) that the user had deliberately excluded from the read scope.
The vulnerability did not grant any capability beyond what the OS user already held, did not affect runs that granted unrestricted --allow-read, and required the user to have installed and then required a hostile package, i.e. an existing supply-chain compromise. The reason it warranted a security advisory rather than a routine bug fix is that Deno's permission model
promised that --allow-read=<scope> was a hard boundary even over untrusted npm code, and that promise was broken.
Not affected:
- Runs without BYONM (default npm resolution went through a separate code path that rejected the traversal).
- Runs with full
--allow-read(no boundary to bypass). - Non-JSON entrypoints, in practice —
.js/.cjs/.mjstargets executed rather than exposing file contents, which already implied attacker code execution within the granted permission set.
Workarounds
Users on unpatched versions could mitigate by:
- Avoiding BYONM mode (
nodeModulesDir: "manual") for projects that depended on untrusted packages. - Auditing
package.jsonmainfields innode_modulesfor..segments before running. - Granting
--allow-readonly when the read scope already covered every file the OS user could see (in which case there was no boundary to bypass and no additional exposure).
NVD (es)
Deno es un entorno de ejecución de JavaScript, TypeScript y WebAssembly. Antes de la versión 2.7.12, cuando Deno se ejecutaba en modo BYONM (nodeModulesDir: ’manual’), el resolvedor de módulos no validaba que el punto de entrada resuelto de un paquete permaneciera dentro de su directorio node_modules/[pkg]/. Un package.json malicioso cuyo campo main contenía segmentos .. podía resolverse a una ruta arbitraria en el disco, y el resolvedor luego leía ese archivo sin consultar la lista de permitidos --allow-read. Esto permitía que una llamada require(’evil-pkg’) devolviera el contenido de un archivo que una llamada directa Deno.readTextFileSync(...) habría sido bloqueada para su lectura. Esta vulnerabilidad está corregida en la versión 2.7.12.
References
| https://github.com/denoland/deno/security/advisories/GHSA-968w-xfqw-vp9q | exploit, mitigation, vendor-advisory, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2026-49406 | advisory | |
| https://github.com/denoland/deno | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-49406 changed 2026-06-23 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-968w-xfqw-vp9q changed 2026-07-20 | CC-BY-4.0 |
| NVD | CVE-2026-49406 changed 2026-10-25 | Public domain |