A Star is Reborn: The PHP Interpreter Rewritten in Safe Rust
Tianyu Li, Bo Wang, Prateek Saxena, Umang Mathur
Key points
From the paper's conclusion- To our knowledge, this is the first principled safe Rust port of a core fragment of the PHP interpreter that combines formal guarantees of logical memory safety with functional compatibility.
Abstract
PHP powers most of the web, yet its C interpreter has had many memory-safety vulnerabilities. Reimplementing the interpreter in safe Rust offers a promising way to eliminate these vulnerabilities. However, eliminating native memory violations alone does not necessarily prevent unintended accesses to the logical memory of the translated program. To prevent such failures, we introduce logical memory safety, which confines the program operations to their permitted memory. In this paper, we formalize this property for PHP through an abstract PHP machine model that captures how the PHP interpreter manages program values while abstracting away functionality details. Guided by this model, we reimplement the PHP 5.0.0 engine in safe Rust, and formally prove that, for a core fragment of PHP, our Rust translation refines the abstract PHP machine, thereby establishing logical memory safety for this fragment. Our translation safely handles all 173 memory vulnerabilities we collected that affect PHP 5.0.0 prior to the rewrite. The Rust version matches the C implementation on all functionality tests, and produces identical outputs for the real-world PHP applications we evaluate. To our knowledge, this is the first principled safe Rust port of a core fragment of the PHP interpreter that combines formal guarantees of logical memory safety with functional compatibility. The improved security comes at a modest average runtime overhead of only 15% compared to C.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- Verified Implementation of the Next-gen Borrow Checking Algorithm for Rust via Abstract InterpretationarXiv · 2026
- Miri: Practical Undefined Behavior Detection for RustProceedings of the ACM on Programming Languages · 2026
- Bringing Foundational Verification to Real-World Rust CodeProceedings of the ACM on Programming Languages · 2026
- XRust: Detecting Logical Races in Rust Linux DriversarXiv · 2026
- Petri Nets-based Methods on Automatically Detecting for Concurrency Bugs in Rust ProgramsACM Transactions on Autonomous and Adaptive Systems · 2026
- Scylla: Translating an Applicative Subset of C to Safe RustProceedings of the ACM on Programming Languages · 2026