Section 17.1

A memory-safe VM without a static verifier

Question

Can an interpreter §2.13 safely execute untrusted bytecode §2.4 without a Linux-style verifier?

Short answer

Yes, as far as memory safety is concerned, if the interpreter itself checks every memory access and every call to an outside function at the moment the bytecode requests it, and refuses any that is not allowed. A Linux-style verifier instead proves, before the program starts, that no forbidden request can occur. Both keep the bytecode inside the memory it was given, provided the checking code itself is correct. The interpreter pays with a check on every access, and discovers a faulty program only in the middle of a run.

Terms in the question

Full answer

Bytecode is data. It cannot touch memory by itself. Every effect it has on the real machine happens because the interpreter performs that effect on the program’s behalf. The interpreter is therefore a gate that no instruction can avoid. If the interpreter examines each request before acting on it, a forbidden request is caught before it takes effect. This is complete mediation §1.16: every access goes through the check, and no path leads around it.

The checks come in two groups.

  1. Once, when the program is loaded. These checks concern form only. Every instruction has a known operation code §2.8, the number that names its operation. Every register number names an existing register, which is one of the storage slots of the virtual machine. Every jump whose target is written in the instruction lands on the start of an instruction inside the program. Every jump in the eBPF instruction set of RFC 9669 is of this kind. The last instruction is an unconditional jump or the instruction that ends the program, so a run cannot continue past the last instruction.

  2. At every step of the run. Before a load or a store, all bytes of the access must lie inside a region the program was given, and the region must permit the operation. This test is a runtime bounds check §2.27. Before a call, the function number must be on the list of helper functions. Before each instruction, a counter is decreased, and the run stops when the counter is used up, so no loop in the bytecode runs forever.

Each run also starts from known contents. The interpreter first sets the registers and the working memory of the virtual machine to fixed values, so the program cannot read data left behind by an earlier run.

Real systems work this way. By default the interpreter of uBPF §2.16 (userspace eBPF, an open-source virtual machine for eBPF programs) checks every load and store instruction during the run, and a comment in its source code says that the check is needed because uBPF has no verifier. Femto-Containers §21.4, a system for microcontrollers §6.1 (small computers on a single chip) that was published in 2022 and uses the eBPF instruction set, checks each memory access during the run against a list of allowed regions.

The guarantee rests on four conditions.

Checking during the run has costs that a static verifier avoids. Every access pays for its check. A faulty program is discovered only when the faulty instruction is reached, in the middle of a run, so the design must define the result of a stopped run, for example a fixed error value. Stopping the run does not undo changes that the program already made through helper functions. In return the interpreter stays small. A bounds check is a few comparisons, while the main source file of the Linux verifier, kernel/bpf/verifier.c, held more than 20,000 lines of C in November 2026.

Worked example

An interpreter gives a program one 8-byte input buffer at address 0x20001000. The buffer has offsets 0 to 7. Register r1 holds the address of the buffer. The program asks to load 4 bytes from the address in r1 plus 6.

  1. The interpreter computes the address, 0x20001006. The address is not below the start of the buffer, so its offset inside the buffer is 0x20001006 minus 0x20001000, which is 6.

  2. The offset is not larger than the size of the buffer, because 6≤86 \le 8. The interpreter computes how many bytes remain from offset 6 to the end of the buffer: 8−6=28 - 6 = 2.

  3. It compares the width of the access with the bytes that remain: 4≤24 \le 2 is false. The load would touch offsets 6, 7, 8 and 9, and offsets 8 and 9 lie beyond the buffer.

  4. It does not perform the load. It stops the program and reports a fault.

With offset 4 in place of 6, step 2 gives 8−4=48 - 4 = 4 and step 3 gives 4≤44 \le 4, which is true. The load touches offsets 4 to 7 and proceeds. A check of the start address alone would have accepted the first load, because offset 6 is inside the buffer.

Follow-up questions and limits

Do the checks limit how long the program runs? No. The instruction counter limits the number of instructions, not time. One call can start a helper function that runs with no time limit.

Do the checks make the program correct? No. A program can stay inside its memory and still return the wrong decision.

Is a bounds check all that memory safety needs? No. A bounds check compares numbers. It still passes for memory that was freed and given to a new owner, unless the list of regions is kept true. It also guards the edge of a region, not the edges between two objects that share the region.

This answer covers memory safety. It does not cover whether the program came from an authorized sender.

Fullest treatment: Runtime bounds check (§2.27).

Related entries: Structural bytecode admission (§2.26), Helper contract (§2.21), Interpreter semantic fidelity (§2.38), Trusted computing base (TCB) (§1.4), eBPF verifier (§3.3), Interpreter (§2.13), Complete mediation (§1.16). Further reading: [2, 3, 160, 206].