CHERI C/C++ ガイド:ケイパビリティハードウェアにおけるメモリ安全性のための失われたマニュアル

GitHub April 2026
⭐ 67
Source: GitHubArchive: April 2026
CHERI C/C++ プログラミングガイドが、CHERI ケイパビリティハードウェアを対象とする開発者向けの決定版リファレンスとしてリリースされました。このガイドは、ポインタ圧縮、ケイパビリティ境界チェック、その他の中核的概念を体系的にカバーし、CHERI エコシステムにおける重要なドキュメントギャップを埋めます。
The article body is currently shown in English by default. You can generate the full version in this language on demand.

The CHERI (Capability Hardware Enhanced RISC Instructions) architecture represents one of the most promising hardware-software co-design approaches to eliminating memory safety vulnerabilities at the root. For years, the CHERI ecosystem has been rich in research papers and academic prototypes but severely lacking in practical, developer-friendly documentation. The release of the official CHERI C/C++ Programming Guide on GitHub (repo: ctsrd-cheri/cheri-c-programming) changes that equation. This guide is not merely a tutorial; it is a comprehensive reference that systematically explains how to write C and C++ code that fully leverages CHERI's capability model. It covers everything from the basics of capabilities—fat pointers that carry both address and permission metadata—to advanced topics like pointer compression (where capabilities are packed into 64-bit registers to reduce memory overhead) and fine-grained bounds checking. The guide's significance extends beyond mere documentation. It lowers the barrier to entry for developers who want to experiment with CHERI on platforms like Arm's Morello board or the CHERI-RISC-V FPGA implementations. By providing clear code examples, best practices, and explanations of common pitfalls, the guide accelerates the transition from research curiosity to practical adoption. For security researchers, it offers a structured way to understand how CHERI's architectural guarantees translate into compiler-level protections. For the broader industry, this guide is a signal that CHERI is moving from the lab into the hands of real developers, potentially reshaping how we think about memory safety in systems software.

Technical Deep Dive

The CHERI C/C++ Programming Guide is built around a deceptively simple premise: teach developers how to write code that works correctly with CHERI's capability model. But the technical reality is far more nuanced.

At its core, CHERI replaces traditional 64-bit pointers with 128-bit or 256-bit capabilities. Each capability contains not just an address, but also a base, a bound (length), and a set of permissions (read, write, execute, load capability, store capability, etc.). The hardware enforces that any memory access through a capability must fall within its bounds and respect its permissions. This is fundamentally different from conventional MMU-based protection, which operates at page granularity (typically 4KB). CHERI enables byte-granularity protection, meaning a buffer overflow of even a single byte can be caught at runtime.

The guide dedicates substantial attention to pointer compression, a critical optimization for real-world deployment. Full 128-bit capabilities double the size of every pointer, which is prohibitive for many workloads. CHERI's compression scheme, as implemented in the Morello architecture, stores capabilities in 64-bit registers when possible, using a technique that exploits the fact that many capabilities share common base and bound values. The guide explains how developers can structure their data to maximize compressibility—for example, by grouping objects with similar lifetimes and permissions into the same memory region.

Another key section covers the interaction between CHERI and the C/C++ type system. The guide explains how to use the `__capability` keyword to annotate pointers, and how the compiler automatically instruments code with bounds checks. It also covers the CHERI-specific intrinsics for manual capability manipulation, such as `cheri_bounds_set` and `cheri_perms_and`. These intrinsics give developers fine-grained control when the automatic instrumentation is insufficient.

For developers working on CHERI-RISC-V implementations, the guide references the open-source CHERI LLVM compiler and the associated toolchain. The GitHub repository for the CHERI LLVM project (ctsrd/cheri-llvm) has seen steady activity, with over 1,200 stars and regular commits. The guide shows how to compile existing C/C++ codebases with minimal modifications, often just by adding compiler flags like `-mabi=purecap` (pure capability ABI).

Data Table: CHERI Overhead vs. Traditional Memory Safety Approaches

| Approach | Memory Overhead | Performance Overhead | Granularity | Detection Time |
|---|---|---|---|---|
| CHERI (128-bit caps) | ~100-200% pointer size | 5-15% average | Byte-level | Runtime (hardware) |
| Address Sanitizer | ~200-300% memory | 2-3x slowdown | Byte-level | Runtime (software) |
| SoftBound/CETS | ~50-100% memory | 1.5-2x slowdown | Byte-level | Runtime (software) |
| Rust (ownership) | ~0% runtime | 0% runtime | Compile-time | Compile-time |
| MPK (Memory Protection Keys) | ~0% pointer size | <1% overhead | Page-level | Runtime (hardware) |

Data Takeaway: CHERI offers a compelling middle ground: hardware-enforced byte-granularity protection with moderate performance overhead, far lower than software-only approaches like Address Sanitizer. However, the pointer size increase is a real cost that compression schemes only partially mitigate.

