Skip to content
STIRUP

TECHNOLOGY INTELLIGENCE

Understand what's next.

Deno's Permissions System and Its Security Limitations

Deno's permissions system restricts JavaScript code from interacting with the outside world without explicit approval, but limitations exist, such as environment variables for child processes being set without additional permissions, potentially leading to unexpected behavior.

Share
AI-generated conceptual illustration accompanying: Deno's Permissions System and Its Security Limitations
AI-generated editorial illustration of the article topic; not a photograph, product screenshot or measured result.

Deno's Permissions System and Its Limitations

Deno’s permissions system is designed to restrict JavaScript code from interacting with the outside world without explicit approval. For instance, when running deno run --allow-read=/tmp/dir --allow-run=uname code.ts, the standard library limits code.ts to only reading from /tmp/dir and executing the uname command, as noted in Lobsters. This model aims to prevent unintended access to system resources, though it relies on users correctly specifying allowed actions.

However, limitations exist. As highlighted in Lobsters, environment variables for child processes can be set without requiring additional permissions. This can lead to unexpected behavior, such as executing a modified uname script that outputs lol instead of the actual system information, as demonstrated in the example. While this is not a flaw in the permissions model itself, it underscores the importance of carefully managing environment variables and ensuring scripts are trusted.

Security Risks from Environment Variables and Command Execution

Deno’s security model faces challenges when handling environment variables and command execution. As demonstrated in Lobsters, environment variables can be set for child processes without requiring additional permissions, potentially allowing malicious code to execute. For example, a script can manipulate the PATH variable to point to a tampered binary, leading to unexpected behavior. Similarly, Lobsters highlights how environment variables like LD_PRELOAD can be used to inject arbitrary shared libraries, effectively bypassing the sandbox. This underscores a broader issue: programs are not uniquely identified by their names, as noted in Lobsters, which can lead to security vulnerabilities if not properly addressed. These examples illustrate that while Deno aims to provide a secure runtime, its current implementation may leave gaps that could be exploited if not carefully managed.

False Sense of Security and Implications of Deno's Model

In discussions around Deno’s security model, some developers have raised concerns about the potential for a false sense of security. As noted in GitHub issues, a Deno developer stated that the model primarily protects users from malicious code that isn't sophisticated enough. However, another contributor disagreed, arguing that Deno’s permission system may give users a misleading impression of safety, potentially leading them to run untrusted code without adequate sandboxing. This approach implicitly places the burden on users to fully understand the implications of various permissions and their combinations, which can be complex and challenging. While Deno’s model aims to enhance security through granular controls, critics suggest that it may not sufficiently address advanced threats or ensure robust isolation of untrusted code.

Deno's Inability to Fully Sandbox Processes

In 2024, concerns about Deno’s security model continue to surface, particularly regarding its inability to fully sandbox processes. As noted in one discussion, the security model breaks down when running code that does not use the Deno standard library. Another point raised highlights that Deno does not prevent users from following symlinks that lead outside of the sandbox, which ultimately points to a core issue: the process is not sandboxed. While some may argue that features like --allow-run=uname offer flexibility, they also introduce potential security risks. These observations underscore the limitations of Deno’s current approach to process isolation and highlight the need for more robust sandboxing mechanisms to ensure secure execution environments.

Mitigation Strategies and Caveats for Safe Use

Mitigation Strategies and Caveats for Safe Use

  • It’s possible that you can use Deno sandboxing safely if you never use more dangerous permissions like --allow-run, even with =cmd.
  • That includes --allow-env, even --allow-env=VAR, for setting environment variables is memory unsafe and can affect libc functions.
  • Preferably run with --no-prompt so your terminal can’t be tricked.
  • Be careful about symlinks in directories you --allow-{read,write} to.
  • Be aware that resource exhaustion is not mitigated: there’re zero permissions required to burn CPU or allocate memory.

Sources and reporting notes

Based on published source material. No independent hands-on testing is claimed.

Read more