refern.
Extensions

Security model

How refern isolates the three extension tiers: validated theme data, sandboxed app frames with host-mediated network, and fuel-limited WebAssembly decoders with no imports.

An extension can only do what refern lets it ask for, and each tier can ask for less than the one above it. No extension can run a program, read a file by path, or reach the network or this computer directly.

TierRuns asCanCannot
1. ThemeJSON data, checkedSet color tokens and fontsRun code, load a URL, add CSS
2. App<iframe sandbox="allow-scripts">, opaque originCall the refern API within its granted scopesTouch refern's page, IPC, disk, storage or network directly
3. FormatWebAssembly in Wasmtime, no importsTurn file bytes into preview pixelsCall anything; outlive its fuel or memory

Before anything runs

  • The manifest is checked by the same rules in refern (Rust), the CLI and the registry: ids, versions, every package path (no .., drive, backslash, link or URL), network hosts (no IP addresses, localhost, .local, .internal, ports or paths), and when expressions (a closed list of atoms, never evaluated as code).
  • The user decides. refern shows the scopes, network hosts and managed tools an extension asks for before it installs, and the user can turn it off at any time on the Extensions page. A turned-off extension's frames get no more answers at once.
  • The registry kill list can block an extension id, a version or a package SHA-256. Packages are deterministic ZIP files, so a SHA-256 names exactly one build. refern reads the list with the directory index at start and every 24 hours, keeps its last copy when the index cannot be reached, and turns a blocked extension off at that read. A blocked version cannot be turned on again. So a block reaches a running app within 24 hours.
  • Directory extensions pass the same checks for every version (see publishing), and refern downloads them only from its own host and installs a package only when its SHA-256 matches the index.
  • A developer folder (Load Developer Folder...) is not checked by the refern directory, and refern says so in the install confirm. It still serves only the manifest and the files the manifest names (and their top-level folders), never src/, .env or node_modules/, and never through a link that leaves the folder.

Tier 1: themes are data

A theme sets known color tokens to "R G B" triplets (three integers from 0 to 255) and may name up to two font files inside its package. Any other value is refused, so url(...), ;, { and every other piece of CSS can never reach a style. Unknown tokens are refused. Text must reach WCAG AA contrast (4.5:1) on the background and surfaces. Fonts load from the package through refern's own scheme. A theme cannot call the app at all.

Tier 2: app extensions run in a sandboxed frame

Each page of an app extension runs in <iframe sandbox="allow-scripts">. Without allow-same-origin the frame has an opaque origin: it cannot read refern's page, cookies or storage, use refern's IPC, open popups, submit forms or navigate the app. refern never adds to this sandbox.

Files. The frame loads from the refern-plugin: scheme. Every URL holds a secret nonce made at each launch, so a page that does not know it cannot load an extension's files. refern answers only for an installed, enabled, unblocked extension, only for files in its package, and refuses requests from remote pages. Each file is sent with this content security policy (<own> is the extension's own URL prefix):

 default-src 'none'; script-src <own> 'wasm-unsafe-eval' blob:; style-src <own> 'unsafe-inline'; img-src <own> blob: data:; font-src <own> data:; media-src <own> blob:; connect-src <own>; frame-src 'none'; object-src 'none'; form-action 'none'; base-uri 'none'; frame-ancestors <the app> 

So a page loads only its own scripts, styles, fonts and images: no CDN, no other extension's files, no network connection, no inline <script>. The app page also enforces a frame-src content security policy that allows only refern-plugin: and refern's own bookmark player pages, so an extension frame cannot navigate itself to an external website to bypass permissions.network.

Calls. The SDK talks to refern with postMessage. refern knows which extension a message comes from by the frame window that sent it, never by a field in the message: it maps each frame to its extension before the page's script runs and forgets it when the frame closes. A frame that navigates to another page loses its connection. Each call is checked against the scopes the user grants now, so a scope or an extension the user turns off stops working at once. Limits: 16 calls waiting per frame, 2 MiB of parameters, 3 toasts every 5 seconds. Dialogs, links, the folder picker and running another extension's command need a recent click or key press, so a page cannot open them on its own.

Library data. Calls run the Local API's operations as the extension, with the same scope checks, undo history and change list as a token. Answers never hold a path on this disk: every path is null, thumbnails and viewer files arrive as bytes, and an export folder is an opaque token. NSFW items are hidden unless the manifest sets includeNsfw and the user agrees. An extension cannot import local files.

Network. The CSP allows no connection, so the only way out is refern.net.fetch, which refern performs:

  • https: on the default port, to a host the manifest lists (exactly, or its subdomains for *.example.com), checked again at every redirect (at most 5);
  • through a resolver that refuses loopback, private (RFC 1918), link-local, CGNAT and address forms that embed them, so a public name that resolves to this computer or the local network (DNS rebinding) connects nowhere; no system proxy;
  • without cookies, Origin, Referer or connection headers set by the page; 2 MiB to send, 32 MiB to read, 30 seconds;
  • with secrets filled in by refern ({{secret:<key>}} in a header), so an API key need not enter the frame.

Storage and secrets. Each extension has its own key-value store (4 MiB of JSON) and settings file in refern's data folder. Secret settings live in the operating system's credential store under refern.plugin.<id>; an extension can read only the secret keys its own manifest declares.

Tier 3: format decoders run in Wasmtime

A decoder is a WebAssembly module that turns a file's bytes into RGBA pixels for a thumbnail.

  • No imports at all. refern refuses a module that imports anything: no WASI, no file system, no network, no clock, no host functions. It gets bytes and returns pixels.
  • A fresh instance per file, with 500,000,000 instructions of fuel and 128 MiB of memory (and at most 10,000 table elements). A module that loops or allocates too much traps instead of hanging or exhausting the app.
  • Bounded input and output. Input is at most 64 MiB (maxInputBytes); a cloud placeholder file is never read (that would download it). Output is checked: each edge 1 to 4096, exactly w * h * 4 bytes, inside the module's memory.
  • A circuit breaker. After 5 traps in one preview pass, refern skips the decoder until the next pass. A trap or a corrupt file never marks a file as permanently failed.
  • A viewer page of a format extension is a Tier 2 frame and gets the open file only as bytes (refern.viewer.readCurrentFile()), never its path.

No extension runs programs

There is no exec(), shell or process API for extensions.

  • Managed ExifTool is host-owned. An extension with managedTools: ["exiftool"] names items and typed fields (keywords, rating, description, and so on). refern reads the values from the library, builds every ExifTool argument itself, runs its own ExifTool install, and replaces each file safely. The extension never passes a flag or sees a path. Where ExifTool comes from is a setting on the Extensions page only.
  • External Tools (Settings > External Tools) are programs the user picks to open files with. They live in a file on this device that no extension and no Local API token can read or write. refern runs them without a shell, one argument per file path. An extension cannot list, add or run them.

Reporting a problem

If you find a way around any of this, contact refern through refern.app before you publish it, and include the extension, the steps and the refern version.

SDK and CLI reference

Copy-pasteable reference for @refern/plugin-sdk, its UI controls, the format decoder ABI, @refern/sdk (the Local API client) and @refern/cli.

Publish to the extension directory

List a refern extension in the directory at refern.app/extensions: requirements, listing images, refern-cli plugin submit, the checks, how updates reach users, and how blocks and removals work.

On this page

Before anything runsTier 1: themes are dataTier 2: app extensions run in a sandboxed frameTier 3: format decoders run in WasmtimeNo extension runs programsReporting a problem