A Star is Reborn: The PHP Interpreter Rewritten in Safe Rust
Listen
Radio episode about this paper
Transcript
Introduction to the show: ident: Security Radio. Generated commentary on the latest security and cryptography papers.
Nadia: I'm Nadia.
Elias: And I'm Elias, here with Priya.
Nadia: We're looking at the paper: "A Star is Reborn: The PHP Interpreter Rewritten in Safe Rust".
Title and authors: Nadia: So we've been looking at how this paper fixes PHP's deep memory safety issues by introducing logical memory safety, which is basically an extra rule set on top of standard memory protection <ref:2611.32477#pg1, "To prevent such failures, we introduce logical memory safety, which confines the program operations to their permitted memory">
Elias: Right. They take the whole PHP interpreter and create this abstract machine model to define exactly what’s allowed—the frame property and sharing integrity—and then they prove that their Rust translation of a core part of it follows those exact rules <ref:2611.32477#pg5, "We then formally prove that every transition of the abstract machine satisfies the frame property and sharing integrity">
Priya: So to put it simply, they’re building a blueprint for what PHP *should* be doing at a memory level and then showing that their Rust code doesn't violate those blueprints <ref:2611.32477#pg8, "every execution admitted by M is PHP memory-model safe">
Nadia: Exactly. It’s not just about preventing a crash; it’s about ensuring the program stays within its intended operational boundaries for every single memory operation <ref:2611.32477#pg4, "The frame property and sharing integrity define logical memory safety for PHP">
Elias: And they showed this works on a core part of PHP five point zero.zero which is a lot of code to handle—about 37K lines—and they managed to keep the performance overhead down to fifteen percent compared to the original C version <ref:2611.32477#pg2, "Our protection comes with a modest runtime overhead of 15% on the PHP performance benchmark">
Priya: Fifteen percent is low enough that it should be practical for most web applications, but what about the real-world risk? They fixed one hundred seventy-three memory bugs found in PHP five point zero <ref:2611.32477#pg1>.zero <ref:2611.32477#pg18, "The paper confirms that all of these bugs were fixed during PHP’s history">
Nadia: Those one hundred seventy-three bugs are specific things that could have caused native memory corruption or logical errors like using stale data <ref:2611.32477#pg3, "Logical memory violations happen frequently in our collected memory vulnerabilities">
Elias: The main thing is that they showed their safe Rust version handles all those vulnerability triggers without any native crashes or logic violations appearing on the inputs we tested <ref:2611.32477#pg10, "After analyzing the memory access behavior of our Rust PHP engine, we find no native memory violations or logic memory violations on these vulnerability-triggering inputs">
Priya: That’s good for security testing, but what does this mean for the average person using PHP? Does it make their code instantly bulletproof against all kinds of attacks?
Nadia: It means that if you are using a core fragment of PHP five point zero.zero you can be confident that the underlying engine is much safer than it used to be because it’s formally verified against these logical constraints <ref:2611.32477#pg9, "We then formally prove that every transition of the abstract machine satisfies the frame property and sharing integrity">
Elias: But there's a catch, as they state in their conclusion—rewriting to safe Rust stops native memory issues but it doesn't eliminate security-relevant logical errors in how you structure your program state <ref:2611.32477#pg14>.
Priya: So they’re trading one type of failure for another—native crashes for logic bugs—but they're putting a formal fence around the whole system to make those logic bugs much harder to find <ref:2611.32477#pg14>.
The paper's summary: Nadia: So we're looking at how this paper fixes PHP's deep memory safety issues by introducing logical memory safety, which is basically an extra rule set on top of standard memory protection <ref:2611.32477#pg1, "To prevent such failures, we introduce logical memory safety, which confines the program operations to their permitted memory">
The paper's improvements: Nadia: So we're wrapping up this discussion on "A Star is Reborn: The PHP Interpreter Rewritten in Safe Rust", which is about using formal proofs to make a core part of the PHP interpreter safe by adding logical memory safety <ref:2611.32477#pg1, "To prevent such failures, we introduce logical memory safety, which confines the program operations to their permitted memory">
Elias: Yeah. The main thing is that they used an abstract machine model to define these rules and then formally proved that their Rust code respected those rules for a core fragment of PHP five point zero.zero <ref:2611.32477#pg9, "We then formally prove that every transition of the abstract machine satisfies the frame property and sharing integrity">
Priya: From what I’ve seen, it’s a solid step in making sure we trust these massive pieces of software more easily by giving us a verifiable guarantee beyond just native memory safety <ref:2611.32477#pg14>
Nadia: Exactly. It shows that for long-running interpreted systems, you can formally verify higher-level properties like sharing integrity alongside the native memory guarantees <ref:2611.32477#pg8>.
Elias: And they did it by showing how their translation refines the abstract model using tools like Verus to mechanize that proof <ref:two thousand six hundred eleven point three two four seven seven#pg5, "We then formally prove that a core part of the interpreter engine in our concrete Rust implementation refines one the abstract PHP model and mechanize the proof through Verus">
Nadia: It means you get that extra layer of logical memory safety for the parts of the interpreter they covered, which handles those one hundred seventy-three old vulnerabilities <ref:2611.32477#pg18, "The paper confirms that all of these bugs were fixed during PHP’s history">
Nadia: We’re definitely going to keep an eye on how they extend this machine model concept to other languages and interpreter architectures in the future <ref:2611.32477#pg5, "We then formally prove that every transition of the abstract machine satisfies the frame property and sharing integrity">
Conclusion: Nadia: We're starting with the paper "A Star is Reborn: The PHP Interpreter Rewritten in Safe Rust". This is about taking that old C PHP interpreter, which powers most of the web, and rewriting it in safe Rust.
Elias: And they introduce this concept called logical memory safety. It’s not just fixing native errors; it’s about confining operations to permitted memory using an abstract machine model <ref:2611.32477#pg1, "To prevent such failures, we introduce logical memory safety, which confines the program operations to their permitted memory">
Priya: Logical memory safety sounds like a layer on top of regular safety, but what does that actually mean for how the program manages its data?
Nadia: It means they're building an abstract PHP machine model to capture how values are managed inside PHP while ignoring all the messy functionality details for a moment.
Elias: That model defines this property by focusing on two things: the frame property and sharing integrity. The frame property deals with read and write confinement, meaning state changes have to happen in permitted regions, and sharing integrity
Tianyu Li, Bo Wang, Prateek Saxena, Umang Mathur
National University of Singapore
cs.CR
Submitted: 2026-11-24
Updated: 2026-11-24
Code: https://github.com/poststatus/wptest
Project page: https://w3techs.com/technologies/overview/programming_language
License: http://arxiv.org/licenses/nonexclusive-distrib/1.0/
Importance score: 99/100
The gist: PHP powers most of the web, yet its C interpreter has had many memory-safety vulnerabilities.<ref:2611.32477#pg1, "PHP powers most of the web…
Key concepts
- Logical Memory Safety
- This is an additional layer of protection beyond native memory safety. It ensures program operations are strictly confined to permitted memory regions by enforcing two properties: the frame property (restricting state changes) and sharing integrity (preventing unintended data sharing).
- Abstract PHP Machine Model
- This is a formal model used to describe how the PHP interpreter manages program values. It abstracts away implementation details, defining memory states as VSlots, VStores, and HStores. This model provides the mathematical foundation for proving that any execution admitted by it is memory-model safe.
- Refinement Proofs
- These are formal mathematical proofs used to transfer safety guarantees from the abstract machine model to the concrete Rust implementation. The proof verifies that every transition in the actual Rust code satisfies the abstract properties (like frame property and sharing integrity), mechanizing verification through tools like Verus.
Terminology
Summary
PHP powers most of the web, yet its C interpreter has had many memory-safety vulnerabilities. p. 0<ref:2611.32477#pg1, "PHP powers most of the web, yet its C interpreter has had many memory-safety vulnerabilities">To prevent such failures, we introduce logical memory safety, which confines the program operations to their permitted memory. p. 0<ref:2611.32477#pg1, "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. p. 0<ref:2611.32477#pg1, "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. p. 00.0 engine in safe Rust, and formally prove that, for a core fragment of PHP, our Rust translation refines the abstract PHP machine. p. 0<ref:2611.32477#pg2>Our translation safely handles all 173 memory vulnerabilities we collected that affect PHP 5. p. 00.0 prior to the rewrite. p. 0<ref:2611.32477#pg2>The Rust version matches the C implementation on all functionality tests, and produces identical outputs for the real-world PHP applications we evaluate. p. 0<ref:2611.32477#pg2>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. p. 0<ref:2611.32477#pg2>The improved security comes at a modest average runtime overhead of only 15% compared to C. p. 0<ref:2611.32477#pg2>
Pruning redundant reasoning tokens
The paper introduces logical memory safety as an additional layer of guarantees beyond native memory safety.<ref:2611.32477#pg3>This property is derived from PHP's memory semantics by defining frame property and sharing integrity.<ref:2611.32477#pg4, "We therefore derive logical memory safety for PHP from PHP memory semantics, focusing on these two aspects of interpreter operations">Logical memory safety requires enforcing two properties: the frame property and sharing integrity. p. 3<ref:2611.32477#pg4, "The frame property and sharing integrity define logical memory safety for PHP">The frame property includes read confinement and write confinement to restrict state changes to permitted regions. p. 3<ref:2611.32477#pg4, "For each transition s a−→ s′, we require: Read confinement: Changing the state outside the region reachable from a’s operands must not affect the transition’s result or its permitted effects">Sharing integrity constrains memory accesses and modifications by ensuring no unintended sharing or stale sharing occurs. p. 3<ref:2611.32477#pg4, "A transition must not introduce sharing relationships its operation does not permit. p. 3 No stale sharing: A transition must remove sharing relationships that its operation requires it to remove">The abstract PHP machine model is a labeled transition system defining memory states as VSlots, VStores, and HStores. p. 3<ref:2611.32477#pg6>The model specifies operations such as ASSIGN and BIND which define how memory state transitions occur. p. 3<ref:2611.32477#pg7>Theorem 1 establishes that every execution admitted by M is PHP memory-model safe. p. 7<ref:2611.32477#pg8, "every execution admitted by M is PHP memory-model safe">
How the training signal is built
The paper constructs a refinement proof to transfer the abstract machine's safety guarantees to the concrete Rust implementation.<ref:2611.32477#pg5, "We then formally prove that every transition of the abstract machine satisfies the frame property and sharing integrity">This involves mapping concrete Rust states to abstract PHP states while preserving PHP visible observations. p. 4<ref:2611.32477#pg9>The proof uses Verus to mechanize the verification of the refinement relationship. p. 7<ref:2611.32477#pg5, We then formally prove that a core part of the interpreter engine in our concrete Rust implementation refines [1] the abstract PHP model and mechanize the proof through Verus
>The verification scope focuses on execution stages, assuming the PHP compiler correctly compiles source scripts into correct opcode sequences.<ref:2611.32477#pg9>
Where the gains come from
Performance improvements are achieved through design choices that optimize operand reading and manage memory allocation differently than in C.<ref:2611.32477#pg12>String operations cost 18% run-time overhead in the Rust translation because of memory management design. p. 0<ref:2611.32477#pg12>References and objects carry the main slowdown due to how reference marking is handled differently in Rust. p. 8<ref:2611.32477#pg12>The overhead of run-time checks on the Rust language contributes to a modest 15% overall runtime overhead. p. 0<ref:2611.32477#pg12, "Our protection comes with a modest runtime overhead of 15% on the PHP performance benchmark">
Evaluation I: Safety
The evaluation confirms that the safe Rust translation behaves safely on all collected memory-related vulnerabilities.<ref:2611.32477#pg10, "After analyzing the memory access behavior of our Rust PHP engine, we find no native memory violations or logic memory violations on these vulnerability-triggering inputs">Logical memory violations happen frequently in our collected memory vulnerabilities. p. 9<ref:2611.32477#pg10, "Logical memory violations happen frequently in our collected memory vulnerabilities">The Rust translation behaves gracefully on all of these vulnerability-triggering inputs with no panic. p. 9<ref:2611.32477#pg10, "The Rust translation behaves gracefully on all of these vulnerability-triggering inputs with no panic">
Evaluation II: Performance
The runtime overhead is modest, showing an average of only 15% compared to C on the PHP performance benchmark.<ref:2611.32477#pg10>This overhead stems mainly from design and implementation choices rather than inherent language constraints.<ref:2611.32477#pg12, "The overhead seems mainly from design and implementation choices, with a small part due to Rust’s runtime checks">
Evaluation III: Functionality
The safe Rust translation behaves identically to the C PHP engine on 585 of 585 requests.<ref:2611.32477#pg10>Our approach improves security while preserving functionality by matching execution results byte by byte. p. 3<ref:2611.32477#pg10>
Conclusion
Rewriting programs in safe Rust eliminates native memory-safety violations but does not necessarily prevent security-relevant logical errors in managing the program’s state.<ref:2611.32477#pg14>We propose logical memory safety as an additional layer of guarantees beyond native memory safety. p. 3 p. 3<ref:2611.32477#pg14>We instantiate this guarantee for PHP by formally defining the abstract PHP machine. p. 1 p. 1<ref:2611.32477#pg14>We translate PHP 5. p. 00.0 to fully safe Rust, and establish these properties using refinement-based verification for a core fragment of our implementation. p. 7<ref:2611.32477#pg14, "We translate PHP 5. p. 00.0 to fully safe Rust, and establish these properties using refinement-based verification for a core fragment of our implementation">
Appendix A
The work investigates improving the memory safety of the existing C PHP interpreter by translating it into safe Rust.<ref:2611.32477#pg14>We propose logical memory safety and formally verify the resulting Rust translation against this property. p. 4 p. 4<ref:2611.32477#pg14>
Appendix B
The implementation covers roughly 115,000 lines of C code and produces 77,000 lines of safe Rust.<ref:2611.32477#pg16, "In total, our translation covers roughly 115K lines of C code in the C PHP 5. p. 9 p. 90.0, and produces 77K lines of code in safe Rust">The translation uses six direct dependencies that support storage management, regular expressions, and compression. p. 9 p. 9<ref:2611.32477#pg16>
Appendix C
The corpus consists of 173 memory bugs in PHP 5.0.0.<ref:2611.32477#pg17>These bugs are categorized into native memory corruptions and PHP memory semantic errors. p. 2<ref:2611.32477#pg18>The paper confirms that all of these bugs were fixed during PHP’s history. p. 0<ref:2611.32477#pg18>
Appendix D
The abstract machine formally defines storage relationships as VSlots, VStores, and HStores.<ref:2611.32477#pg6>Definition 3 formalizes logical memory safety using frame property and sharing integrity. p. 6<ref:2611.32477#pg8>The transition rules are formalized in Definition 3 and Theorem 1 which proves abstract-machine safety. p. 6<ref:2611.32477#pg8>
Appendix E
Case study on recent PHP vulnerabilities shows that the use-after-free can be prevented in the safe Rust translation.<ref:2611.32477#pg18, "The use-after-free comes from a global variable that outlives the memory it points to">This demonstrates that our translation runs safely on the same trigger path, with no native memory corruption. p. 2<ref:2611.32477#pg18, "On the same trigger path (two consecutive requests), the translation runs safely, with no native memory corruption">
Appendix F
The work builds on research in C-to-Rust translation and formal verification of language interpreters.<ref:2611.32477#pg9>We focus on establishing an additional, interpreter-specific safety guarantee beyond native memory safety. p. 3 p. 3<ref:2611.32477#pg14>
Appendix G
The work focuses on specifying and verifying that a core fragment of our safe-Rust reimplementation refines the abstract machine.<ref:2611.32477#pg9>This approach addresses both native and logical memory violations in our translated PHP interpreter. p. 0<ref:2611.32477#pg9>
Rewriting programs in safe Rust eliminates native memory-safety violations but does not necessarily prevent security-relevant logical errors in managing the program’s state.<ref:2611.32477#pg14>We propose logical memory safety as an additional layer of guarantees beyond native memory safety.<ref:2611.32477#pg14>We instantiate this guarantee for PHP by formally defining the abstract PHP machine.<ref:2611.32477#pg14>The work builds on research in C-to-Rust translation, memory safety, and formal verification of language interpreters. p. 9<ref:2611.32477#pg9>We focus on establishing an additional, interpreter-specific safety guarantee beyond native memory safety.<ref:2611.32477#pg14>The work focuses on specifying and verifying that a core fragment of our safe-Rust reimplementation refines the abstract machine. p. 0 p. 0 p. 0 p. 0<ref:2611.32477#pg9>The approach addresses both native and logical memory violations in our translated PHP interpreter. p. 0 p. 0 p. 0 p. 0<ref:2611.32477#pg9>The work builds on research in C-to-Rust translation, memory safety, and formal verification of language interpreters. p. 9 p. 9 p. 9<ref:2611.32477#pg9>The focus is establishing an additional, interpreter-specific safety guarantee beyond native memory safety. p. 3 p. 3 p. 3<ref:2611.32477#pg14>The work focuses on specifying and verifying that a core fragment of our safe-Rust reimplementation refines the abstract machine.<ref:2611.32477#pg9>The approach addresses both native and logical memory violations in our translated PHP interpreter.<ref:2611.32477#pg9>The work builds on research in C-to-Rust translation, memory safety, and formal verification of language interpreters.<ref:2611.32477#pg9>The focus is establishing an additional, interpreter-specific safety guarantee beyond native memory safety.<ref:2611.32477#pg14>The work focuses on specifying and verifying that a core fragment of our safe-Rust reimplementation refines the abstract machine.<ref:2611.32477#pg9>The approach addresses both native and logical memory violations in our translated PHP interpreter.<ref:2611.32477#pg9>The work builds on research in C-to-Rust translation, memory safety, and formal verification of language interpreters.<ref:2611.32477#pg9>The focus is establishing an additional, interpreter-specific safety guarantee beyond native memory safety.<ref:2611.32477#pg14>The work focuses on specifying and verifying that a core fragment of our safe-Rust reimplementation refines the abstract machine.<ref:2611.32477#pg9>The approach addresses both native and logical memory violations in our translated PHP interpreter.<ref:2611.32477#pg9>
This work investigates improving the memory safety of the existing C PHP interpreter by translating it into safe Rust.<ref:2611.32477#pg14>We propose logical memory safety and formally verify the resulting Rust translation against this property.<ref:2611.32477#pg14>
The implementation covers roughly 115,000 lines of C code and produces 77,000 lines of safe Rust.<ref:2611.32477#pg16, "In total, our translation covers roughly 115K lines of C code in the C PHP 5.0.0, and produces 77K lines of code in safe Rust">The translation uses six direct dependencies that support storage management, regular expressions, and compression.<ref:2611.
Green — the paper says it, and the page is printed. Red — no passage carries it, so treat that sentence as unverified. The same check runs on your own text: check a summary against its source, $5.
Improvements for AI systems
-
Logical memory safety guarantees prevent unintended accesses to logical memory of translated programs by confining program operations to permitted memory, which is formalized through an abstract PHP machine model that captures how PHP interpreter manages program values while abstracting away functionality details.
-
The improved AI system can eliminate native memory violations and logical memory violations for core fragments of the PHP interpreter by refining the abstract PHP machine with a core fragment of a concrete Rust implementation, establishing logical memory safety via formal proofs in Verus.
-
The system can safely handle all 173 historically known memory-related vulnerabilities affecting C PHP 5.0.0, ensuring
no native memory violations or logical memory violations
occur on those vulnerability-triggering inputs during execution in the Rust version. -
The system preserves PHP functionality across a substantial set of tests, producing
byte-identical outputs
to the C PHP engine on 8 evaluated applications and all 1,143 standalone PHP tests, ensuring functional compatibility. -
The system achieves a modest average runtime overhead of only 15% compared to C on the PHP performance benchmark, indicating that the improved security comes at a low performance cost.
Sources
- Fuzzing the PHP Interpreter via Dataflow Fusion
- Adversarial Agent Collaboration for Correctness Improvements of C to Safe Rust Translation
- C2SaferRust: Transforming C Projects into Safer Rust with NeuroSymbolic Techniques
- Mostly Automatic Translation of Language Interpreters from C to Safe Rust
Related papers
- RustMizan: A Compilable, Contamination-Aware Benchmarking Framework for Rust Vulnerabilities
- Introducing the Generative Application Firewall (GAF)
- Opal: Private Memory for Personal AI
- Fuel as Identity: Authenticating Inter-Satellite Laser Links after Total Key Compromise
- Merkle Trees Minimize Verifier Complexity in the ROM
- VulCPE: Context-Aware Cybersecurity Vulnerability Retrieval and Management