A security audit
A four-part adversarial review of the whole kernel, done after milestone 11. Four independent reviewers read the code cold, one per dimension, and every finding was verified against the source before it was believed. This note is the record: the threat model, what held up, what did not, what was fixed, and what is deferred on purpose.
Threat model
A malicious or buggy userspace ELF running at EL0 that wants to (a) escape confinement and reach kernel or another process's memory, or (b) forge or widen a capability it was not granted. Or to (c) corrupt the kernel with a crafted binary, filesystem, or message, or (d) exhaust kernel resources to take the machine down. No remote attacker, no crypto, single core, runs under QEMU or HVF.
What held up
The core boundaries are sound, and the review confirmed each with reasoning rather than assertion:
- The capability boundary. No method is invocable without its rights (SEND needs WRITE, RECEIVE
needs READ,
MemoryRegion::MAPneeds WRITE,Interruptneeds READ). Userspace only ever names a capability slot, whichCapabilityTable::getbounds-checks; the object index inside (endpoint id, untyped region, intid) always comes from a kernel-minted capability, never a user register. Rights cannot widen, and delegation is not even exposed to userspace yet. No process can reach another's CapabilityTable, mailbox, or endpoints. - The MMU. Every
user_*page-flag has correct AP/PXN/UXN bits; W^X holds as a type invariant (there is no writable-and-executable constructor, proved over all of them by a test). EL0 cannot name, read, write, or execute any kernel high-half address.map_physical(arbitrary-physical mapping) is not reachable from EL0; the only user mapping path isMemoryRegion::MAP, which is confined to the process's own budget and own low half. - TLB discipline. Stack VAs and address spaces are flushed on reuse, so a new owner cannot read a dead owner's data.
- The scheduler and locks. No third instance of the two bugs milestone 9 (A virtio-blk driver at EL0, and an interrupt) fixed (interrupt
restored under the lock; no idle thread).
HELD_RANKisNONEat everyswitch_to; IPC blocking races, interrupt re-entrancy, and the untyped-MAP TOCTOU all check out on single core. - The loaders and parsers. ELF file-bounds and header-table math are
checked_*;.bssis genuinely zeroed; the "load over the kernel" attack is refused by construction (Half::Low); the device-tree parser reads every field through bounds-checked accessors and cannot be made to loop or read out of bounds.
What was wrong, and is now fixed
-
A crafted ELF could panic the kernel (
crates/static_elf). The parser checkedp_offset + p_fileszandmemsz >= fileszbut neverp_vaddr + p_memsz. A segment withmemsznearu64::MAXpassed validation, then overflowed the entry-in-segment check andpage_range. With overflow-checks on (the shipping dev profile) that is a panic, i.e. a hostile initrd halting the kernel, which is precisely the denial of service the ELF crate exists to prevent. Fixed with achecked_addonvaddr + memsz(newError::AddressOverflow), saturating arithmetic in thepubpage_range, and two tests (u64::MAXmemsz, and 65-header count). Also capped the program header count (MAXIMUM_PHNUM = 64), because 65535 headers turned the O(n²) overlap check into a multi-second stall. -
A spawn flood could panic the kernel (
shell_service). The process service did.expect(...)onsched::spawn, so once memory was tight, out-of-memory became a kernel panic. Now it degrades: a failed spawn returns a sentinel result to the shell ("could not spawn a process") and the service keeps serving. Per-process spawn quotas are the real fix and are deferred with untyped kernel objects; not turning OOM into a panic is the cheap, honest hardening. -
A failed
MemoryRegion::MAPsilently burned the process's own budget. The system call retyped a page before attempting the map, so a badva(misaligned, or high-half) spent a page for nothing. Now those cheap cases are rejected before any page is retyped. (An already-mappedvastill costs one page, which is process-local and bounded by the untyped, so it is left as-is.) -
Stale documentation described defenses the code no longer has. Comments still pointed at
user_sliceand the confused-deputyAT S1E0Rreader, which milestone 8 deleted when the console left the kernel; a future reader could have believed a pointer path was guarded when there is no pointer path at all. Corrected, and the historicalmoho_abi::consolemethods are marked as such.
What is deferred, on purpose, and named honestly
-
DMA confinement: now closed by kernel-mediated validation. This was the single most severe item: the virtio device is a second bus master doing DMA against raw physical addresses with no MMU in front of it. So a hostile driver could point a descriptor at the kernel and the device would DMA over it. QEMU
virthas no IOMMU that covers virtio-mmio, so the fix is software. The kernel keeps the two DMA-critical powers (programming the queue's ring addresses and ringing the device). It validates that every descriptor stays within the driver's own DMA region before the device sees it. The driver drives the device through aVirtualIocapability and can no longer aim it anywhere else. A malicious driver pointing a descriptor at the kernel image is now refused end to end, and there is a test that proves it (and that the legit block read still works). Fault isolation and malice isolation now hold. A second audit pass found the in-place check was still bypassable two ways. An indirect descriptor aims the device at a table the validator never walked (reachable on QEMU, which offers the feature). A packed ring swaps the format out from under it. Both are now stripped at feature negotiation and refused at validation, with unit and end-to-end tests. The residual time-of-check/time-of-use race (the validator read descriptors the driver keeps mapped writable) is now closed too. The device reads a shadow descriptor ring in kernel-private memory, filled by a validated copy on each notify. So it never reads a descriptor the driver can mutate after the check. The driver's ABI is unchanged and the end-to-end disk read still works through the copy. A test points a descriptor at the kernel after validation and confirms the shadow is untouched. See notes/dma.md. -
Per-process resource limits: closed by the untyped budget, not by a per-spawner quota. The spawn-exhaustion vector is bounded because a process spawns out of its own untyped budget (§10 (process model), §16 (object revocation)): the budget is the limit, and retyping enforces it. The per-spawner quota in notes/quotas.md still exists in the kernel but has had no caller since §28 retired the kernel-wired shell, which milestone 41 found and recorded there. Read that note as a description of the mechanism, not of what is running. What remains unbounded is any kernel object a future system call might create outside the untyped model.
-
No IPC timeouts and no revocation. A thread blocked on an endpoint that never gets a peer is never reclaimed. This is the accumulation primitive above, and it is the seL4 depth (capability derivation tree, revocation) deliberately parked.
Recorded-accepted by milestone 94's sweep (2026-08-04). "Parked" here is a position and not a backlog entry: the tree took generational names instead of a derivation tree, and notes/generational-names.md carries the argument. An audit may pass over it. §71 says what would promote it, and notes/untracked-work-sweep.md holds the sweep's inventory.
The shape of the result
The MMU-and-capability confinement, the part the whole architecture is built to get right, held up under adversarial reading with no exploitable hole. The real defects were two panics on untrusted input, both now fixed and tested, and the honest limitations were the ones a single-core kernel without an IOMMU or resource quotas is expected to have. Naming them is the point; a kernel that pretends to isolate a hostile DMA driver is worse than one that says it cannot.
What has changed under this audit since (2026-09-05)
This is a dated record of a review done after milestone 11 and everything above stays in its own present tense. Four of its standing conditions have moved, and a reader who took the paragraph above as current would be wrong about all four:
- Single core. The threat model says "single core", and the scheduler section says the IPC blocking races and the untyped-MAP TOCTOU "check out on single core". SMP landed with DECISIONS §11 (SMP: per-CPU run queues, message-based migration). What was checked by reading here is now searched by loom (notes/interleaving.md) and inventoried by notes/memory-ordering.md, and neither existed when this was written.
- "delegation is not even exposed to userspace yet". It is.
SEND_CAPABILITYhands a capability over an endpoint, and notes/delegation.md is honest that until it existed the kernel was "a central authority-granting oracle", which is a sharper statement of the same gap this audit recorded. - "without an IOMMU". Milestone 16b built one, on both architectures, at the QEMU tier: an identity-mapped domain per device with the existing DMA-escape tests run behind it, plus two Kani harnesses over the aarch64 entry arithmetic. The shadow ring (notes/dma.md) deliberately stays as defense in depth. notes/iommu.md carries the honest limits, which are real.
- "without resource quotas". The mechanism exists (
Thread's quota slot, returned by ownership rather than by bookkeeping; notes/quotas.md), andsched::spawn_with_quotahas no caller today, so the exhaustion attack this audit named is still reachable. The gap is "a mechanism nobody wired" rather than "no mechanism", which is a different piece of work.