PHP5 Globals Vulnerability

简介: http://securityvulns.com/Ldocument219.html PHP5 Globals Vulnerability: with ?GLOBALS[foobar] yo...

http://securityvulns.com/Ldocument219.html

 PHP5 Globals Vulnerability: with ?GLOBALS[foobar] you can set the value of the un-initialized $foobar variable.

PHP5 Globals Vulnerability

Name              PHP5 Globals Vulnerability
Systems Affected  PHP5 (verified on 5.1.1 and 5.1.2)
Severity          Critical
Vendor            www.php.net
Advisory          http://www.ush.it/2006/01/25/php5-globals-vulnerability/
Author            Francesco "aScii" Ongaro (ascii at katamail . com)
Date              20060125

I. BACKGROUND

PHP is the well known widely-used general-purpose scripting language
that is especially suited for Web development and can be embedded
into HTML.

II. DESCRIPTION

Everybody knows the GLOBALS vulnerability, this is a serious bug and
can leak in a lot of different bugs in applications otherwise secure.

(Text from http://www.hardened-php.net/advisory_202005.79.html)
> In PHP5 < = 5.0.5 it is possible to register f.e. the global
> variable $foobar [..] by supplying a GPC variable called
> 慓LOBALS[foobar]?

As i was saying everybody knows this, except me : ) While conducing some
VA and code review on PmWiki i rediscovered this independently. More
details on this can be found in 揚mWiki Multiple Vulnerabilities?
(http://www.ush.it/2006/01/24/pmwiki-multiple-vulnerabilities/)

Trying to replicate the PmWiki bug on various PHP versions i discovered
it was in realty also a PHP bug (in fact the PmWiki bug itself is PHP
version dependent), but while it was supposed to affect only < = 5.0.5
we reproduced the same results in theorically safe PHP versions.

!! Note: There has been some updates, read the first comment! !!

Lately we produced a (22 bytes long) POC to test the PHP vulnerability
separately and we had the confirm that this bug is still here.

Will this advisory produce a third line in the changelog after these?

5.0.4 Fixed bug #31440 ($GLOBALS can be overwritten via GPC when
register_globals is enabled). (Ilia)

5.1.0 Fixed possible GLOBALS variable override when register_globals are
ON. (Ilia, Stefan)

If GLOBALS can override GLOBALS you could inject a variable into _POST
by _GET or set _SESSION['logged_in'] to TRUE by _GET, this is a bad
scenario for your uber-secured web application.

III. ANALYSIS

Check your own with this simple POC:

$ cat > foo.php < < EOF

<?php echo $foobar; ?>

EOF

Then query foo.php?GLOBALS[foobar]=HELLO

If the poc prints out HELLO your PHP version is vulnerable.

Here the results i collected:

Branch 4, register_globals ON: fixed and no effect
5.0.5 win, register_globals ON: affected, WORKS!
5.1.1 win, register_globals ON: affected, WORKS!
5.1.1 unix, register_globals ON: affected, WORKS!
5.1.2 unix, register_globals ON: affected, WORKS!

Testing needed on 5.1.0 and 4.x versions.

You can play around with this using some code like this:
<?php print_r($GLOBALS); ?>

IV. DETECTION

PHP 5.1.1 and 5.1.1 is vulnerable (this advisory).
PHP < = 4.3.10 should be vulnerable (bug discovered by Stefan Esser).
PHP <= 5.0.5 is vulnerable (bug discovered by Stefan Esser).
Older version not verified. PHP 5.1.0 not verified.

V. WORKAROUND

Register global off will fix. This PHP code will mitigate this bug.

// put this code before everything
if (isset($HTTP_POST_VARS['GLOBALS']) || isset($_POST['GLOBALS']) ||
   isset($HTTP_POST_FILES['GLOBALS']) || isset($_FILES['GLOBALS']) ||
   isset($HTTP_GET_VARS['GLOBALS']) || isset($_GET['GLOBALS']) ||
   isset($HTTP_COOKIE_VARS['GLOBALS']) || isset($_COOKIE['GLOBALS'])) {
trigger_error('Is this a GLOBAL GPC hacking attemp?', E_USER_ERROR);
}

For deeper fixage wait for an official patch.

VI. VENDOR RESPONSE

This is a known bug in PHP <= 5.0.5, that seems to be still effective
in PHP 5.1.1 and 5.1.2. I'll wait for official and Stefan Esser
responses.

