Dev.to Security πŸ” Cybersecurity πŸ‘ 0 πŸ“– 9 min read

CHERI Capability Machines vs MMU Virtual Memory: Two Ideas of a Pointer

Most memory corruption bugs come from a simple fact: in a conventional computer, a pointer is just an integer. If a program computes the wrong address, the hardware has no way to know the mistake is a mistake β€” it happil

Most memory corruption bugs come from a simple fact: in a conventional computer, a pointer is just an integer. If a program computes the wrong address, the hardware has no way to know the mistake is a mistake β€” it happily reads or writes whatever the number says. The memory management unit, or MMU, was the twentieth century's answer, dividing memory into pages and checking access at page granularity. CHERI, a capability-machine architecture developed over more than a decade, proposes a different answer: make every pointer a hardware-protected token that carries its own bounds and permissions. The two approaches protect the same memory but disagree fundamentally about what a reference to memory should be.

An MMU checks access in coarse page-sized chunks using a page table, while a CHERI capability is an unforgeable pointer carrying its own bounds and permissions that the hardware checks on every dereference, enabling fine-grained memory safety that page tables cannot express.

Part One: What is being compared

An MMU sits between the processor and physical memory. It translates virtual addresses to physical addresses using a multi-level page table maintained by the operating system, and it attaches protection bits to each page β€” readable, writable, executable, user-accessible. When software accesses memory, the hardware checks the page's permissions and raises a fault on violation. This is the foundation of process isolation: one application cannot read another's memory because their page tables map the same virtual addresses to different physical pages. It is a remarkably successful abstraction, and it underpins every general-purpose operating system in use today.

The weakness is granularity. A page is typically 4 kilobytes, sometimes 2 megabytes or 1 gigabyte. Protection applies to the whole page. If a 64-byte object and a sensitive 64-byte key share a page, the MMU cannot protect one from the other β€” they live under the same permission bits. A buffer overflow that writes a few bytes past an array stays inside the array's page, so the MMU sees nothing wrong. Worse, page tables are large and slow to walk, so processors cache translations in a translation lookaside buffer, and changing protections frequently is expensive. The MMU is good at isolating large regions from each other and poor at isolating small objects within a region.

CHERI, which stands for Capability Hardware Enhanced RISC Instructions, changes the pointer itself. A CHERI capability is a wide value β€” typically 128 bits on a 64-bit architecture β€” that contains an address plus a base and bound defining a valid region, plus permission bits describing what may be done with it. Crucially, capabilities are unforgeable: they are tagged in memory by extra hardware bits, and integer arithmetic cannot produce a valid capability. You cannot take an integer, add one to it, and get a pointer, because the result loses its tag. To point at a smaller region you must explicitly derive a narrower capability from a wider one, and the hardware enforces that the new bounds stay within the old.

Part Two: The arithmetic

The protection granularity is where the numbers diverge sharply. With an MMU, the smallest unit of protection is a 4 KB page. A program with ten thousand small objects has, from the hardware's perspective, a handful of pages containing many objects each. A single out-of-bounds write of a few bytes is invisible as long as it stays within the page. CHERI capabilities can be as narrow as a single object: a 32-byte structure gets a capability whose bounds are exactly 32 bytes, and a write one byte past it traps immediately in hardware. The difference between 4,096 bytes and 32 bytes is roughly a thousand-fold improvement in protection granularity.

Where an MMU's smallest protected unit is a 4 KB page, a CHERI capability can bound a single 32-byte object and trap an out-of-bounds write in hardware on the very next instruction, roughly a thousand-fold finer protection than page tables provide.

The cost side of the arithmetic is the capability itself. A CHERI pointer is typically 128 bits rather than 64, doubling the size of every pointer in the program. Structures containing many pointers grow, caches hold fewer objects, and memory bandwidth use rises. Early evaluations on the CHERI RISC-V and Morello prototypes found performance overheads in the low single-digit to low double-digit percentages for unmodified code, dropping substantially once software is adapted to use capabilities efficiently. The hardware must also check bounds on every memory access, which adds a small amount of logic to the critical path, though careful pipelining keeps the cycle-time impact modest.

There is a second-order benefit that offsets some of this cost. Because capabilities can express fine-grained sharing, a program can hand a narrow, read-only capability for one object to another component without granting access to the rest of its memory. In a web browser, that means a parser could receive a capability to just the buffer it needs, rather than sharing a whole address space. This shrinks the trusted computing base β€” the amount of code that must be correct for security to hold β€” which is where modern exploits concentrate. The MMU has no equivalent; its page-level model forces a choice between sharing everything and sharing nothing.

The chip-area arithmetic is subtler. CHERI does not need to eliminate the MMU; prototypes keep virtual memory and add capabilities on top, so the page table machinery remains. The extra cost is the tagged memory, wider registers and pointer paths, and bounds-check logic. On a modern processor die this is a small fraction of total area, and the dominant design cost is not silicon but the software toolchain β€” a compiler, linker, C library and operating system port that all understand capabilities. That engineering effort, not transistor count, is the real barrier to adoption.

