R367 · Agent principles and patterns › Formal constraints on agent actions

Rights from main: capability types in a systems language, and the one that collapses them

Read the original

sandboxingcapabilitiescompilersupply-chainagent-governancesecurity

Source: Vx v0.0.6 (github.com/vx-lang/Vx), Apache-2.0 with LLVM Exceptions, compiler in Rust on LLVM/MLIR 22; the book chapters Files, input and time and Unsafe and FFI; and securl, a rewrite of curl in Vx (github.com/vx-lang/securl) used as the worked example.

Why it matters here: every team running model-written code has converged on the same question — what authority does this code hold, and who granted it. Most answers are runtime: a container, a microVM, an interpreter that implements no syscall. This one is a compile-time answer, and it is worth reading even if you will never write a line of the language, because the shape of its lattice (and the place where the lattice collapses) is the design you would have to reinvent.

The mechanism

A program's authority enters at exactly one point. A main written fn main(root : Root) -> i32 receives the program's rights in root, and passes references onward to the code that needs them: &root.files to open a file, a network right to connect or bind, Stdout or Stderr to print, &root.processes to start a program. A function that is handed none of these cannot perform the corresponding operation, and there is no ambient fallback to reach for.

Unforgeability is not a special rule in the type system. A capability is an ordinary value whose constructor is module-private: only std::fs can make a Files, so code outside it cannot manufacture one. The guarantee therefore reduces to a property the compiler already enforces, which is a good sign — the fewer bespoke mechanisms in a security story, the fewer places it can be wrong.

The lattice has levels, and this is the part worth stealing. Three grades of filesystem authority:

RightWhat it permits
&Filesopen any path
Folderread the files of one folder; an absolute path, a .. segment or a symlink leading out fails with FileError::NotInFolder
PendingFileopen one path, in one mode, once, later

The documentation's own example is the one that lands for anyone building model infrastructure: a model server hands the weight-loading code a Folder and hands the request-reading code no right at all. That is the decomposition most systems never make, because at runtime the process holds one identity and every component inherits it.

Two classification calls in the design are worth noting because they are the ones teams usually get wrong. Environment variables are a right, on the stated grounds that they can hold secrets — so reading them is treated like opening a file. Command-line arguments are not: they are data the caller already chose. And DNS resolution requires the network right, because the lookup can send the name to the network — exactly the kind of covert channel that a naive capability split leaves open.

The escape hatches, which the project documents itself

A capability system is only as strong as its weakest grant, and this one names its own:

The process right is the top of the lattice and collapses it. From the documentation: the compiler does not check the program that run starts, that program can open files, use the network and read environment variables, so the process right gives every other right in practice, and should go only to code trusted with all of them. Any audit of such a program reduces, at that point, to a single question: who got &Processes. This is not a flaw in the design so much as the honest edge of what a compile-time model can promise — but a reader of the announcement alone would not know it exists.

Trusted code bypasses the model by construction. The file API carries raw variants for code receiving a path from C; they require unsafe and they require no file right. So "cannot be forged" holds precisely for code containing no unsafe blocks, no unverified compiler-IR blocks, no extern functions and no extern/unsafe impls — which is stated plainly in the reference, and is the correct scope.

What turns that into a supply-chain control is the flag, not the type. Compiling a package with --no-trusted-code makes every use of trusted code inside it an error, and the consumer passes the flag — so a new version of a dependency cannot quietly introduce trusted code without failing the build. An audit mode lists every trusted use with file, line and column in a stable order, so two versions' audits can be diffed. That combination — a machine-checkable "this dependency contains no privileged operations", asserted by the person who depends on it — is a stronger property than the capability types themselves, and it is the part most directly portable to other ecosystems.

The evidence: a curl rewrite

The claim is demonstrated rather than asserted, which is rarer than it should be. securl reimplements curl for HTTP/1.1, HTTP/2 and HTTPS, with TLS from OpenSSL as a submodule and everything else in the language. The protocol code, the tool and its file access all compile with no trusted code, and the audit reports 135 trusted items remaining, 129 of them OpenSSL — a number that makes the residual trusted surface countable rather than rhetorical. Only main holds network, file, environment and terminal rights; the parsers get none.

SuiteResult
curl's own HTTP tests599 / 762
restricted to options securl implements539 / 569
TLS, proxy and limit tests290 / 290
HTTP/2 tests32 / 32
unit tests13 / 13
libFuzzer across nine parsersno crash in 50M inputs

It also types two of curl's historical bug classes out of existence: a connection is reused only when its whole connection key matches, and a credential travels only where its type says it may. Caveats stated on the page: Linux x86-64 only, no HTTP/2 connection reuse, no h2c upgrade, no HTTP/2 through a proxy, no HTTP/3, and a timing field that reports no DNS time because resolution happens inside connect.

What is claimed but not visible

Three things a reader should not take on trust from the announcement:

Nothing published gives a cost: no compile-time, binary-size or runtime overhead for the checking, no comparison against an OS-level sandbox, and no threat model for the compiler itself. The project is nine weeks old and at v0.0.6, with its package manager still unbuilt — so this is a research compiler with a good idea in it, not a dependency.

A checklist for anyone designing the same thing

  1. Is there exactly one entry point for authority? If any component can acquire a right without being handed one, the rest of the design is decoration.

  2. Does the lattice have at least three levels? All-or-nothing file access is the failure this is meant to fix; a scoped-folder and a single-use grant are what make it usable.

  3. Which single grant collapses everything? Every such system has one — process spawn here, a host callback in an interpreter sandbox, a broad mount in a container. Name it in your docs, as this project does, and audit for it specifically.

  4. What is the residual trusted surface, as a number? "129 of 135 trusted items are the TLS library" is a reviewable claim. "Memory-safe" is not.

  5. Can a consumer assert the absence of privileged code in a dependency, mechanically? This is the property that survives contact with a supply chain, and it needs a flag the depender sets, not a promise the dependency makes.

  6. Is the thing you classified as data actually data? Arguments versus environment variables, and name resolution counting as network access, are the two calls to make deliberately.

Part of the Research notes on nowucca.com. Figures and claims are the source's own unless the summary says otherwise.