liveBook · Manning

Capability

As explained in Server-Side WebAssembly

A capability is an explicit, constrained authority that permits code to access a particular resource or operation.

A capability is a narrowly granted permission that lets a WebAssembly program perform a specific interaction with its host system. A Wasm module remains inside a memory-safe sandbox and cannot use native operating-system interfaces unless the runtime supplies the relevant capability. Granting standard output enables printing; withholding network access prevents unnecessary communication. section 1.2.4 section 4.1

Capabilities shape both security and integration:

  • Treat each permission as an explicit boundary between the guest and native operating-system resources. section 1.2.4
  • Use WASI to expose capabilities such as standard output, environment variables, or files to a Wasm guest. section 4.1
  • Disable capabilities that an application does not need; the greeting component disables HTTP while retaining standard output. section 4.1

Granting standard output with WASI

A JavaScript guest changes greet from returning a string to calling console.log, then jco componentizes it with `--disable http`. A Rust Wasmtime host adds WASI to its linker, inherits stdout with `WasiCtxBuilder::new().inherit_stdout()`, and calls the component. The guest can print "Hello, World!" but receives no network capability.

Figure 1.6 A native (traditional) application security model versus Wasm’s capability-based security model
A screenshot of a computer

AI-generated content may be incorrect.

Compare unrestricted native operating-system access with Wasm’s capability-based model, where host permissions are granted selectively. section 1.2.4

How Server-Side WebAssembly covers it

How deep it goes
Explains sandbox boundaries and demonstrates capability selection through WASI configuration, stopping short of a broader permission model.
Examples
Uses a greeting component that prints through WASI while disabling HTTP access.
What it assumes
Assumes familiarity with a Wasm component, WIT definitions, componentization, and a host program that instantiates the guest.
What you can do after
Operate/configure Wasmtime and WASI hosts to grant standard output while withholding unused capabilities.
How it connects
Connects WebAssembly with sandboxing, WASI, host runtimes, system calls, standard output, files, and network access.

Also explained in

Compare how 7 books explain capability →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Server-Side WebAssembly. The section links point to the parts of the book it draws on.