CVE-2026-49406: Deno: BYONM module resolution allows `package.json` main path traversal to bypass `--allow-read` restrictions

Published Jun 16, 2026
·
Updated

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 nodemodules/<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 nodemodules 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:

json { "main": "../../../secret.json" }

resolved to nodemodules/pkg/../../../secret.json, escaping nodemodules entirely. The BYONM permission check accepted any path that contained a nodemodules 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/denobyonmpoc/ ├── app/ │ ├── deno.json (BYONM enabled) │ ├── exploit.ts (require("evil-pkg")) │ └── nodemodules/ │ └── evil-pkg/ │ └── package.json (main: "../../../secret.json") └── secret.json (outside --allow-read scope)

Run:

bash deno run --no-prompt --allow-read=/tmp/denobyonmpoc/app exploit.ts

Observed:

- Deno.readTextFileSync("/tmp/denobyonmpoc/secret.json") — blocked, as expected. - require("evil-pkg") — returned the parsed contents of secret.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 nodemodules 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/.mjs targets 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.json main fields in nodemodules for .. segments before running. - Granting --allow-read only 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).

Other sources

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 nodemodules/<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.

— MITRE

Affected Software

2 affected componentsFixes available
rust/deno<=2.7.11
2.7.12
Deno Deno<2.7.12

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade rust/deno to a version that resolves this vulnerability.

    Fixed in 2.7.12
  2. Upgrade

    Upgrade Deno to a version that resolves this vulnerability.

    Fixed in 2.7.12
  3. Configuration

    Avoid running Deno in BYONM mode using `nodeModulesDir: "manual"` on versions prior to 2.7.12, since BYONM module resolution could follow `package.json` `main` path traversal (`..`) and bypass `--allow-read` boundaries.

    Deno nodeModulesDir = manual (BYONM) -> avoid

Event History

Jun 16, 2026
Advisory Published
via GitHub·07:11 PM
Data Sourced
via GitHub·07:11 PM
DescriptionSeverityWeaknessAffected Software
Jun 23, 2026
CVE Published
via MITRE·05:19 PM
Data Sourced
via MITRE·05:19 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·06:18 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2026-49406?

CVE-2026-49406 has a medium severity rating of 5.5.

2

How do I fix CVE-2026-49406?

To mitigate CVE-2026-49406, ensure that your Deno environment is configured not to use the BYONM mode with untrusted package sources.

3

What category of vulnerability does CVE-2026-49406 fall under?

CVE-2026-49406 is categorized as a Path Traversal vulnerability.

4

What software is affected by CVE-2026-49406?

CVE-2026-49406 affects the Rust-based Deno software.

5

When was CVE-2026-49406 published?

CVE-2026-49406 was published on June 16, 2026.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203