The guide also delves into the interaction between CHERI and C++ features like virtual tables, exceptions, and standard library containers. For example, CHERI's capability model requires that vtable pointers be treated as capabilities, which means the hardware can verify that a vtable access doesn't exceed the vtable's bounds—preventing vtable hijacking attacks. The guide provides patterns for writing CHERI-safe custom allocators and smart pointers.

Key Players & Case Studies

The CHERI ecosystem is primarily driven by academic and research institutions, with the University of Cambridge's Computer Laboratory as the originator. The guide is authored by researchers from Cambridge, SRI International, and Arm, reflecting the collaborative nature of the project.

Arm's Morello board is the most prominent commercial CHERI implementation. Announced in 2021 and shipping to select partners in 2022, Morello is a prototype system-on-chip that implements CHERI on a modified Armv8-A architecture. The guide includes specific examples for Morello, such as how to use the `morello` target triple and how to debug CHERI exceptions on the board. Arm has invested heavily in CHERI, viewing it as a potential differentiator for secure computing in IoT, automotive, and cloud infrastructure.

On the open-source side, the CHERI-RISC-V project (github.com/CTSRD-CHERI/cheri-riscv) provides a complete FPGA implementation of CHERI on RISC-V. This is particularly important for researchers and hobbyists who cannot access Morello hardware. The guide covers both platforms, noting that the programming model is nearly identical.

Comparison Table: CHERI Hardware Platforms

| Platform | ISA | Availability | Performance | Cost | Maturity |
|---|---|---|---|---|---|
| Arm Morello | Armv8-A + CHERI | Limited partners | ~2-5% overhead | High (prototype) | Production prototype |
| CHERI-RISC-V (FPGA) | RISC-V + CHERI | Open-source | ~10-20% overhead | Low (FPGA) | Research |
| CHERI-RISC-V (ASIC) | RISC-V + CHERI | Not yet | Projected <5% | Unknown | Design stage |
| CHERIoT (low-end) | Custom RISC-V | Open-source | Minimal | Very low | Active development |

Data Takeaway: The Morello platform remains the most practical for serious development, but its limited availability and high cost create a barrier. The CHERI-RISC-V FPGA option is accessible but slower, making it suitable for experimentation rather than production workloads.

A notable case study is the CHERIoT project (github.com/microsoft/cheriot-rtos), a collaboration between Microsoft and Cambridge. CHERIoT targets ultra-low-power IoT devices, where memory safety vulnerabilities are particularly dangerous. The guide includes sections on writing CHERIoT-compatible code, showing how the same CHERI principles apply even on resource-constrained hardware.

Industry Impact & Market Dynamics

The release of a comprehensive programming guide is a strong signal that CHERI is transitioning from research to early adoption. The immediate impact will be on the security research community and on companies building safety-critical systems.

For the broader software industry, the guide represents a double-edged sword. On one hand, it provides a path to eliminate entire classes of vulnerabilities (buffer overflows, use-after-free, etc.) that have plagued C/C++ for decades. On the other hand, it requires hardware that is not yet widely available, and it imposes a learning curve on developers accustomed to conventional memory models.

The market for memory-safe systems is growing rapidly, driven by regulatory pressure (e.g., the EU Cyber Resilience Act) and high-profile security incidents. The global market for secure microcontrollers is projected to grow from $4.5 billion in 2023 to $8.2 billion by 2028, according to industry estimates. CHERI is well-positioned to capture a significant share of this market, particularly in automotive (ISO 26262), aerospace (DO-178C), and industrial control (IEC 61508) domains.

Data Table: Memory Safety Vulnerability Trends

| Year | CVEs with memory safety root cause | Percentage of total CVEs | Estimated global cost |
|---|---|---|---|
| 2020 | ~18,000 | ~70% | $5.2 trillion |
| 2021 | ~20,000 | ~68% | $6.0 trillion |
| 2022 | ~22,000 | ~65% | $7.0 trillion |
| 2023 | ~24,000 | ~63% | $8.0 trillion |
| 2024 (est.) | ~26,000 | ~60% | $9.1 trillion |

Data Takeaway: While the percentage of memory safety CVEs is slowly declining (thanks to Rust and other safer languages), the absolute number continues to rise. CHERI offers a way to secure existing C/C++ codebases without rewriting them in a new language.

Microsoft, Google, and Apple have all publicly invested in memory safety research. Microsoft's Project Verona and Google's Android memory safety initiatives are complementary to CHERI. The guide could accelerate adoption by providing a common reference for developers across these ecosystems.

Risks, Limitations & Open Questions

Despite its technical elegance, CHERI faces several significant challenges that the guide acknowledges but cannot fully resolve.

First, the performance overhead, while modest, is not zero. For latency-sensitive applications (e.g., high-frequency trading, real-time control), even a 5% overhead may be unacceptable. The guide's advice on pointer compression helps, but it adds complexity to memory management.

