æ¬å½ã« PHP ã® DoS èå¼±æ§ (CVE-2015-4024) ããããªãï¼
hakaikosen.hateblo.jp
ä¸è¨è¨äºãããã大å¤(æ£èªã¿)ãã¨ãæããªããèªãã§ããããã©ãPHP ã® BTS ã®æ¹ãèªãã§ã¿ãã確ãã«åçããåç¾æé ã¾ã§ç´°ããè¨è¼ããã¦ãã¦
ããªããããã¾ããããã¨æã£ãã®ã§ãdocker ã使ã£ã¦æ¤è¨¼ãã¦ã¿ããã¨ã«ã
PHP å ¥ãã® Docker ã³ã³ããã¯ãOfficial ã®ãã®ãå©ç¨ãã¾ãããregistry.hub.docker.com
ä»åã®èå¼±æ§ãPOST ããªããã¼ã¸ã«ã¯é¢ä¿ãªãã®ããªï¼ã¨æã£ã¦ã¾ããããããããè¦ã㨠PHP ããåããã¼ã¸ã§ããã°ãªãã§ããããããã
ã¨ãããã¨ã§ä»¥ä¸ã®ãã㪠PHP ãã¡ã¤ã«ãç¨æããããã«ã¢ã¯ã»ã¹ (æ»æ) ããã¾ãã
- htdocs/index.php
<!DOCTYPE html> <html> <head> <title>PHP Bugs #69364</title> </head> <body> Hello, World! </body> </html>
ãããã®éãæ¡å¼µåãã .php ã¨ãªã£ã¦ãããã®ã®ããã ã® HTML ã§ãã
æ»æå´ã®ã³ã¼ãã¯ä»¥ä¸ã®éããä»å㯠PHP ã®èå¼±æ§ãçªãããã« Perl ã§ããã¾ããæ·±ãæå³ã¯ããã¾ããã
BTS ãè¦ãã°ããã«åããããã©ã念ã®ããæ»æã®æ ¸å¿ã¨ãªãé¨åã¯ä¼ãã¦ããã¾ãã
- bin/attack.pl
#!/usr/bin/env perl use strict; use warnings; use feature qw/ say /; use Furl::HTTP; use Time::HiRes qw/ gettimeofday tv_interval /; sub attack { my $url = shift; my $body = "<<< ãããæ»æé¨å >>>"; my $furl = Furl::HTTP->new(agent => 'PHP-Bugs/69364', timeout => 100); my $start = [ gettimeofday ]; my @response = $furl->post($url, [ 'Content-Type' => 'multipart/form-data; boundary=xYzZY' ], $body); say 'Status: ', join(' ', $response[1], $response[2]); say 'Elapsed time: ', tv_interval($start); } attack($ARGV[0]) if scalar @ARGV == 1;
æºåãã§ããã docker ã³ã³ãããèµ·åãã¾ãã
ã¾ãã¯èå¼±æ§å¯¾å¿ãå®äºãã¦ãããææ°ã® PHP 5.6.9 ããã
$ docker run -d -v $PWD/htdocs:/var/www/html -p 8080:80 php:5.6.9-apache $ ./bin/attack.pl http://docker-vm:8080/ Status: 200 OK Elapsed time: 0.134595
ãªãã®åé¡ããªãã0.1 ç§ç¨åº¦ã§ã¬ã¹ãã³ã¹ãåã£ã¦ãã¾ããã
ç¶ãã¦èå¼±æ§ãæ®ã£ã¦ãã 5.6.8ã
$ docker run -d -v $PWD/htdocs:/var/www/html -p 8080:80 php:5.6.8-apache $ ./bin/attack.pl http://docker-vm:8080/ Status: 200 OK Elapsed time: 30.050448
ãªãã¨ã¬ã¹ãã³ã¹ã帰ã£ã¦ããã¾ã§ 30 ç§ãããã¾ããã
ãã®é CPU ã®ä½¿ç¨ç㯠100% ã«å¼µãä»ããè¦äºæ»æã«æåãã¾ããã
ã¡ãªã¿ã«ããµãã¼ããåãã¦ãã PHP 5.3 ã§ãåç¾ãããã¨ã確èªã§ãã¾ããã
$ docker run -d -v $PWD/htdocs:/var/www/html -p 8080:80 php:5.3-apache $ ./bin/attack.pl http://docker-vm:8080/ Status: 200 OK Elapsed time: 30.053104
ã¨ããããã§ãä»åã®èå¼±æ§ã¯ããããã® PHP ã®ãªã¯ã¨ã¹ããå¦çãããã¸ãã¯ã«åé¡ãããããããã¨ã POST ãå¦çããªããã¼ã¸ã§ãã£ã¦ãå±éºã ã¨ãããã¨ããããã¾ããã
ä»åã¯æå æ¸ãã¦ãªã¯ã¨ã¹ããéãã¾ãããããªã¯ã¨ã¹ãããããããå°ãå¶æªã«ãã¦ãã¹ã¬ããã»ããã»ã¹ã使ã£ã¦ããå¤ãã®ãªã¯ã¨ã¹ããéãã¤ããã°ãç°¡åã« DoS æ»æãæç«ããã®ã§ã¯ãªãã§ããããã
ããç°¡åã§ããï¼
ã£ã¦è©±ããä¼ç¤¾ã®äººã«ãããããµã¼ããã£ã¦ããæãã®è¿äºããã¦ãããã PHP ã®äººã¯éãããã¦ãããªãã¨æãã¾ããã
1ã¶æå¾ãããã«é¨ãã®ããªï¼ããã¨ãä½äºããªãã£ããã®ããã«æ²éåããã®ããªã