Deno's Permission Model: Terminal Prompts and --allow-run Escape Paths
A technical blog argues that Deno's permission prompts are vulnerable to terminal manipulation and --allow-run can be bypassed via PATH and LD_PRELOAD; the Deno process is not actually sandboxed.
Terminal Prompts on an Attacker-Controlled Channel
Deno is a JavaScript runtime that bundles a standard library, package manager, and TypeScript transpiler, and runs JavaScript on V8. Its permission system is marketed as “Secure by default.” The --allow-read=/tmp/dir --allow-run=uname flags restrict file and command access. Runtime permission requests such as Deno.permissions.request() display a terminal prompt and wait for the user to approve or deny.
That prompt is just text on stdout waiting for input from stdin. Terminals use an in-band protocol: applications send commands by printing to stdout, and the terminal replies via stdin. Deno does not restrict printing to stdout or reading from stdin, so malicious code can send arbitrary commands to the terminal. Normally that is harmless; terminals don’t execute shell commands from stdout. But when the same terminal is used for a security prompt after malicious code has had full access to it, the prompt cannot be trusted.
An attacker can hide the prompt by changing terminal colors. The issue was later closed with the explanation that the prompt is “partially visible” because an emoji remains, and that “AI agents tend to” change terminal colors. Another technique pre-feeds approval into stdin, or tricks the terminal into sending approval as a response to a “press Enter to continue” request, so the user never sees the actual prompt. The specific exploit shown in an asciicast was patched, but the terminal color issue remains. Even if all standard escape codes are handled, non-standard terminal features are unpredictable. The core flaw is that security-sensitive information travels over a channel controlled by the attacker, similar to asking for a password on a page that runs attacker-controlled JavaScript.
–allow-run Breaks Down
--allow-run=uname is not a canonical program name. It tells Deno to search PATH for an executable named uname. Environment variables for the child process can be set without extra permissions. An attacker can point PATH to a directory containing a fake uname script, and deno run --allow-run=uname will execute it.
Fixing the PATH lookup does not solve the problem. Dynamically linked executables rely on a dynamic loader, which is configurable through environment variables. Setting LD_PRELOAD causes the loader to load a shared library before running the program; library constructors can execute arbitrary code. Deno later blocked environment variables starting with LD_, but that is a patch for one specific technique. The larger problem remains: permission to run a single command is not a meaningful security boundary.
Consider a script that requests permission to run $EDITOR so the user can edit data, like a git commit message. A user may grant --allow-run=vim without much thought, but the script can set VIMINIT='!rm -rf /*', and launching vim will execute that command. Most programs are configurable in ways that escape the intended restriction, and the attacker controls the execution environment. Patching individual configuration vectors is futile.
A Pretend Sandbox
Deno tries to do what the operating system should do by emulating syscall filtering through standard library calls. That emulation collapses when code runs outside the Deno standard library. The Deno process is not actually sandboxed; it only pretends to be. For example, Deno does not prevent symlinks from pointing outside an allowed directory. A Deno developer wrote in a GitHub discussion: “The main thing it protects you against is malicious code that isn’t smart enough.”
The author of the blog post argues that pseudo-sandboxing is worse than nothing because it creates a false sense of security. Users may run untrusted code without a proper sandbox, believing permissions protect them. Some safety measures are possible: avoid –allow-run and –allow-env, use –no-prompt to keep the terminal from being tricked, watch for symlinks, and accept that resource exhaustion requires no permissions at all. But the author still recommends against relying on Deno’s permission system for untrusted code. The moment a program needs OS interaction, it is no longer running with “no permissions.” The appropriate response is to use a real sandbox like bwrap.