How Deno protects against npm exploits
Recent npm compromises (@ctrl/tinycolor via a malicious postinstall script, and debug/chalk via phishing) exploited Node and npm's default of giving every dependency full access to the filesystem, network and environment. Deno runs Node apps in a sandbox with no OS access by default. Access is granted through flags such as --allow-read, --allow-net and --allow-env, which can be scoped to specific paths or hosts or grouped into permission sets in deno.json. Deno also skips postinstall scripts unless allowed per package with --allow-scripts, and can log permission use via DENO_AUDIT_PERMISSIONS and DENO_TRACE_PERMISSIONS. Its standard library and the JSR registry, which offers publish authorization and automatic provenance statements, further reduce dependency sprawl and supply-chain risk.
Related posts
- Deno 2.6: dx is the new npx
Deno mediumAdeptDeno 2.6 adds `dx`, an npx equivalent for running npm and JSR package binaries that defaults to full permissions, prompts before download and runs lifecycle scripts. It also adds `--ignore-read`/`--ignore-env` flags that return NotFound/undefined instead of NotCapable errors, plus an experimental permission broker process for mediating permission requests. Other changes include opt-in type checking with the Go-based tsgo (about 2x faster on internal projects), Wasm source phase imports, `--require` for preloading CommonJS, and `deno audit` with optional socket.dev integration. Supply-chain controls include `deno approve-scripts` and a `minimumDependencyAge` setting, alongside bundler fixes, default `@types/node`, and many Node.js API compatibility fixes.
- Introducing your new JavaScript package manager: Deno
Deno mediumAdeptDeno 2 adds `deno add`, `deno remove`/`uninstall`, and `deno install` subcommands that manage npm and JSR dependencies in either `deno.json` import maps or an existing `package.json`, so they work inside Node projects too. Installs use a global cache with hard links (Linux) or clonefile (macOS), like pnpm, to save disk space and speed up installs, and `--entrypoint` can pre-cache dependencies for Docker builds. Postinstall scripts are blocked by default and must be allowed per package with `--allow-scripts`. `deno outdated` and `deno update` are planned for the next release.
- Deno 1.28: Featuring 1.3 Million New Modules
Deno mediumAdeptDeno 1.28 stabilizes npm compatibility, letting programs import any of npm's 1.3 million packages via `npm:` specifiers in imports or import maps, and run npm CLIs with `deno run npm:<pkg>`, with no package.json, install step or node_modules folder by default. Deno's opt-in permission prompts restrict what npm dependencies can access, though post-install scripts, `deno compile` and some Node-layout assumptions remain unsupported. The release also auto-discovers and additively updates a `deno.lock` file whenever a deno.json config exists, stabilizes APIs such as `Deno.bench()` and `Deno.networkInterfaces()`, adds an unstable unified `Deno.Command` subprocess API replacing the `Deno.spawn` family, and upgrades to V8 10.9.
- Announcing Deno 2
Deno easyNoviceDeno 2 adds backwards compatibility with Node.js and npm, so it runs existing Node projects using package.json, node_modules and npm workspaces, and supports npm: import specifiers without a manifest. It also adds package management commands (deno install/add/remove, claimed 15% faster than npm on a cold cache and 90% faster on a hot cache), private registries via .npmrc, workspaces and monorepos, a stabilized standard library on JSR, and an LTS channel starting with 2.1 that gets six months of backported fixes. Toolchain updates include multi-core deno serve, HTML/CSS/YAML formatting and node:test support. A correction notes HTTP throughput is about 20% lower than charted because V8 pointer compression was disabled to lift the 4GB heap limit.
- Deno 1.36: More flexible security and expanded testing APIs
Deno mediumAdeptDeno 1.36 adds --deny-* flags that complement --allow-* permissions, letting programs open broad access while excluding specific domains, IPs or file paths, with deny taking precedence over allow. Testing gains JUnit and dot reporters plus a node:test polyfill, and Deno.bench fixes V8 JIT bias with a warmup run and adds BenchContext start/end to measure only a critical section. Node compatibility improves with process.dlopen, a fully polyfilled node:os, running non-bin npm scripts, and AsyncLocalStorage up to 3.5x faster. Smaller changes include automatic retries for failed module downloads, clearer Deno.Command errors, http(s) URLs accepted by WebSocket, and LSP fixes.