Live data from Hacker News

New PHP Vulnerability:?-s may expose source code for mod_cgi

php.net

41–50 of 65 posts

Re: New PHP Vulnerability:?-s may expose source code for mod_cgi

#41
post #40

From the commit that introduced this bug: The point of the question here is if anybody remembers why we decided not to parse command line args for the cgi version? I could easily see it being useful to be able to write a cgi script like: #!/usr/local/bin/php-cgi -d include_path=/path and have it work both from the command line and from a web context. As far as I can tell this wouldn't conflict with anything, but some…

Thanks for digging that up, it's indeed a very strong example in favor of good comments.

Re: New PHP Vulnerability:?-s may expose source code for mod_cgi

#42

This vulnerability is about as bad as it gets, and my heart stopped while I was reading the intro (it's so trivially simple to compromise a site). Then I reached this sentence, which I felt needed to be bolded and underlined: A large number of sites run PHP as either an Apache module through mod_php or using php-fpm under nginx. Neither of these setups are vulnerable to this. . Thank God. That said, some blackhats ar…

Anyone using a php CGI app could easily have more serious problems than source code disclosure. Those kinds of apps have often been around over a decade with little or no modifications or auditing, because if someone cared enough about the apps to maintain or audit them it's likely they'd have moved to a more performant backend.

Re: New PHP Vulnerability:?-s may expose source code for mod_cgi

#43

Earlier quoted context omitted.

Yeah, but nobody's run PHP in this silly CGI configuration for 10 years.

Dutch ISP KPN actually has a hosting service that runs PHP primarily in CGI mode: https://www.google.com/#hl=en&output=search&sclient=... yields a massive amount of vulnerable sites.

So many databases credentials in the open... it must like Christmas for black-hat German hackers!

Re: New PHP Vulnerability:?-s may expose source code for mod_cgi

#45
post #34
post #27

From Twitter: Stefan Esser ‏ @i0n1c The security emergency release to fix the PHP CGI RCE (that was tested for days...) does not fix anything at all.

Here is the fix that was applied: https://github.com/php/php-src/commit/55869a95ab75c0eb99c572... If the first char in the query string is "-" and the query string also contains "=", it skips cmdline argument option parsing. Maybe it is possible to construct a string not starting with "-", not containing "=", but containing a "+" followed by "-options" further out?

No, the problem is that they check the decoded query string for `=` signs, but Apache checks the raw query string. If you pass an encoded `=` anywhere in the query string then you can bypass the fix.

Re: New PHP Vulnerability:?-s may expose source code for mod_cgi

#46
post #40

From the commit that introduced this bug: The point of the question here is if anybody remembers why we decided not to parse command line args for the cgi version? I could easily see it being useful to be able to write a cgi script like: #!/usr/local/bin/php-cgi -d include_path=/path and have it work both from the command line and from a web context. As far as I can tell this wouldn't conflict with anything, but some…

In addition, it illustrates the utility of well-written commit messages with judicious use of the blame utility.

Re: New PHP Vulnerability:?-s may expose source code for mod_cgi

#47
post #35

Earlier quoted context omitted.

FastCGI makes little to no sense on shared web hosting machines. With FastCGI, each user on the machine needs at least one long-running process to handle requests. This is a waste when you consider that large numbers of the sites may be idle 99% of the time. With CGI, you only have PHP processes running when they are actually handling requests, it's really a much better solution for shared hosting.

With PHP 5.3.9 or 5.3.10 and php-fpm a new method of process management called ondemand was introduced that handles this use care very well. With a super short idle timeout (a few seconds) this could work very well for shared hosting, but I doubt there are many folks using it since it does still require the process manager to stay running in order to start the workers (this makes it hard to have user configurable php…

You can send a signal to php-fpm to reload configuration without restarting (at least, the way I read it). My /etc/init.d/php-fpm has "reload" with `kill -USR2 $PHP_PID`

Re: New PHP Vulnerability:?-s may expose source code for mod_cgi

#48

Earlier quoted context omitted.

Yeah, but nobody's run PHP in this silly CGI configuration for 10 years.

Dutch ISP KPN actually has a hosting service that runs PHP primarily in CGI mode: https://www.google.com/#hl=en&output=search&sclient=... yields a massive amount of vulnerable sites.

[deleted]
Post reply on HN