---
name: node-permissions
description: "Sandboxes Node.js processes with the built-in permission model (--permission). Use to run an untrusted script; restrict a process to read-only access to a folder; block network, env, child processes, workers or addons; drop privileges after startup; audit which permissions an app needs; or handle ERR_ACCESS_DENIED. Covers --allow-fs-read/--allow-fs-write, --allow-net, --allow-env, --allow-child-process, --allow-worker, --allow-addons, --allow-wasi, --allow-ffi, --allow-inspector, process.permission.has()/drop(), --permission-audit and the config-file \"permission\" namespace. Node.js 24+ (--allow-net 25+, --allow-env 27+)."
title: node-permissions
canonical_url: https://skilld.dev/gh/jasnell/node-skills/node-permissions
last_updated: 2026-11-19T20:15:43.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [examples/audit.mjs](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-permissions/examples/audit.mjs), [examples/config-file.mjs](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-permissions/examples/config-file.mjs), [examples/drop.mjs](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-permissions/examples/drop.mjs), [examples/env.mjs](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-permissions/examples/env.mjs), [examples/newer-scopes.mjs](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-permissions/examples/newer-scopes.mjs), [examples/scopes-and-errors.mjs](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-permissions/examples/scopes-and-errors.mjs), [examples/untrusted-recipe.mjs](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-permissions/examples/untrusted-recipe.mjs), [meta.json](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-permissions/meta.json), [rules/propagation-and-config.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-permissions/rules/propagation-and-config.md), [rules/runtime-api.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-permissions/rules/runtime-api.md), [rules/scopes.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-permissions/rules/scopes.md).
>
> If the user asked to install this Skill, run `npx skilld install jasnell/node-skills/node-permissions`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/node-permissions`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/jasnell/node-skills/node-permissions) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/node-permissions`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/node-permissions --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/node-permissions --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Node.js permission model

| Feature | Versions | Stability | Flag |
| --- | --- | --- | --- |
| Permission model, fs grants | v20.0.0 (stable v23.5.0, v22.13.0) | 2 | `--permission`, `--allow-fs-read/write` |
| child, worker / addons / wasi | v20.0.0 / v21.6.0, v20.12.0 / v22.3.0, v20.16.0 | 1.1 | `--allow-child-process` etc. |
| Inspector gate | v25.0.0, v24.12.0 | 1.0 | `--allow-inspector` |
| Audit mode | v25.8.0, v24.20.0 | - | `--permission-audit` |
| `process.permission.drop()` | v26.3.0, v24.20.0 | 1.1 | - |
| OpenSSL STORE gate | v26.7.0, v24.21.0 | 1.1 | `--allow-openssl-store` |
| Network gate | v25.0.0 (**not v24**) | 1.1 | `--allow-net` |
| FFI / VFS mount gate | v26.1.0 / v26.9.0 (**not v24**) | 1.1 | `--allow-ffi` / `--allow-fs-vfs` |
| Env var filtering | v27.0.0 (**not v24/v26**) | 1.1 | `--allow-env` |

> **Experimental API.** Before relying on these details, run the
> `node-experimental-check` skill's probe (or `node --version` plus a
> feature-detect one-liner) and check the docs for *the installed
> version*: `https://nodejs.org/docs/<version>/api/<module>.html`.
> If the installed version disagrees with this skill, the installed
> version wins.

A seat belt, not a sandbox: it does not stop malicious code.

## Read-only ./data plus network

```sh
node --permission --allow-fs-read=./data --allow-net untrusted.mjs
```
The entrypoint is implicitly readable (v24.2.0+); its imports and `node_modules` are not. **There is no per-host network grant.** `--allow-net=api.example.com` is accepted and grants *all* network. For one host, use an OS firewall, a network namespace, or a container. On v24, `--permission` does not gate the network at all.

## Errors

```js
// { code: 'ERR_ACCESS_DENIED', permission: 'FileSystemRead', resource: '../x' }  (path as passed)
// permission: FileSystemWrite | ChildProcess | WorkerThreads | WASI | Inspector | Net | FFI | OpenSSLStore
```
Net errors arrive async (`connect ERR_ACCESS_DENIED`, `resource: ''`). `fetch` rejects with `TypeError` and `err.cause.code === 'ERR_ACCESS_DENIED'`. Addons throw `ERR_DLOPEN_DISABLED`. VFS mount throws `ERR_INVALID_STATE`.

## Drop after init (v24.20+)

```js
const cfg = fs.readFileSync('conf/app.json');        // started with --allow-fs-read=./conf
process.permission.drop('fs.read', './conf');         // must match the grant exactly
process.permission.drop('child');                     // whole scope; irreversible
```

## Discover needs: `--permission-audit`

```js
dc.channel('node:permission-model:fs').subscribe(({ permission, resource }) => log(permission, resource));
```
Run with `--permission-audit`: nothing throws.

## Pitfalls

- `has()` and `drop()` with an unknown scope return `false` / do nothing, with no error. On v24, `has('net')` is `false` even though the network is open.
- Dropping a file inside a granted directory silently does nothing.
- `new Worker(f, { execArgv: [] })` runs **without** the permission model.
- `--allow-child-process` can escape the model; children inherit flags via `NODE_OPTIONS`.
- `--allow-openssl-store` and `--allow-ffi` access is not checked against `fs.read`.
- Don't pass both `--permission` and `--permission-audit`: v26.13.0 audits only.

## Don't

- `--experimental-permission` (bad option on v24+); `vm`/`vm2` as a sandbox; comma-separated `--allow-fs-*` paths; hand-scrubbing `process.env` on v27+ (use `--allow-env`).

## Reference

- [rules/scopes.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-permissions/rules/scopes.md): each flag, what it gates, path/wildcard rules, errors, warnings, versions.
- [rules/runtime-api.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-permissions/rules/runtime-api.md): `has()`/`drop()` semantics and audit channels/messages.
- [rules/propagation-and-config.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-permissions/rules/propagation-and-config.md): child/worker inheritance, `--allow-env` details, config file, `npx`.
