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
Bytecode: a program stored as instructions for a virtual machine §2.3 (VM), which is a processor defined in software. The real processor cannot run bytecode directly.
Untrusted: the author may be an attacker, so every property the system relies on must be checked, not assumed.
Interpreter: a program on the real processor that reads the bytecode one instruction at a time and carries out each instruction itself.
Linux-style verifier: a checker like the one that the Linux kernel applies to programs in eBPF §2.1 (extended Berkeley Packet Filter, now used as a plain name), a bytecode format that lets the kernel run programs supplied from outside the kernel. The eBPF verifier §3.3 examines a program once, when the program is loaded, and covers every path the program could take. It rejects the program unless every memory access is shown to be in bounds. Such checking is static analysis §3.1: it examines the program without running it.
Safely: here, memory safety. The bytecode reads and writes only the memory regions it was given, jumps only to its own instructions, and calls only the functions that the host offers. The host is the system that runs the interpreter. A function that the host offers to bytecode is called a helper function §2.19.
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.
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.
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.
The check is right, including its own arithmetic. It covers the full width of the access, and no sum inside it can exceed the largest value an integer holds and wrap around to a small number.
Nothing bypasses the check. A helper function that takes an address and a length from the bytecode checks them itself. If just-in-time compilation §2.14 (JIT) translates the bytecode into instructions for the real processor, the translated code contains the same checks.
The list of regions is true at the moment of the access. Memory is removed from the list before it is freed.
The interpreter and the helper functions are correct. They are code for the real processor, and nothing checks them at run time. They belong to the trusted computing base §1.4 (TCB): everything whose correctness the guarantee depends on.
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.
The interpreter computes the address,
0x20001006. The address is not below the start of the buffer, so its offset inside the buffer is0x20001006minus0x20001000, which is 6.The offset is not larger than the size of the buffer, because . The interpreter computes how many bytes remain from offset 6 to the end of the buffer: .
It compares the width of the access with the bytes that remain: is false. The load would touch offsets 6, 7, 8 and 9, and offsets 8 and 9 lie beyond the buffer.
It does not perform the load. It stops the program and reports a fault.
With offset 4 in place of 6, step 2 gives and step 3 gives , 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].