PHP <= 5.3.2 ext/phar/stream.c和ext/phar/dirstream.c文件多个格式串漏洞

来源:岁月联盟 编辑:老鹰 时间:2010-05-18

影响版本:
PHP <= 5.3.2

漏洞描述:
BUGTRAQ  ID: 40173

PHP是广泛使用的通用目的脚本语言,特别适合于Web开发,可嵌入到HTML中。

PHP的ext/phar/stream.c文件中内部所使用的phar_stream_flush()、phar_wrapper_unlink()、 phar_parse_url()、phar_wrapper_open_url()函数以及ext/phar/dirstream.c文件中内部所使用的phar_wrapper_open_dir()函数在处理出错情况时存在格式串漏洞。在出现错误的情况下会将error变量用作格式串来调用 php_stream_wrapper_log_error()函数。由于出错消息中可以包含有用户输入,这允许攻击者执行各种格式串攻击,如通过%08x的信息泄露或通过%n的内存破坏。

<*参考
Stefan Esser (s.esser@ematters.de)

链接:http://php-security.org/2010/05/14/mops-2010-028-php-phar_wrapper_open_url-format-string-vulnerabilities/index.html
http://php-security.org/2010/05/14/mops-2010-027-php-phar_parse_url-format-string-vulnerabilities/index.html
http://php-security.org/2010/05/14/mops-2010-026-php-phar_wrapper_unlink-format-string-vulnerability/index.html
http://php-security.org/2010/05/14/mops-2010-025-php-phar_wrapper_open_dir-format-string-vulnerability/index.html
http://php-security.org/2010/05/14/mops-2010-024-php-phar_stream_flush-format-string-vulnerability/index.html
*>

测试方法:
$ php -r "fopen('phar:///usr/bin/phar.phar/*%08x-%08x-%08x-%08x-%08x-%08x-%08x

安全建议:
厂商补丁:

PHP
---
目前厂商已经发布了升级补丁以修复这个安全问题,请到厂商的主页下载:

http://svn.php.net/viewvc?view=revision&revision=298667