Security and permissions
Ende is secure by default. Unless you specifically enable it, a program run with Ende has no access to sensitive APIs, such as file system access, network connectivity, or environment access. You must explicitly grant access to these resources with command line flags or with a runtime permission prompt. This is a major difference from Node, where dependencies are automatically granted full access to all system I/O, potentially introducing hidden vulnerabilities into your project.
Before using Ende to run completely untrusted code, read the section on executing untrusted code below.
Key principles
Before diving into the specifics of permissions, it's important to understand the key principles of Ende's security model:
- No access to I/O by default: Code executing in an Ende runtime has no access to read or write arbitrary files on the file system, to make network requests or open network listeners, to access environment variables, or to spawn subprocesses.
- No limits on the execution of code at the same privilege level: Ende
allows the execution of any code (JS/TS/Wasm) via multiple means, including
eval,new Function, dynamic imports and web workers at the same privilege level with little restriction as to where the code originates (network, JSR, etc). - Multiple invocations of the same application can share data: Ende provides a mechanism for multiple invocations of the same application to share data, through built in caching and storage APIs. Different applications can not see each other's data.
- All code executing on the same thread shares the same privilege level: All code executing on the same thread shares the same privilege level. It is not possible for different modules to have different privilege levels within the same thread.
- Code that needs different permissions runs in its own worker: To give part
of a program different permissions, Ende runs it on a separate thread with its
own permission set, and calls into it through a proxy (async unless the rule
sets
sync) (Ende 2026.12.01+). A dependency named inisolateinende.jsongets at most what the app has, and less if its rule says so. An extension gets exactly what itsende.jsonentry and its manifest both allow, which may be more or less than the app has. - Code can not escalate its privileges without user consent: Code executing
in an Ende runtime can not escalate its privileges without the user agreeing
explicitly to an escalation via interactive prompt or a invocation time flag.
An extension's grant in
ende.jsonis such an agreement (Ende 2026.12.01+): it is pinned in the lockfile, and a changed grant is refused untilende installapproves it. Two things skip that check:--no-lockruns the changed grant with a warning, and afterende.lockis deleted the next run records the grant again with a notice. - The initial static module graph can import modules without restrictions:
All modules that are imported in the initial static module graph (local files,
jsr packages, and remote URLs) are loaded by the runtime without consulting
the permission system. No
--allow-readis required to load local files in the project folder, and no--allow-netis required to fetch remote modules. The static graph includes staticimportstatements andimport()calls whose specifier is a string literal: anything that can be resolved without running code. This exemption applies only to loading. Once code runs, anything it does still goes through the permission system, andimport()calls with non-literal specifiers (e.g.import(someVariable)) are checked against--allow-read/--allow-importat runtime. Extensions and sandboxed dependencies are exceptions (Ende 2026.12.01+): an extension's static graph may read local files only from its own folder, and a sandboxed dependency needs its own read permission for local files outside its folder. The app's own graph has limits too (Ende NEXT_RELEASE+): a local file outside the project folder, code or data, loads only with--allow-readfor its path, and a--deny-read=<path>rule refuses every import of that path. See the Permissions reference.
These key principles are designed to provide an environment where a user can execute code with minimal risk of harm to the host machine or network. The security model is designed to be simple to understand and to provide a clear separation of concerns between the runtime and the code executing within it. The security model is enforced by the Ende runtime, and is not dependent on the underlying operating system.
Permissions
Ende is sandboxed by default: code cannot touch the file system, network,
environment, or run subprocesses unless you allow it. Permissions are not all or
nothing. You grant them with --allow-* flags, and most can be scoped to
specific resources, so a program gets exactly the access it needs and no more.
Run a program with no flags and a sensitive operation is refused. On a terminal Ende asks first (see below); without one, the operation fails:
ende run main.ts < /dev/null
# error: Uncaught (in promise) NotCapable: Requires net access to "example.com:443", run again with the --allow-net flag
Grant access scoped to just the host the program should reach:
ende run --allow-net=example.com main.ts
The same scoping works for the other permissions: --allow-read=./data limits
reads to one directory, --allow-env=API_KEY to a single variable, and so on. A
bare --allow-net with no value grants the whole category, which is broader
than most programs need.
When an operation is refused (because the permission was not granted or was
explicitly denied), Ende throws a NotCapable error. You can catch it like any
other error if you want to handle missing permissions gracefully:
try {
await Ende.readTextFile("/etc/hosts");
} catch (err) {
if (err instanceof Ende.errors.NotCapable) {
console.error("Missing read permission, run again with --allow-read");
}
}
Error messages don't widen access either. An uncaught error shows a line of
another file that a source map names only if the program could read that file
(Ende NEXT_RELEASE+). See
Source lines in error messages.
Neither do file system events: Ende.watchFs leaves out paths the program may
not read (Ende NEXT_RELEASE+). See
Watching the file system.
When stdin and stderr are both terminals and you have not passed a flag, Ende pauses and asks instead of failing, so you can grant access interactively as it is requested:
┏ Warning Ende requests net access to "example.com:443".
┠─ Requested by `fetch()` API.
┠─ To see a stack trace for this prompt, set the ENDE_TRACE_PERMISSIONS environmental variable.
┠─ Learn more at: https://docs.ende.sh/go/--allow-net
┠─ Run again with --allow-net to bypass this prompt.
┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all net permissions) >
Answer y to allow this request, n to deny it, or A to allow every request
of this kind. Once you answer, the prompt is replaced by one line, such as
Denied net access to "example.com:443". Ctrl-D, an empty answer, or an answer
longer than one character (such as yes) denies the request without that line.
Ende 2026.12.01
The prompt starts with the word Warning rather than an emoji. Ctrl-D now
prints the Denied … line too. With TERM=dumb, where the terminal can't
redraw the prompt, the prompt stays and the answer is printed below it.
Stdout doesn't matter, so ende run main.ts > out.txt still prompts. When stdin
or stderr isn't a terminal, or with --no-prompt or ENDE_NO_PROMPT, the
request is denied without asking.
--deny-* flags override their --allow-* counterparts, so you can grant a
broad category and carve out the sensitive parts:
--allow-read --deny-read=/etc reads anything except /etc. At the other
extreme, -A (--allow-all) grants everything and turns the sandbox off
entirely, giving the same access as running code in Node, so reach for it
sparingly.
-A covers only the app's own code (Ende 2026.12.01+). Sandboxed
dependencies and extensions keep the permissions ende.json gives them, and
when extensions are declared, the app still can't write the config file, the
lockfile, the vendor folder or a local extension's folder. That holds only
inside the Ende process: a subprocess (--allow-run) or native code
(--allow-ffi), both part of -A, can still change them. The next run refuses
a changed grant or changed code for an extension the lockfile already records,
unless the lockfile was changed to match. Other edits aren't caught: a newly
declared extension is recorded on its first run, and the app's own permissions
in ende.json aren't pinned.
See the Permissions reference for every
permission and its flags, and
permissions in ende.json for
declaring them in your configuration file.
Permissions that bypass the sandbox
A few permissions grant access to things Ende cannot sandbox, so granting them is effectively granting full access:
--allow-runlets the program spawn subprocesses. A subprocess runs as a separate program with its own permissions, not the restricted set you granted the Ende process, so whatever it does happens outside the sandbox. This is why--allow-run=endeis especially dangerous: a script that can start a newendeprocess can start it with--allow-all, inheriting none of the parent's limits and escaping the sandbox entirely. Grant--allow-runonly for specific, trusted executables where you can (--allow-run=git), and avoid giving a sandboxed program the ability to launchendeor a shell.--allow-ffiloads native libraries through FFI or Node-API addons. Ende enforces permissions in the JavaScript layer, but a native library runs as compiled machine code in the same process and can issue system calls directly. Once loaded, it can read files, open sockets, or do anything the operating system lets the process do, regardless of which--allow-*flags you passed.
Be careful when combining --allow-write with --allow-run. Write access to a
directory that contains an allowed executable (or to the executable itself) lets
a program overwrite that binary, so the next subprocess it spawns runs
attacker-controlled code with the host's privileges. Avoid granting write access
to directories that hold binaries you allow with --allow-run.
Treat both as equivalent to --allow-all when deciding whether to trust the
code you are running.
Adjusting permissions at runtime
A program can inspect and tighten its own permissions through the
Ende.permissions API.
Ende.permissions.query
reports whether a permission is granted,
Ende.permissions.request
prompts for one on demand, and
Ende.permissions.revoke
downgrades a granted permission back to the prompt state:
// Read a config file at startup, then give up read access.
const config = JSON.parse(await Ende.readTextFile("./config.json"));
await Ende.permissions.revoke({ name: "read" });
// Later reads now have to prompt again, and fail outright under --no-prompt.
Dropping permissions you no longer need after startup is a simple way to shrink the attack surface available to the rest of your code, including your dependencies.
Revoking one path, as in Ende.permissions.revoke({ name: "read", path }), only
removes granted entries that cover that path. Under a blanket --allow-read
there is no such entry, so nothing changes and the returned state is still
"granted". Under a list grant such as --allow-read=./data, revoking
./data/cache removes the whole ./data entry, which is wider than the path
you named. Check the state the call returns. To give up a path for good, run
with --deny-read=<path>, or revoke the whole permission ({ name: "read" })
and request again only what you still need.
A revoke also reaches dependencies sandboxed with
isolate, even ones already
running, because a sandbox never has more than the app (Ende 2026.12.01+).
After Ende.permissions.revoke({ name: "read" }), a sandbox granted read
fails too:
NotCapable: ./vendor/pkg/: Requires read access to "secret.txt", which the app itself isn't allowed. isolate["./vendor/pkg/"] can only narrow the app's permissions; run again with the --allow-read flag
Extensions have their own permissions, so the app's revoke doesn't change them.
Evaluation of code
Ende sets no limits on the execution of code at the same privilege level. This
means that code executing in an Ende runtime can use eval, new Function, or
even dynamic import or web workers to execute arbitrary code with the same
privilege level as the code that called eval, new Function, or the dynamic
import or web worker.
This code can be hosted on the network, be in a local file (if read permissions
are granted), or be stored as plain text in a string inside of the code that
called eval, new Function, or the dynamic import or web worker.
Executing untrusted code
While Ende provides security features that are designed to protect the host machine and network from harm, untrusted code is still scary. When executing untrusted code, it is important to have more than one layer of defense. Some suggestions for executing untrusted code are outlined below, and we recommend using all of these when executing arbitrary untrusted code:
- Run
endewith limited permissions and determine upfront what code actually needs to run (and prevent more code being loaded using--frozenlockfile and--cached-only). - Give an untrusted dependency only the permissions it needs by naming it in
isolateinende.json. It runs in its own worker with what its rule grants, never more than the app, and its grant is pinned in the lockfile (Ende 2026.12.01+). As for the app, granting itrunorffilets it bypass the sandbox. - Load plugins as extensions, each in its
own worker with the permissions you grant it in
ende.json, and with its code and grant pinned in the lockfile (Ende 2026.12.01+). Granting itrun,ffior unscopedwritelets it bypass the sandbox. - Isolate the untrusted part in a Web Worker with a reduced permission set, so it cannot inherit everything the main program was granted.
- Use OS provided sandboxing mechanisms like
chroot,cgroups,seccomp, etc. - Use a sandboxed environment like a VM or MicroVM (gVisor, Firecracker, etc).
Keeping dependencies safe
The permission sandbox controls what code can do at runtime, but it does not tell you whether your dependencies are trustworthy. See supply chain management for keeping dependencies safe over time.
Permission broker
Advanced use only
Using a permission broker changes Ende's decision authority: CLI flags and
prompts no longer apply. Ensure your broker process is resilient, audited, and
available before enabling ENDE_PERMISSION_BROKER_PATH.
For centralized and policy-driven permission decisions, Ende can delegate all
permission checks to an external broker process. Enable this by setting the
ENDE_PERMISSION_BROKER_PATH environment variable to a path that Ende will use
to connect to the broker:
- On Unix-like systems: a Unix domain socket path (for example,
/tmp/ende-perm.sock). - On Windows: a named pipe (for example,
\\.\pipe\ende-permission-broker).
When a permission broker is active:
- All
--allow-*and--deny-*flags are ignored. - Interactive permission prompts are not shown (equivalent to non-interactive mode).
- Every permission check is sent to the broker; the broker must reply with a decision for each request.
- In a sandboxed dependency or an extension, the broker can only narrow: a
"deny"applies, but an"allow"falls back to that code's own permissions, so a broker can't widen them (Ende 2026.12.01+).
If anything goes wrong during brokering (for example: Ende cannot connect to the socket/pipe, messages are malformed, arrive out of order, IDs do not match, or the connection closes unexpectedly), Ende immediately terminates the process to preserve integrity and prevent permission escalation.
The request/response message shapes are versioned and defined by JSON Schemas:
- Request schema: permission-broker-request.v1.json
- Response schema: permission-broker-response.v1.json
Each request contains a version (v), the Ende process ID (pid), a unique
monotonic request id, a timestamp (datetime, RFC 3339), the permission
name, and an optional value depending on permission type. The response must
echo the id and include a result of either "allow" or "deny". When
denied, a human-readable reason may be included.
Example message flow:
-> req {"v":1,"pid":10234,"id":1,"datetime":"2025-01-01T00:00:00.000Z","permission":"read","value":"./run/permission_broker/scratch.txt"}
<- res {"id":1,"result":"allow"}
-> req {"v":1,"pid":10234,"id":2,"datetime":"2025-01-01T00:00:01.000Z","permission":"read","value":"./run/permission_broker/scratch.txt"}
<- res {"id":2,"result":"allow"}
-> req {"v":1,"pid":10234,"id":3,"datetime":"2025-01-01T00:00:02.000Z","permission":"read","value":"./run/permission_broker/log.txt"}
<- res {"id":3,"result":"allow"}
-> req {"v":1,"pid":10234,"id":4,"datetime":"2025-01-01T00:00:03.000Z","permission":"write","value":"./run/permission_broker/log.txt"}
<- res {"id":4,"result":"allow"}
-> req {"v":1,"pid":10234,"id":5,"datetime":"2025-01-01T00:00:04.000Z","permission":"env","value":null}
<- res {"id":5,"result":"deny","reason":"Environment access is denied."}