A Star is Reborn: The PHP Interpreter Rewritten in Safe Rust

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.

Authors

Publication Details

Journal
arXiv
Published
2026-11-24
DOI
https://doi.org/10.48550/arxiv.2611.32477
Primary Topic
Logic, programming, and type systems
Type
preprint
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
preprint

A Star is Reborn: The PHP Interpreter Rewritten in Safe Rust

Umang Mathur, Prateek Saxena, Bo Wang, Tianyu Li
arXiv
Logic, programming, and type systems
preprint

A Star is Reborn: The PHP Interpreter Rewritten in Safe Rust

Umang Mathur, Prateek Saxena, Bo Wang, Tianyu Li
preprint en

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.

arXiv
Logic, programming, and type systems
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon