notes

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:

What was wrong, and is now fixed

  1. A crafted ELF could panic the kernel (crates/static_elf). The parser checked p_offset + p_filesz and memsz >= filesz but never p_vaddr + p_memsz. A segment with memsz near u64::MAX passed validation, then overflowed the entry-in-segment check and page_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 a checked_add on vaddr + memsz (new Error::AddressOverflow), saturating arithmetic in the pub page_range, and two tests (u64::MAX memsz, 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.

  2. A spawn flood could panic the kernel (shell_service). The process service did .expect(...) on sched::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.

  3. A failed MemoryRegion::MAP silently burned the process's own budget. The system call retyped a page before attempting the map, so a bad va (misaligned, or high-half) spent a page for nothing. Now those cheap cases are rejected before any page is retyped. (An already-mapped va still costs one page, which is process-local and bounded by the untyped, so it is left as-is.)

  4. Stale documentation described defenses the code no longer has. Comments still pointed at user_slice and the confused-deputy AT S1E0R reader, 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 historical moho_abi::console methods are marked as such.

What is deferred, on purpose, and named honestly

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: