-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PATH_INFO when not $fastcgi_path_info #8
Comments
Hi, Many thanks for the detailed report! It looks like PATH_INFO is set in I will be able to look into it tomorrow evening I guess. If you want, you can use the reproducer docker to try it yourself before that. |
Hi again, As I suspected, it's the location regexp that doesn't allow any newlines. If there's a newline character inside the URL path, the location regexp is not matched (the same way as in However, I think there're some chances we can trigger the underflow in a different way. Modern php-fpm doesn't allow files with arbitrary extensions to be executed as a script, but the check comes after the request initialization completed, meaning that PHP_VALUE may be set. So, if you have a file without .php extension under However, it would be much harder to get an RCE because php.ini options must be even shorter than in #1 because of additional So, my questions are:
|
Hi,
There are no non-php files in the level of /foobar root. Alongside the
Obviously RCE is worse but wanted to just work out if with the config supplied above, whether it's vulnerable in any form. Thanks for all the information! |
I get the PHP FPM 'Access Denied' at the path I think I will assume it is still vulnerable in some way with the config supplied. Thanks again. |
That will work too.
Yes, that's the expected behavior. At the php code, the underflow happens here (the As you can see, all we need to trigger the vulnerability is to have In your configuration, we can achieve the same by sending Considering the fact that your configuration looks very uncommon, I don't think I will add something to the exploit about this. However, I wrote a simple script that should help you confirm you're vulnerable: import requests
import sys
if __name__ == "__main__":
base_url = sys.argv[1]
rl = 16 # not sure, should be between 10 20
for qsl in range(1500, 2000, 5):
url = f"{base_url}/{'A'*rl}.php/a?{'B'*qsl}"
if requests.get(url).text != "Access denied.\n":
print(f"Found qsl = {qsl}, check php-fpm log for a segfault message")
break
else:
print("Not vulnerable") Run it like
meaning that a php-fpm worker had a segfault. Thanks again for an interesting case! I think that RCE might possible, but it requires some research. P.S. Sorry if the references to php sources don't make anything clear. I still trying to find inspiration to write a proper writeup. |
Thanks for the script! I confirmed SIGSEGV on my PHP 7 hosts with that script, despite those vhosts also having On the PHP5 instances, it still wouldn't SIGSEGV or report vulnerable, presumably because still using the same exploit method as per your README. I'll close this out, cheers |
Hi,
I've been trying to use your PoC against an Nginx vhost that contains this snippet:
I can't seem to reproduce it hitting http://example.com/foobar/index.php or http://example.com/foobar/module.php/modules/index.php (there are PHP files in both these locations). All my attempts yield an Nginx 404. There is no
try_files
within thislocation
block.Would you agree that the above is somehow not exploitable? I am not sure why, wondering if it's because of the use of the
$pathinfo if_not_empty
instead of$fastcgi_path_info
, or perhaps it's the location regex?P.S the
/etc/nginx/fastcgi_params
that gets included, looks like this. Note there is a PATH_INFO in there too but I think it gets overwritten by the subsequentfastcgi_param PATH_INFO $pathinfo if_not_empty
in the location block?Thanks!
The text was updated successfully, but these errors were encountered: