Skip to content

Unify capability flags into an explicit allow/deny permission model with trusted config #1255

Closed

Description

@frostney

Summary

Replace GocciaScript's scattered capability flags with one capability model: an immutable engine-level capability set, a --allow-<cap> / --deny-<cap> grammar, config permissions that apply only through an explicit trust step, and a single runner that has a sandbox filesystem mode. It ships as one hard-breaking release (0.14.0). The design is recorded in ADR 0122.

Why

  • Defaults contradict VISION. VISION promises "no ambient file system", yet the default loader can read any file the process can read through import … with { type: "bytes" }, because host-filesystem module loading is on by default.
  • Config grants itself capabilities. A discovered goccia.json, found by walking up from each script, can grant unsafe-ffi, allowed-hosts, allow-node-modules and unsafe-*. Running a cloned project can therefore enable network or native code with no flag.
  • Flags have no shared grammar. Current forms include --allowed-host, --unsafe-ffi, --allow-node-modules[=ceiling], --no-host-filesystem and --fetch-deny-private-ranges. Flag options ignore their value, so --unsafe-ffi=false enables FFI.
  • Several binaries silently ignore capability options. The bundler ignores all runtime options, the REPL ignores --timeout and --no-host-filesystem, and the sandbox runner ignores --allow-node-modules.
  • The embedding API is scattered and partly process-wide. It spans AttachRuntime(hostFileLoading), SetAllowedFetchHosts, the process-global SetFetchRequestPolicy, AllowNodeModules and extension installs.

Current behavior

  • No-flag loader: host files are readable through imports; fetch exists with an empty allowlist; FFI, eval, ShadowRealm and node_modules are off; the Function constructor throws.
  • Per-folder configs grant capabilities implicitly. CI's test run depends on this for FFI, fetch, ShadowRealm, AST, node_modules and the Function constructor.
  • GocciaSandboxRunner is a separate binary with its own CLI. Its entry is a sandbox path that must be seeded separately, and it has --seed/--seed-config, four --diff* flags, --fs-quota-bytes/--fs-node-limit, and --config-only config.

Expected behavior

Model

  • One immutable capability set, owned by the engine and fixed at creation. The CLI, config and embedders only fill it in; nested contexts can only narrow it; there is no process-wide policy.
  • With no flags, nothing reaching outside the process is allowed, except statically importing code and data from inside the project (the nearest goccia.json directory, or the entry's directory).
  • No interactive prompts.

Grammar

  • --allow-<cap>[=scope,…] / --deny-<cap>[=scope,…]. Deny always wins, independent of order. There is no --allow-all and no environment-variable form.

Capabilities

  • read: canonical paths (symlinks resolved), recursive.
  • net: host, host:port, *.domain, IPs and CIDR ranges, private. Private ranges are denied unless named, and every redirect hop is re-checked.
  • ffi: library paths.
  • import: node_modules[=ceiling] and provider hosts such as github.

Settings outside the grammar

  • Limits become --max-memory, --max-fetch-bytes, --max-fs-bytes, --max-fs-nodes, --max-instructions and --max-stack, with unit suffixes. --timeout accepts units.
  • --unsafe-* language escapes stay separate but need trust when they come from config. --compat-*, --experimental-* and --deterministic stay settings.

Config and trust

  • A config's permissions block, its unsafe-* keys and its sandbox inputs are requests, not grants. There are no named sets.
  • --trust <path> stores path + SHA-256 of the normalized effective block in a user-level store outside the repo, after showing the change. --untrust and --list-trusted manage the store.
  • An untrusted or changed config fails startup with the exact fix. -P trusts the declarations for a single run; CI uses it.
  • A binary fails on a capability flag it can't honor and warns when the capability comes from config.

Runner

  • GocciaScriptLoader becomes GocciaRunner and absorbs GocciaSandboxRunner as a sandbox filesystem mode. The mode activates on --copy/--copy-rw, a trusted sandbox config section, or --sandbox.
  • The entry is a host file, auto-copied into the sandbox; --entry covers the rare sandbox-only case.
  • --copy <host>[=<sandbox>] copies read-only. --copy-rw marks an input for write-back, following ADR 0119's rules.
  • --diff[=json|unified] prints the diff; --diff-file=<path> writes it.
  • In sandbox mode only net is allowed, and fs, $ and runScript exist only in this mode.

Surfacing

  • Denials raise a catchable PermissionDenied. Its guest-visible message names the capability and scope, never host paths; the host-side report names the flag or --trust command to use.
  • Audit event kinds are named after capabilities, and every allow and deny is emitted. New config.permissions and capabilities.effective events record trust decisions and the final set.
  • Provider imports: --allow-import=github downloads at resolve time against a required, hash-verified lockfile, with no default hosts.

Scope notes

Delivery. A hard break with no aliases: old flags and keys fail with an error naming their replacement. It ships as one native PR stack that merges atomically as 0.14.0. Layers exist for reviewability only, so an intermediate layer builds and passes its own tests but does not have to preserve behavior. The boundary is mechanism (engine) versus policy (CLI):
0. ADR 0122 (#1256).

  1. Engine capabilities. The immutable set and Pascal API; read enforcement with scopes and the module-graph exemption; net scopes and private ranges; ffi paths; node_modules; the per-engine fetch policy; PermissionDenied; audit events renamed after capabilities, plus capabilities.effective. Engines created without a set get None (deny everything); embedders and tests declare what they need.
  2. CLI surface and defaults. The --allow-* / --deny-* grammar, the hard break, --max-* limits with units, errors for unsupported capabilities, and the user-facing deny-by-default flip.
  3. Config trust. permissions blocks, the path+hash trust store, --trust / --untrust / --list-trusted, -P.
  4. One runner. GocciaScriptLoader becomes GocciaRunner, with sandbox mode (--copy, --copy-rw, --diff, --diff-file, host entry) replacing GocciaSandboxRunner.
  5. Provider imports. feat(modules): add gated remote package imports #1054 rebuilt as --allow-import=github.

Standalone fixes shipped first (security bugs found while designing layer 1, fixed on main independently of this stack):

  • A nested runScript frees the thread's fetch manager: the parent loses --fetch-deny-private-ranges / --fetch-max-response-bytes, and fetch-then-runScript hangs or crashes.
  • --no-host-filesystem is bypassed by --modules=<manifest.js>.

Docs. ADR 0122 supersedes the flag decisions in ADRs 0068, 0097 (event names), 0103 (host filesystem default), 0111, 0119 and 0121. A new docs/permissions.md becomes the single reference. VISION's "no ambient file system" becomes literally true.

Test suite. CI adds -P. The fetch tests declare private for 127.0.0.1, and capability-dependent folders declare their needs.

Related. #1054 (provider imports; stays a draft until layer 8); #1254 (single goccia binary; a follow-up, not part of this stack); ADR 0107 (its out-of-process capabilities section should adopt these names).

Activity

  1. added
    new feature
    runtime
    on Sep 25, 2026
  2. frostney commented on Sep 25, 2026

    @frostney
    OwnerAuthor

    Design recorded in ADR 0122: #1256.

  3. frostney commented on Sep 28, 2026

    @frostney
    OwnerAuthor
  4. added this to the 0.14.0 milestone on Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    new featureruntime

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions