Add 'multipart_uri_whitelist' INI option to control which URL paths are allowed to submit multipart body#21118
Add 'multipart_uri_whitelist' INI option to control which URL paths are allowed to submit multipart body#21118chopins wants to merge 32 commits intophp:masterfrom
Conversation
sync master
sync master
sync master
sync master
sync master
|
Seems more like a webserver responsibility, but I'll let Jakub be the judge of that. |
The issue that PHP automatically saves uploaded files to temporary files should still be addressed. |
|
The exploit will work as long as there is at least one URL on which file uploads are allowed, so I think that a whitelist is not the right approach. You would need to disable file uploads entirely, or to make sure that whitelisted URLs are not accessible (but then the same layer than controls access can also disable uploads). One way to make the exploit ineffective would be to obfuscate/encrypt session files: #3759 @devnexen. This can also be implemented with a custom SessionHandler: https://externals.io/message/117740#117748. With the caveat that the arbitrary file upload vulnerability would likely allow the attacker to disclose the encryption key. There are other ways to exploit these vulnerabilities without controlling a local or remote file: https://blog.lexfo.fr/wrapwrap-php-filters-suffix.html. This relies on |
|
In terms of alternative approaches, there's also the |
This function cannot independently control requests of type multipart/form-data; files are still uploaded after using it. |
|
@iluuu1994 |
Currently, in PHP, users can upload files to the server under any circumstances, even if the PHP script does not include file upload handling.
This not only unnecessarily increases server bandwidth usage but also introduces the security risk of arbitrary file uploads to the server. like : hitcon-ctf-2018-one-line-php-challenge.
So add multipart_uri_whitelist PHP_INI_PERDIR ini option to Allow file uploads only from whitelisted paths.