Second, the guide cannot address the fundamental limitation of CHERI: it does not prevent logical bugs. A capability that grants read access to a valid memory region can still be used to read sensitive data if the program logic is flawed. CHERI is a safety net, not a silver bullet.

Third, the ecosystem is still fragmented. The guide covers Morello and CHERI-RISC-V, but there are subtle differences in how capabilities are represented and how the ABI works. Developers targeting both platforms must be careful with conditional compilation.

Fourth, the guide is a living document, but it is not yet complete. Sections on debugging CHERI exceptions, integrating with existing build systems, and performance profiling are thin. The community will need to contribute examples and best practices.

Finally, there is the question of adoption inertia. The vast majority of C/C++ developers have never heard of CHERI. The guide is a necessary but not sufficient condition for widespread adoption. It will take hardware availability, toolchain maturity, and killer applications to drive real change.

AINews Verdict & Predictions

The CHERI C/C++ Programming Guide is a landmark document for the security community. It transforms CHERI from an esoteric research project into a practical tool that developers can actually use. Our verdict: this is a must-read for anyone serious about memory safety in C/C++.

Predictions:

1. Within 12 months, we will see at least three major open-source projects (e.g., FreeRTOS, Zephyr, or a Linux subsystem) adopt CHERI support, citing this guide as a key enabler.

2. Within 24 months, Arm will announce a production-grade CHERI implementation for a specific market (likely automotive or IoT), moving beyond the Morello prototype.

3. Within 36 months, the CHERI ecosystem will reach a tipping point where major cloud providers (AWS, Azure, GCP) begin offering CHERI-enabled instances for security-sensitive workloads.

4. The guide itself will become the de facto standard reference, with over 10,000 stars on GitHub within two years, as it becomes required reading in university computer security courses.

What to watch next: The CHERI LLVM compiler's support for automatic capability inference (reducing the need for manual annotations) and the emergence of CHERI-aware static analysis tools. The guide is the foundation; the tools built on top of it will determine how quickly CHERI enters the mainstream.

More from GitHub

MOSS-TTS-Nano:0.1Bパラメータモデルで音声AIをすべてのCPUにThe OpenMOSS team and MOSI.AI have released MOSS-TTS-Nano, a tiny yet powerful text-to-speech model that redefines what'WMPFDebugger:Windows でのWeChatミニプログラムデバッグをようやく改善するオープンソースツールFor years, debugging WeChat mini programs on a Windows PC has been a pain point. Developers were forced to rely on the WAG-UI Hooks: AIエージェントのフロントエンドを標準化するReactライブラリThe ayushgupta11/agui-hooks repository introduces a production-ready React wrapper for the AG-UI (Agent-GUI) protocol, aOpen source hub1714 indexed articles from GitHub

Archive

April 20263042 published articles

Further Reading

CHERIBSD:FreeBSDのハードウェアメモリセキュリティ革命は現実にCHERIBSDはFreeBSDをCHERI-RISC-VおよびArm Morelloに移植し、ハードウェア強制のケイパビリティモデルを用いて、アーキテクチャレベルでメモリ安全性のバグのクラス全体を排除します。これはソフトウェアパッチではなCHERI LLVM フォーク:ハードウェア機能がAI時代のメモリ安全性をどう変革するかLLVMコンパイラ基盤の特殊なフォークが、ハードウェアによるメモリ安全性を主流開発にもたらしています。ctsrd-cheri/llvm-projectはCHERI(Capability Hardware Enhanced RISC InstSail における CHERI-RISC-V:ハードウェアセキュリティの最前線を深掘りSail 言語で記述された CHERI-RISC-V モデルが、ハードウェアセキュリティ検証の方法を静かに変革しています。このオープンソースプロジェクトは実行可能な仕様を提供し、RISC-V エコシステム全体でのケイパビリティベースのメモリWhisper-rs、Rustのメモリ安全エコシステムに効率的なローカル音声認識をもたらすwhisper-rsプロジェクトは、C++ whisper.cpp実装への効率的なバインディングを通じて、OpenAIのWhisper音声認識モデルをRust開発者に提供します。これにより、クラウド依存やPythonツールチェーンなしで、メ

常见问题

GitHub 热点“CHERI C/C++ Guide: The Missing Manual for Memory Safety on Capability Hardware”主要讲了什么?

The CHERI (Capability Hardware Enhanced RISC Instructions) architecture represents one of the most promising hardware-software co-design approaches to eliminating memory safety vul…

这个 GitHub 项目在“CHERI C/C++ programming guide memory safety”上为什么会引发关注?

The CHERI C/C++ Programming Guide is built around a deceptively simple premise: teach developers how to write code that works correctly with CHERI's capability model. But the technical reality is far more nuanced. At its…

从“CHERI capability hardware tutorial for developers”看,这个 GitHub 项目的热度表现如何?

当前相关 GitHub 项目总星标约为 67,近一日增长约为 0,这说明它在开源社区具有较强讨论度和扩散能力。