123 points · by ecaron · 14y ago · 59 comments
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.
<insert immense sigh of relief>. Thank God.
That said, some blackhats are going to be really sore that a backdoor that's been wide open for "at least 8 years" is finally being closed.
The vulnerability can only be exploited if the HTTP server follows a fairly obscure part of the CGI spec. Apache does this, but many other servers do not.
From: http://eindbazen.net/2012/05/php-cgi-advisory-cve-2012-1823/
It took me a bit to figure out _how_, but it's nothing obscure or difficult. In fact it relies on _other_ bozotic PHP behavior to work!
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
<?php
...
?>
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 somebody at
some point must have had a reason for disallowing this.
Perfectly illustrating the utility of well-chosen comments in code.<?php
include_once 'https://www.facebook.com/careers/department?dept=engineering...;
> [...] we had a bug in our bug system [...] causing this issue to go public before we had time to test solutions to the level we would like.
Ouch.
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?
2) Running PHP as regular CGI (not FCGI) is a very dated practice so the amount of implementations that are vulnerable is probably limited.
It maybe an old mechanism, but it is fast, which is worth something these days :)
On the other hand, this does make me feel better about my own code!
Then I asked on SO and found out I was doing things horribly, horribly wrong.
http://example.com/cgi/mything?stuff
Results in apache calling: /home/ajf/cgi/mything stuffhttps://www.google.com/search?q=inurl:%22cgi-bin%22+inurl:ph...
www.ptecwebdev.com?-s
Although to be honest I doubt it's going to affect anyone as I reckon 99%+ are on mod_php.