PHP Development Server <= 7.4.21 Remote Source Disclosure
The PHP built-in development server mishandled pipelined HTTP requests, causing it to serve the source code of a PHP file as a static file instead of executing it. An attacker could read the source code of PHP scripts, potentially exposing sensitive information.
projectdiscovery.io
Published on projectdiscovery.io
While testing request pipelining on multiple programming language built-in servers, we observed strange behavior with PHP’s. As we delved deeper, we discovered a security bug in PHP that could expose the source code of PHP files as if they were static files rather than executing them as intended.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely a state confusion: when two requests are sent together, the server checks the file extension of the second request but opens the file path saved from the first request, so it treats a PHP file as static.
Impact
An attacker could read the source code of PHP files, which may contain sensitive information such as credentials or logic. The text notes that the vulnerability was not exploitable when the server was behind NGINX or Apache.
What the attacker needed
PHP development server version <= 7.4.21; Ability to send pipelined HTTP requests; No reverse proxy blocking the requests
The fix
The issue was fixed in PHP 7.4.22 by adding a check that prevents parsing a second request path if the vpath is already set.
How it was found
- Send a first HTTP request for a PHP file without a Content-Length header.
- Immediately send a second HTTP request for a directory or non-PHP path in the same connection.
- The server processes both requests and serves the PHP file as a static file, revealing its source code.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
The PHP development server is a simple web server used for testing. It normally runs PHP files and sends only the output. A bug made it sometimes send the raw PHP code instead, so anyone could read the code and any secrets in it.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.