Part Three: Where the model breaks

The hardest break is compatibility. Decades of C and C++ code assume a pointer is the same size as an integer, that you can cast a pointer to a long and back, that you can store a pointer in a 64-bit field, and that pointer arithmetic is just addition. CHERI deliberately breaks every one of these assumptions, because they are exactly what make out-of-bounds access possible. Existing programs cannot simply be recompiled unchanged; they need source changes, and sometimes significant architectural rework. The operating system and all its libraries must be ported too. This is why CHERI, despite being research-stable for years, has not appeared in mainstream shipping processors.

Pure capability systems have also struggled with the compartmentalisation story. It is easy to give a component a narrow capability; it is harder to decide where the boundaries between components should be and to retrofit them into a large application. A monolithic program gains little from capabilities unless someone divides it into mutually distrusting parts, and that division is a design problem, not a hardware feature. The security benefit is only realised when the software is structured to use it.

The memory-tag mechanism introduces its own concerns. Tags are extra bits stored alongside memory, typically one tag bit per capability-sized granule, and they must be preserved end-to-end through caches, DMA and I/O devices. Devices that write memory directly must either be capability-aware or go through an interface that maintains tags correctly. Getting this wrong could allow a tag to be lost or forged, undermining the whole model. It is a manageable engineering problem but an unfamiliar one for hardware teams.

Finally, CHERI does not prevent every bug. It stops spatial memory errors β€” accessing outside an object's bounds β€” and, with careful use, can help with temporal errors like use-after-free through revocation. But logical bugs, race conditions and flaws in application logic remain. It is a powerful tool that removes an entire class of low-level vulnerability, not a guarantee of correct software. Teams that expect it to eliminate security work entirely will be disappointed.

What is actually transferable

The deeper idea is about where to place enforcement. The MMU enforces at a coarse boundary that software rarely has to think about, which is why it succeeded: it is nearly invisible. CHERI enforces at a fine boundary that software must participate in, which is why it is powerful and why adoption is slow. This is a general trade in security architecture β€” the stronger the guarantee, the more the software must cooperate to earn it.

For an ordinary user, the payoff is invisible in the best sense. The web browser, media player and messaging app on a CHERI-based machine would be far harder to compromise through the memory-corruption bugs that dominate real-world exploits. The user would not see a capability or a tag; they would simply see fewer successful attacks and fewer emergency patch cycles. The same applications, compiled for the same task, would be substantially harder to break into β€” determined by a property of the pointer, not a change in behaviour.

For a software organisation, the decision is about where to spend effort. Adopting CHERI means a toolchain port and code changes, which is expensive, but it can remove entire categories of vulnerability from the audit list. For high-assurance systems β€” defense, finance, critical infrastructure β€” that trade can be attractive. For a consumer app with a short release cycle, the cost currently outweighs the benefit, which is why the technology has stayed in research and specialist deployments.

For the hardware industry, the interesting question is whether the extra silicon and toolchain cost can be amortised into ordinary chips. If a mainstream processor shipped with capability support enabled and compilers produced capability-clean binaries by default, software would gradually adapt, much as 64-bit and non-executable stacks did. The barrier is coordinated adoption across hardware, operating systems and toolchains at once, which is a much harder problem than any single layer.

A fair comparison fixes the workload, the threat model and the software stack, then compares the classes of bug each architecture actually prevents and the cost of getting there. Comparing page-level isolation to object-level capabilities is comparing two different definitions of the word "protected."

Market sizing check

Memory-safety vulnerabilities account for a large share of serious software exploits, and the global cybersecurity market exceeds two hundred billion dollars annually. Even a modest foothold for hardware-enforced memory safety β€” in high-assurance processors, secure enclaves, and eventually mainstream CPUs β€” could represent a multi-billion-dollar component and tooling market. If capability extensions reached even five to ten percent of new server and embedded processor shipments over a decade, the associated toolchain, porting and security-services work would be a substantial business. The swing factor is not silicon cost but whether an ecosystem can coordinate toolchain, operating system and application support.

These are order-of-magnitude estimates from published market ranges and a stated model, not a forecast for any specific vendor.

The comparison that matters

CHERI and the MMU are not simple substitutes. The MMU gives coarse, cheap, nearly invisible isolation that every operating system relies on and that software never has to think about. CHERI gives fine-grained, stronger isolation that demands software cooperation in exchange for removing an entire class of vulnerabilities. One is a foundation; the other is a refinement that changes the rules.

The conclusion assumes the software can be adapted. If a team can restructure code around capabilities, the security gain is real and permanent. If it cannot, the strongest hardware in the world protects nothing that the program voluntarily exposes. The guarantee is only as good as the boundaries the software chooses to draw.

The MMU protects pages that software rarely thinks about, while CHERI protects objects that software must explicitly name β€” and that difference, between invisible and cooperative enforcement, is the whole story of why one is everywhere and the other is still arriving.

Creating this takes real effort β€” thank you for the support.
HCqPmPJM3NVtS6YrmVaTZYnuP8XZ2PFgQZKT94VK1LkS

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.