Developers

Use Rust with CHERI

Rust and CHERI address overlapping memory-safety risks at different layers and can be combined to protect safe code, unsafe code and component boundaries.

For
Developers, engineering managers and educators
Last reviewed
2026-08-05
Review cycle
Review every 6 months

What you’ll do

Rust and CHERI address overlapping risk at different layers. Rust prevents many memory-safety errors in safe code; CHERI enforces hardware limits across native code, foreign-function interfaces, unsafe Rust and compartment boundaries.

Before you begin

Together they can provide stronger defence for mixed-language systems than either can provide across every component alone.

Steps

1. Keep safe Rust safe

Use ownership and type-system guarantees for new code and minimise unsafe blocks.

2. Treat interfaces as boundaries

Review FFI data layout, pointer provenance, allocation ownership and capability permissions.

3. Compartmentalise

Give Rust and non-Rust components only the authority they require, especially for untrusted inputs and third-party code.

Check your result

CHERI does not make unsafe Rust safe, and Rust support varies by target, runtime and library ecosystem. Verify the current toolchain.

Record the architecture, platform, ABI, release, source revision and complete commands. A second developer should be able to reproduce the result.

Useful references

Continue

Build a small Rust/C boundary on a supported target, document ownership and capability transfer, and test invalid input on both sides.

Understand how the approaches complement each other