Definition
A helper allowlist is the set of helper functions §2.19 that a guest program may call; any other call is refused before the helper runs. A guest program is code that a host program runs inside a virtual machine §2.3 (VM), a computer defined in software. A helper function is a host function that the guest calls for a service it cannot perform itself, such as reading a clock. The allowlist grants permission. It is separate from the dispatch table §2.39, which only says where the code for each helper is.
The idea
A host offers three helpers. Helper 1 reads a clock, helper 2 reads a temperature sensor and helper 3 switches a motor on or off. A guest that filters temperature readings needs helpers 1 and 2. If it can also call helper 3, a faulty or malicious guest can start the motor. Every helper a guest can reach hands it some of the host’s power, and the guest’s safety argument must cover each one. An allowlist keeps that set as small as the task allows, here . This is the principle of least privilege §1.15: each part of a system gets only the rights its job needs.
An allowlist names what is permitted and refuses everything else. A denylist names what is forbidden and permits everything else. Older texts call the two a whitelist and a blacklist. The difference shows when the host changes. Suppose a later version of the host adds helper 4, which erases stored data, for an unrelated task. Under a denylist, every guest may call helper 4 until someone forbids it. Under an allowlist, no guest may call it until someone permits it. A design in which a missing decision leads to refusal is called fail closed §1.13, and refusal as the starting position is a secure default §1.47.
How it works
For each call instruction, the host must establish three facts about the helper number that the instruction carries, in this order; the number is called the helper ID.
Range. The host keeps its helpers in a dispatch table: an array §14.5 whose slot holds the address of the function that implements helper . With slots, numbered 0 to , the check is . It must run before the host reads slot , because reading slot or slot reads memory outside the array, and the host would then call whatever address it found there.
Presence. A slot can be empty, because this build of the host leaves that helper out. In C an empty slot usually holds a null pointer §4.26, the value that means “no address”. Calling through a null pointer is undefined behavior §4.12: with memory protection the call usually stops with a fault, and without it a small processor may run whatever bytes lie at address 0. The host refuses an empty slot.
Permission. The host checks that is in the allowlist for this guest, or for this kind of guest.
A call that passes all three is still not ready to run. Its arguments must also satisfy the helper contract §2.21, the full statement of what the helper requires and promises.
The sign of the number matters. In eBPF §2.1 (extended Berkeley Packet Filter), a helper call carries the helper ID in the instruction’s 32-bit immediate field, a constant stored inside the instruction, which the instruction set defines as a signed integer. The bit pattern 0xFFFFFFFF is then , and a host that tests only on the signed value accepts it and reads the slot just before the table. Testing as well refuses it, and so does converting first to an unsigned 32-bit integer, in which 0xFFFFFFFF is 4,294,967,295.
The checks can run at two times. A load-time check runs once, before the guest first runs, and rejects the whole program if any call fails; a run-time check runs at every call. The Linux eBPF verifier §3.3, the checker that examines eBPF programs before the kernel runs them, checks at load time. Each helper ID must lie between 0 and the largest ID the kernel defines, and the program’s type must return a description of that helper, which it does only for helpers it permits; packet filters and tracing programs are offered different helpers this way. A load-time check is enough only if the program’s instructions, the table and the allowlist do not change between the check and the end of the run.
Permission can be stored as a list of IDs, as a bit mask §4.50 with one bit per ID, or as a column in the dispatch table. Whatever the storage, the rule must not be “a guest may call whatever the table contains”. Under that rule, adding a helper for one guest silently grants it to every guest.
Worked example
A host has a dispatch table with slots, numbered 0 to 7. Slot 1 holds the clock helper and slot 3 holds the motor helper; every other slot is empty. One guest’s allowlist is : the guest’s designer expected helper 7, a sensor reader, but this build does not include it. Each call goes through range, presence and permission, in that order.
ID 1: holds, slot 1 is filled, and 1 is in . The call goes on to the argument checks.
ID 3: holds and slot 3 is filled, but 3 is not in . Refused. A range check alone would have let this guest start the motor.
ID 7: holds, but slot 7 is empty. Refused, although the allowlist names 7, because calling slot 7 would mean calling through a null pointer.
ID 8: is false. Refused before the table is read; with 4-byte addresses, as on a 32-bit processor, the table occupies bytes, and “slot 8” would be the 4 bytes just after it.
ID , encoded as
0xFFFFFFFF: is false. Refused. A host that tested only would read the 4 bytes just before the table and call them as an address.
As a bit mask, sets bits 1 and 7: , which is 0x82. To test ID , shift the mask right by places, which divides it by and drops the remainder, and keep the lowest bit. ID 7: gives 1, whose lowest bit is 1, so 7 is permitted. ID 3: gives 16, whose lowest bit is 0, so 3 is not. The range check comes first here too: in C, shifting a 32-bit value by 32 or more places is undefined behavior.
Stated precisely
Let be the number of slots in the dispatch table, let be the content of slot , either a function or empty, and let be the allowlist for guests of kind , a set of helper IDs. A guest of kind may execute a call with helper ID only if all three conditions hold:
, evaluated on the integer value that the instruction encodes, with no wrap-around;
is not empty;
, where means “is an element of”.
Condition 1 must be established before any read of , and conditions 2 and 3 before the helper starts. The helpers that a guest of kind can reach are therefore exactly where is the set of all IDs that meet the condition after the colon, and keeps the IDs that are in both sets. In the example this is .
A call that meets all three conditions must still meet its helper’s contract. A check made at load time stands in for a check at every call under two named assumptions: the program’s instructions are not changed between the check and the end of the run, and , and at run time are the ones the check used.
Limits and common mistakes
An allowlist decides which helpers a guest may call, not with which arguments. A guest permitted to call a write helper can write any value that the helper accepts. Restricting values is the job of the helper contract and of the checks inside the helper.
An allowlist does not make a helper safe: a permitted helper runs as host code with all of the host’s rights. Nor does it bound time: a permitted helper that waits for a device stalls the guest however few instructions the guest executes.
The most common mistake is order. Code that reads table[id] and only then tests id has already read outside the table when the test fails, and a helper that writes a device register before checking permission has already acted. A second mistake is to treat as permission: it proves only that the lookup is safe.
An allowlist is only as strong as the name it matches. Helper IDs are good names because the host alone decides what each ID means. Network addresses are poor names, because each peer chooses the address it sends; the second question below works this through.
The allowlist must stay tied to the program it was checked against. If a program was admitted under one allowlist and the host later widens the allowlist for that kind of guest, the old program gains rights that nobody checked it for.
Questions answered
Are helper identifiers checked before indexing the dispatch table?
They must be: a correct host checks each helper identifier against the size of the dispatch table before it reads the table, and checks that the slot is filled and that the guest may use that helper before it calls it. The dispatch table is an array whose slot holds the address of the host function, called a helper function, that a guest program in a virtual machine invokes by the number . For an unchecked that is too large or negative, reading slot reads memory outside the array, and the host then calls whatever address it found.
For a table with slots the checks are: on the value the instruction encodes, so that a signed neither passes as a small number nor turns unnoticed into a huge index; the slot is not empty, since calling an empty slot calls through a null pointer; and is in the helper allowlist for this guest, since a number in range can still name a forbidden helper. The checks may run once at load time, as in the Linux eBPF (extended Berkeley Packet Filter) verifier, which then rejects the whole program, or at every call. A load-time check is enough only if neither the program nor the tables change before the run ends.
Why does a denylist of peer addresses fail against an attacker who can choose its address, and what must an allowlist key on to be meaningful?
A denylist of peer addresses fails because it blocks only the addresses already on it, and an attacker who can choose its own address simply sends from one that is not on it. A denylist names what is forbidden and permits everything else, so every new address is permitted by default. A device address, such as the hardware address that a Bluetooth or Ethernet device puts in its packets, is chosen by the sender: many radios let software set it, and a programmable radio can send any value.
An allowlist names what is permitted and refuses everything else, so a new address gains nothing. Keyed on addresses, it is still weak: an address is public, since it appears in every packet, and an attacker who has heard an allowed device can send that same address, which is called spoofing. A meaningful allowlist keys on something the attacker cannot produce: proof that the peer holds a secret key. Examples are a key that two Bluetooth devices established during pairing and on which their link’s encryption depends, or a public key whose digital signature §5.14 the receiver verifies. The address can remain a cheap first filter, but the decision to trust a peer rests on the key check.
Related entries: Dispatch table (§2.39), Helper contract (§2.21), Helper function (§2.19), Least privilege (§1.15), Null pointer (§4.26), Integer promotion and conversion (§4.18), Signed versus unsigned comparison (§2.12). Further reading: [1, 2, 78].