PHP ZipArchive::getArchiveComment()空指针应用拒绝服务漏洞

漏洞起因
设计错误
危险等级

 
影响系统
PHP PHP 5.3.2
PHP PHP 5.3.1
PHP PHP 5.3
PHP PHP 5.2.13
PHP PHP 5.2.12
PHP PHP 5.2.11
PHP PHP 5.2.10
PHP PHP 5.2.9 -2
PHP PHP 5.2.9
PHP PHP 5.2.8
PHP PHP 5.2.7
PHP PHP 5.2.6
PHP PHP 5.2.5
PHP PHP 5.2.4
PHP PHP 5.2.3
PHP PHP 5.2.2
PHP PHP 5.2.1
PHP PHP 5.3.3
PHP PHP 5.2.14
PHP PHP 5.2
 
不受影响系统
 
危害
远程攻击者可以利用漏洞使PHP应用程序崩溃。
 
攻击所需条件
攻击者必须访问PHP应用程序。
 
漏洞信息
PHP是一款流行的编程语言。
ZipArchive库允许用户透明的读写ZIP压缩档案及其中的文件。PHP中所使用的ZipArchive::getArchiveComment函数:
– —
1945     static ZIPARCHIVE_METHOD(getArchiveComment)
1946     {
1947     struct zip *intern;
1948     zval *this = getThis();
1949     long flags = 0;
1950     const char * comment;
1951     int comment_len = 0;
1952    
1953     if (!this) {
1954     RETURN_FALSE;
1955     }
1956    
1957     ZIP_FROM_OBJECT(intern, this);
1958    
1959     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags)
== FAILURE) {
1960     return;
1961     }
1962    
1963     comment = zip_get_archive_comment(intern, &comment_len,
(int)flags); <==== RETURN NULL AND -1
1964     RETURN_STRINGL((char *)comment, (long)comment_len, 1); <===== NULL
POINTER DEFERENCE HERE
1965     }
– —
此方式从zip_get_archive_comment()函数返回字符串。而在如下函数中:
– —
40     ZIP_EXTERN(const char *)
41     zip_get_archive_comment(struct zip *za, int *lenp, int flags)
42     {
43     if ((flags & ZIP_FL_UNCHANGED)
44     || (za->ch_comment_len == -1)) {
45     if (za->cdir) {
46     if (lenp != NULL)
47     *lenp = za->cdir->comment_len;
48     return za->cdir->comment;
49     }
50     else {
51     if (lenp != NULL)
52     *lenp = -1; <===================== -1
53     return NULL; <==================== NULL
54     }
55     }
56    
57     if (lenp != NULL)
58     *lenp = za->ch_comment_len;
59     return za->ch_comment;
60     }
– —
52和53行应返回空指针和(int)-1。结果RETURN_STRINGL()会以如下方式运行:
RETURN_STRINGL(NULL, -1, 1);
在memcpy(3)中出现崩溃。
 
测试方法
 
厂商解决方案
用户可参考如下供应商提供的安全公告获得补丁信息:
http://svn.php.net/viewvc/php/php-src/branches/PHP_5_3/ext/zip/php_zip.c?view=log
http://svn.php.net/viewvc/php/php-src/branches/PHP_5_2/ext/zip/php_zip.c?view=log
 
漏洞提供者
Maksymilian Arciemowicz

发表评论?

0 条评论。

发表评论