CVE-2026-49406: Deno Path Traversal Vulnerability

MODERATE
Advisory Identifier: GHSA-968w-xfqw-vp9q
CVSS 5.5
CWE-22
Published
Advisory Summary

CVE-2026-49406 is a MODERATE (CVSS 5.5) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Deno libraries in the crates.io ecosystem. The issue involves byonm module resolution allows `package.json` main path traversal to bypass `--allow-read` restrictions. Remediation is available by upgrading affected packages to version 2.7.12.

CVE-2026-49406 at a Glance

CVE Identifier CVE-2026-49406
GHSA Identifier GHSA-968w-xfqw-vp9q
Severity MODERATE
CVSS v3.1 Base Score 5.5
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Deno
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 5.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2026-49406

To remediate this vulnerability, upgrade all affected Deno dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

deno fixed: 2.7.12
Upgrade deno to 2.7.12
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for deno

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-49406, inspect your project dependencies for Deno:

inspect dependencies for deno

Analyze the terminal output to locate any version of Deno in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.7.12), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Deno, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## 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: ```json { "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: ```bash 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 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 `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`/`.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 `node_modules` 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).

CVE-2026-49406 Affected Deno Versions

1 component(s)
Fixed Versions:
2.7.12
Product / Package Ecosystem Affected Versions Fixed Version
deno
crates.io
< 2.7.12
2.7.12

References

Frequently Asked Questions

What is CVE-2026-49406?
CVE-2026-49406 is a security vulnerability in Deno involving BYONM module resolution allows `package.json` main path traversal to bypass `--allow-read` restrictions under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Deno versions are affected?
Affected versions include releases prior to 2.7.12 across affected packages: deno.
What version fixes CVE-2026-49406?
Upgrading to 2.7.12 (or the latest patched release for your respective branch) resolves the vulnerability.
Is deno affected?
Yes, deno is affected in releases prior to 2.7.12. Upgrade your dependency to 2.7.12 or later.
What is the CVSS score of CVE-2026-49406?
CVE-2026-49406 has a CVSS v3.1 base score of 5.5 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2026-49406?
CVE-2026-49406 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check crates.io dependencies for CVE-2026-49406?
Run the dependency tree command: 'inspect dependencies for deno'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-968w-xfqw-vp9q",
  "modified" : "2026-07-20T13:43:23Z",
  "published" : "2026-06-16T19:11:26Z",
  "aliases" : [ "CVE-2026-49406" ],
  "summary" : "Deno: BYONM module resolution allows `package.json` main path traversal to bypass `--allow-read` restrictions",
  "details" : "## Summary\n\nWhen 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.\n\n## Details\n\nIn 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.\n\nThe path joined from `main` was not constrained to the package root. A `package.json` such as:\n\n```json\n{ \"main\": \"../../../secret.json\" }\n```\n\nresolved 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.\n\nBecause 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.\n\nThe 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.\n\n## Proof of concept\n\nThe reporter supplied a self-contained PoC. Layout:\n\n```\n/tmp/deno_byonm_poc/\n├── app/\n│   ├── deno.json            (BYONM enabled)\n│   ├── exploit.ts           (require(\"evil-pkg\"))\n│   └── node_modules/\n│       └── evil-pkg/\n│           └── package.json (main: \"../../../secret.json\")\n└── secret.json              (outside --allow-read scope)\n```\n\nRun:\n\n```bash\ndeno run --no-prompt --allow-read=/tmp/deno_byonm_poc/app exploit.ts\n```\n\nObserved:\n\n- `Deno.readTextFileSync(\"/tmp/deno_byonm_poc/secret.json\")` — blocked, as\n  expected.\n- `require(\"evil-pkg\")` — returned the parsed contents of `secret.json`,\n  bypassing the read allowlist.\n\nA control run with BYONM disabled (`--no-config`) blocked the `require` call.\n\n## Impact\n\nThe 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.\n\nThe 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\npromised that `--allow-read=<scope>` was a hard boundary *even over untrusted npm code*, and that promise was broken.\n\nNot affected:\n\n- Runs without BYONM (default npm resolution went through a separate code\n  path that rejected the traversal).\n- Runs with full `--allow-read` (no boundary to bypass).\n- Non-JSON entrypoints, in practice — `.js`/`.cjs`/`.mjs` targets executed\n  rather than exposing file contents, which already implied attacker code\n  execution within the granted permission set.\n\n## Workarounds\n\nUsers on unpatched versions could mitigate by:\n\n- Avoiding BYONM mode (`nodeModulesDir: \"manual\"`) for projects that depended\n  on untrusted packages.\n- Auditing `package.json` `main` fields in `node_modules` for `..` segments\n  before running.\n- Granting `--allow-read` only when the read scope already covered every file\n  the OS user could see (in which case there was no boundary to bypass and no\n  additional exposure).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "deno"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.7.12"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.7.11"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/denoland/deno/security/advisories/GHSA-968w-xfqw-vp9q"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-49406"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/denoland/deno"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-16T19:11:26Z",
    "nvd_published_at" : "2026-06-23T18:18:03Z"
  }
}