November 15, 2026
All You Need to Know About PHP2Shell:Part 2 Vol 1: From Exploit to Root Cause: The 4-Step RIWVβ¦
All You Need to Know About PHP2Shell:Part 2 Vol1: From Exploit to Root Cause: The 4-Step RIWV Method

By Albert Lab
2 min read
In Part 1, we built a reproducible PHP2Shell debugging lab with Docker, DWARF symbols, and LLDB. Now that the exploit works and we can step through PHP's source code, it's time to answer a more interesting question: why does it work?
What You'll Learn
In this article, I'll use a simple vulnerability analysis workflow that I call RIWV.
It consists of four steps:
- R β Reproduce: Reproduce the vulnerability in a controlled environment.
- I β Inspect: Examine the program state at the exploit's critical point-the crime scene.
- W β Work Backwards: Reconstruct the causal chain that led to the vulnerability, not just the call stack.
- V β Validate: Test the root cause hypothesis against source code and runtime evidence.
We'll apply RIWV to PHP2Shell, starting from a working exploit and gradually working our way back to the underlying vulnerability.
By the end, you'll not only understand what makes PHP2Shell possible, but also have a practical workflow you can apply to other known vulnerabilities.
The Crime Scene
We've already completed the first step-Reproduce-in Part 1.
Now let's move on to Inspect.
From the exploit script, we know zif_system() is called to execute the payload, let us try to set a breakpoint on zif_system(). Below is a screenshot when zif_system() is hit during exploit execution: (NOTE: if you are curious why windbg command sytax works in my lldb, that is because I am using my own WinLLDB, https://github.com/albertlab0/WinLLDB , an extension to support windbg command syntax)
From this "crime scene", we notice that zif_system() with the first argument execute_data (type zend_execute_data) leads to the final payload execution via system() call.
Let us dive into the first parameter execute_data.
execute_data structure size is 0x50 bytes. At offset 0x20+0xc This.u2.num_args = 1. which means it has 1 parameter.and after that, The parameter is defined by ZEND_CALL_ARG, the arguments infomration.
So ZEND_CALL_ARG(call, 1) expands to:
ZEND_CALL_VAR_NUM(call, 0) ((zval*)(call)) + ZEND_CALL_FRAME_SLOT ZEND_CALL_FRAME_SLOT = sizeof(zend_execute_data) / sizeof(zval) = 80 / 16 = 5 Which gives: (zval*)call + 5 = call + 5Γ16 = call + 0x50
Each parameter's type is zend_value:
That's why arg1 lives at execute_data+0x50 in the diagram β it's the first zval slot right after the 80-byte zend_execute_data frame. The first argument is type is IS_STRING(6), and the string value is at 0x60, a structure of zend_string.
Let us dump it to see whether it matchefs our payload string:
Below is the full memory layout of the crafted execute_data
Eventually, zif_system() ends up with calling system() and execute the payload.
To be continued.
Originally published at http://chunfeng.io on November 15, 2026.