blob: cfc50711f3fe8b3f8804b8d91de7b01ee9e5af85 [file] [view]
# Verified Components
This directory contains an efficient runtime environment for Fuchsia
components that has been verified to have certain correctness properties
against a formal model of the aarch64 Instruction Set Architecture (ISA) and of
the Zircon system interface.
These programs are more efficient because they do not require many of the
normal abstractions and security mitigations. For example, some production
programs can run in a single page of writable memory because we can prove
precise bounds on their memory usage. The programs do not require a shadow
call stack because we prove both backward- and forward-edge control-flow
integrity, including that return addresses are never overwritten and indirect
calls target only verified static receivers. The programs do not require
separate processes or address spaces for isolation because we prove that all
memory accesses are in-bounds, that the programs never panic, and that the
programs do not interfere with each other.
## Runtime
These programs are written in Rust and execute without a dynamic loader and
without a C runtime library. Instead, the VX runtime bootstraps from the
initial machine state provided by Zircon for a process into an operational
Fuchsia component. These components integrate into the Fuchsia system in the
same way as other components. They use and provide component framework
capabilities using the same FIDL interfaces as any other component.
The runtime is structured similarly to other Fuchsia runtimes. The `vx_zx`
crate provides ergonomic Rust wrappers for Zircon concepts, such as handles and
channels. From there, the runtime builds up the FIDL wire format, an async
reactor, FIDL bindings, a VFS, and a component runtime in a similar structure
to normal Rust programs.
The runtime has a backend for the FIDL compiler, `fidlgen_curry`, which
produces correctness proofs along with its FIDL bindings. Its FIDL-IR-to-schema
lowering and layout checks are proved sound against the FIDL wire format. The
code generator itself remains untrusted: alongside the generated Rust bindings,
it emits Lean proofs that VX checks directly against the compiled aarch64
object code linked into the final binary.
## Verification
Verification begins with a model of the operational semantics of the aarch64
ISA and the Zircon system interface, including the initial machine state for a
Zircon process. From this starting point, VX proves end-to-end properties of
the ELF binaries loaded into this initial state. The Rust source code and the
Rust compiler are untrusted. Although not necessary for security, unsafe Rust
code is encapsulated in low-level crates, making the source code easier to
understand and letting the Rust compiler, as well as developers and agents,
catch mistakes earlier in the engineering pipeline.
Many functions in VX source code are marked `#[curry::verified]`, which
instructs the compiler not to inline the function. These functions have an
associated proof that they provide certain semantics. VX uses these proofs to
prove that their callers provide certain semantics. In this way, VX builds up
end-to-end proofs about the properties of entire Fuchsia components starting
from the initial state of a Zircon process.
The verification is based on a specification of the aarch64 ISA from
[AlphaProof Code](https://deepmind.google/blog/introducing-alphaproof-code/)
and a specification of the Zircon system interface that we have created
ourselves. The Zircon specification has been cross-checked against Zircon's
kernel source, `zx.fidl.json`, real arm64 `libzircon.so` binaries, and live
emulator runs, and additional work is ongoing to improve the Zircon
specification.
## Properties
We have proved the following properties of Fuchsia components using this approach:
### Memory safety and crash-freedom
- *No faults or traps:* Every reachable execution is proved never to fault,
dereference unmapped/out-of-bounds memory, overflow the stack, hit a
panic/trap, or issue raw `svc` instructions outside the vDSO.
- *Bounded memory and zero dynamic linker:* Components run with zero heap
allocations and a statically bounded stack within the 4 KiB initial stack.
### Zircon handle linearity and zero handle leaks
- *Valid handle usage:* Handles are only used with required Zircon rights and
object types, and cannot be forged or double-closed.
- *Zero leaks on exit:* Every clean process exit leaves an empty handle table.
- *Bounded handle usage in long-running servers:* The number of live handles
stays strictly bounded by the server's configured slot capacity regardless
of client churn.
### Strict FIDL wire conformance and fail-closed parsing
- *Exact wire validation:* Generated `fidlgen_curry` validators are proved to
accept an incoming message if and only if it strictly obeys the FIDL wire
specification—transactional headers, UTF-8 validity, zero-padding bytes,
vector/string bounds, table/union envelopes, handle types/rights, and strict
enum/bits discriminants.
- *Protocol state-machine conformance:* Every outgoing response or event is
proved to be a valid FIDL message matching the pending request's `txid` and
protocol-specific rules, while malformed client messages cleanly close that
client's channel with no reply.
### Multi-client isolation (non-interference) and DoS resistance
- *Client-to-client non-interference:* Proved relationally across two
executions that one client's traffic, including arbitrary malformed or
adversarial messages, cannot leak data to or alter the observable replies
seen by any other client sharing the same single-threaded executor.
- *Bounded responsiveness & O(1) cleanup:* Once `zx_port_wait` delivers a
packet for an active slot, the executor reaches its receiver in a small
constant number of instructions, and handling or tearing down a malformed
client takes strictly bounded work, preventing one bad client from hanging
or starving others.
These isolation and resource-bound theorems let us safely pack multiple small
components into a single process to reduce per-process memory overhead,
including from Zircon state associated with the process.
### Component-specific security & functional invariants
We can prove component-specific properties, including security and functional
invariants. For `kernel-args-forwarder`, we prove:
- *Allowlist confinement:* Only queries the exact allowlisted boot arguments
and only inserts `"fuchsia."`-prefixed keys into the exported dictionary.
- *Sanitization:* Never leaks raw `kernel.serial` UART configuration
strings; `"fuchsia.kernel.serial"` is strictly RFC-0120-persisted as a
boolean.
- *Post-init immutability & router safety:* Once serving starts, zero
further `fuchsia.boot/Arguments` or mutating `Capabilities` calls can ever
occur, and every `DictionaryRouter.Route` response serves a duplicate of
the immutable boot dictionary.