!! Note: There has been some updates, read the first comment! !!

Note:

VII. CVE INFORMATION

No CVE at this time.

VIII. DISCLOSURE TIMELINE

20060119 Bug discovered
20060119 Internal release
20060125 Initial release (only on ush.it)
20060127 Initial release (only on sikurezza.org)
20060128 Public release

IX. CREDIT

Francesco "aScii" Ongaro is credited with the discovery of this vulnerability.

Many thanks to:

koba (who committed the VA on PmWiki, sikurezza.org)
Stefano Di Paola (testing on multiple vers. and poc, wisec.it)
Patrick R. Michaud (testing on 5.1.2, the PmWiki vendor)
Ethan (testing 5.1.1)
Saidone (testing 5.1.2)

X. LEGAL NOTICES

Copyright (c) 2005 Francesco "aScii" Ongaro

Permission is granted for the redistribution of this alert
electronically. It may not be edited in any way without mine express
written consent. If you wish to reprint the whole or any
part of this alert in any other medium other than electronically, please
email me for permission.

Disclaimer: The information in the advisory is believed to be accurate
at the time of publishing based on currently available information. Use
of the information constitutes acceptance for use in an AS IS condition.
There are no warranties with regard to this information. Neither the
author nor the publisher accepts any liability for any direct, indirect,
or consequential loss or damage arising from use of, or reliance on,
this information.

目录
相关文章
|
存储 PHP
PHP $GLOBALS 与 global
PHP $GLOBALS 与 global
48 0
|
PHP 索引
PHP中global与$GLOBALS['']的区别
根据官方的解释是$GLOBALS['var'] 是外部的全局变量$var本身。global $var 是外部$var的同名引用或者指针。(错误:是个别名引用而已,非指针!!!)举例说明一下: php纯技术探讨交流群:323899029+++ 探讨(一)+++++++++++++++++++++++++++++++++++++++很多人都认为global和$GLOBALS[]只是写法上面的差别,其实不然。
1134 0
|
PHP
PHP 'header()' HTTP Header Injection Vulnerability
An attacker can exploit this issue by enticing an unsuspecting user to follow a malicious URI.
752 0
|
SQL
Symantec Web Gateway 'deptUploads_data.php' SQL Injection Vulnerability
http://www.securityfocus.com/bid/54721/exploit
540 0
|
PHP
Cpanel PHP Restriction Bypass Vulnerability 0day
''' __ __ ____ _ _ ____ | // |/ __ / // | | | | _ / | / / |...
864 0
|
PHP
PHP 5.2.6 (error_log) safe_mode Bypass Vulnerability
 [ SecurityReason.com PHP 5.2.6 (error_log) safe_mode bypass ]Author: Maksymilian Arciemowicz (cXIb8O3)securityreason.
1200 0
|
安全 PHP
PHP cURL 'safe mode' Security Bypass Vulnerability
The following proof-of-concept PHP code is available:var_dump(curl_exec(curl_init("file://safe_mode_bypass/x00&amp;quot;.
823 0
|
2月前
|
安全 关系型数据库 MySQL
PHP与MySQL交互:从入门到实践
【9月更文挑战第20天】在数字时代的浪潮中,掌握PHP与MySQL的互动成为了开发动态网站和应用程序的关键。本文将通过简明的语言和实例,引导你理解PHP如何与MySQL数据库进行对话,开启你的编程之旅。我们将从连接数据库开始,逐步深入到执行查询、处理结果,以及应对常见的挑战。无论你是初学者还是希望提升技能的开发者,这篇文章都将为你提供实用的知识和技巧。让我们一起探索PHP与MySQL交互的世界,解锁数据的力量!
|
2月前
|
NoSQL 关系型数据库 MySQL
不是 PHP 不行了,而是 MySQL 数据库扛不住啊
【9月更文挑战第8天】这段内容讨论了MySQL在某些场景下面临的挑战及其原因,并指出这些问题不能完全归咎于MySQL本身。高并发读写压力、数据量增长以及复杂查询和事务处理都可能导致性能瓶颈。然而,应用程序设计不合理、系统架构不佳以及其他数据库选择和优化策略不足也是重要因素。综合考虑这些方面才能有效解决性能问题,而MySQL通过不断改进和优化,仍然是许多应用场景中的可靠选择。
124 9