CVE-2026-49406: Deno Path Traversal Vulnerability
MODERATECVE-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
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).
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.
Upgrade deno to 2.7.12
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
CVE-2026-49406 Affected Deno Versions
1 component(s)| 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?
Which Deno versions are affected?
What version fixes CVE-2026-49406?
Is deno affected?
What is the CVSS score of CVE-2026-49406?
What CWE is associated with CVE-2026-49406?
How can I check crates.io dependencies for CVE-2026-49406?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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"
}
}