CVE-2017-1000213 (published 2017-11-17T01:29Z)

WBCE v1.1.11 is vulnerable to reflected XSS via the "begriff" POST parameter in /admin/admintools/tool.php?tool=user_search

Severity: LOW
CVSS v2 base score: 3.5 (AV:N/AC:M/Au:S/C:N/I:P/A:N)
CVSS v3 base score: 4.8, MEDIUM (CVSS:3.0/AV:N/AC:L/PR:H/UI:R/S:C/C:L/I:L/A:N)

Weakness information:
cwe_id: CWE-79
cwe_name: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
description: The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
extended_description: 
            Cross-site scripting (XSS) vulnerabilities occur when:
            
               Untrusted data enters a web application, typically from a web request.
               The web application dynamically generates a web page that contains this untrusted data.
               During page generation, the application does not prevent the data from containing content that is executable by a web browser, such as JavaScript, HTML tags, HTML attributes, mouse events, Flash, ActiveX, etc.
               A victim visits the generated web page through a web browser, which contains malicious script that was injected using the untrusted data.
               Since the script comes from a web page that was sent by the web server, the victim's web browser executes the malicious script in the context of the web server's domain.
               This effectively violates the intention of the web browser's same-origin policy, which states that scripts in one domain should not be able to access resources or run code in a different domain.
            
            There are three main kinds of XSS:
            
               
                  Type 1: Reflected XSS (or Non-Persistent) - 
         			The server reads data directly from the HTTP request and reflects it back in the HTTP response. Reflected XSS exploits occur when an attacker causes a victim to supply dangerous content to a vulnerable web application, which is then reflected back to the victim and executed by the web browser. The most common mechanism for delivering malicious content is to include it as a parameter in a URL that is posted publicly or e-mailed directly to the victim. URLs constructed in this manner constitute the core of many phishing schemes, whereby an attacker convinces a victim to visit a URL that refers to a vulnerable site. After the site reflects the attacker's content back to the victim, the content is executed by the victim's browser.
               
                  Type 2: Stored XSS (or Persistent) - 
               The application stores dangerous data in a database, message forum, visitor log, or other trusted data store. At a later time, the dangerous data is subsequently read back into the application and included in dynamic content. From an attacker's perspective, the optimal place to inject malicious content is in an area that is displayed to either many users or particularly interesting users. Interesting users typically have elevated privileges in the application or interact with sensitive data that is valuable to the attacker. If one of these users executes malicious content, the attacker may be able to perform privileged operations on behalf of the user or gain access to sensitive data belonging to the user. For example, the attacker might inject XSS into a log message, which might not be handled properly when an administrator views the logs.
            
               
                  Type 0: DOM-Based XSS - 
               In DOM-based XSS, the client performs the injection of XSS into the page; in the other types, the server performs the injection. DOM-based XSS generally involves server-controlled, trusted script that is sent to the client, such as Javascript that performs sanity checks on a form before the user submits it. If the server-supplied script processes user-supplied data and then injects it back into the web page (such as with dynamic HTML), then DOM-based XSS is possible.
            
            
            Once the malicious script is injected, the attacker can perform a variety of malicious activities. The attacker could transfer private information, such as cookies that may include session information, from the victim's machine to the attacker. The attacker could send malicious requests to a web site on behalf of the victim, which could be especially dangerous to the site if the victim has administrator privileges to manage that site. Phishing attacks could be used to emulate trusted web sites and trick the victim into entering a password, allowing the attacker to compromise the victim's account on that web site. Finally, the script could exploit a vulnerability in the web browser itself possibly taking over the victim's machine, sometimes referred to as "drive-by hacking."
            In many cases, the attack can be launched without the victim even being aware of it. Even with careful users, attackers frequently use a variety of methods to encode the malicious portion of the attack, such as URL encoding or Unicode, so the request looks less suspicious.
         
         

Fix information:
repo_url: https://github.com/WBCE/WBCE_CMS
commit_details: repo_url: https://github.com/WBCE/WBCE_CMS
author: Christoph Bleiweis
author_date: 2017-05-08 15:54:12+02:00
msg: Update user search

Update user search from 0.41 to 0.50
repository: repo_url: https://github.com/WBCE/WBCE_CMS
repo_name: WBCE/WBCE_CMS
description: Core package of WBCE CMS. This package includes the core and the default addons. Visit https://wbce.org (DE) or https://wbce-cms.org (EN) to learn more or to join the WBCE CMS community. 
repo_language: PHP
owner: WBCE
file_changes: filename: usersearch_result.htt
change_type: ModificationType.MODIFY
diff: @@ -1,82 +1,82 @@
-<h2>{HEADING_RESULT}</h2>
-<p>{HOWTO_RESULT}</p>	
-<table width="98%" cellspacing="0" border="0" cellpadding="5px" class="row_a">
-	<tr>
-		<td style="width: 220px;"><strong>{SEARCH_DETAIL_RESULT}:</strong></td>
-		<td><strong>&nbsp;</td>
-	</tr>
-<!-- BEGIN searchterm_block -->
-	<tr>				
-		<td>{SEARCH_ITEM_RESULT}:</td>
-		<td>{BEGRIFF}</td>		
-	</tr>
-	<tr>				
-		<td>{SEARCH_FIELD_RESULT}:</td>
-		<td>{DISPLAYSEARCHFIELD}</td>		
-	</tr>
-<!-- END searchterm_block -->
-<!-- BEGIN group_block -->	
-	<tr>				
-		<td>{GROUP_RESULT}:</td>
-		<td>{GROUP_NAME}</td>		
-	</tr>
-<!-- END group_block -->
-<!-- BEGIN last_login_block -->		 
-	<tr>				
-		<td>{LAST_LOGIN}:</td>
-		<td>{BEFORE_OR_AFTER} {DATE_RESULT}</td>		
-	</tr>
-<!-- END last_login_block -->	
-	<tr>
-		<td colspan="2"><br /><strong>{SHOW_RESULT}:</strong></td>
-	</tr>
-	
-<!-- BEGIN no_result_block -->
-{NO_RESULT}	
-<!-- END no_result_block -->
-<!-- BEGIN result_table_block -->	
-<table width="100%" border="0" cellpadding="2" cellspacing="0" style="border-collapse: collapse;">
-	<tr style="background-color: #BDCDD9;">
-		<td align="right" style="font-weight:bold; border: 1px solid #ccc;">ID</td>
-		<td style="font-weight:bold; border: 1px solid #ccc;">{USER_NAME}</td>
-		<td style="font-weight:bold; border: 1px solid #ccc;">{REAL_NAME}</td>
-		<td style="font-weight:bold; border: 1px solid #ccc;">{EMAIL}</td>
-		<td style="font-weight:bold; border: 1px solid #ccc;">{LAST_LOGIN}</td>
-		<td style="font-weight:bold; border: 1px solid #ccc;">{LAST_IP}</td>
-	</tr>
-<!-- BEGIN result_list_block -->		
-	<tr style="background-color: {RESULT_BGCOL}">
-		<td align="center" style="border: 1px solid #ccc;">
-			<form name="edituser{RESULT_USER_ID}" method="post" action="{ADMIN_URL}/users/users.php" target="_blank">								
-			<input type="hidden" name="user_id" value="{IDKEY_USER_ID}" />
-			<input type="hidden" name="modify" value="modify" />
-			<input type="hidden" name="details" value="{RESULT_USER_ID}" />
-			<b>{RESULT_USER_ID}</b>
-			</form>
-		</td>
-		<td align="left" style="border: 1px solid #ccc;">
-			<a OnClick="javascript:if ({RESULT_USER_ID}!=1) { document.edituser{RESULT_USER_ID}.submit();} else {alert('{RESULT_ADMIN_DISABLED}');}; return false;" HREF="#" title="{RESULT_EDIT_USER}: {RESULT_DISPLAYNAME}">{RESULT_USERNAME}</a>
-		</td>
-		<td align="left" style="border: 1px solid #ccc;">
-		{RESULT_DISPLAYNAME}
-		</td>
-		<td align="left" style="border: 1px solid #ccc;">
-			<a href="mailto:{RESULT_EMAIL}">{RESULT_EMAIL}</a>
-		</td>
-		<td align="left" style="border: 1px solid #ccc;">
-		{RESULT_LASTLOGIN}/({RESULT_DAYS_INACTIVE})
-		</td>
-		<td align="left" style="border: 1px solid #ccc;">
-		{RESULT_LAST_IP}
-		</td>							
-	</tr>
-<!-- END result_list_block -->	
-	<tr>
-		<td colspan="6" style="font-size:smaller;" align="center">{HINT_EDIT}</td>
-	</tr>
-</table>
-</td>
-</tr>
-</table>
-<!-- END result_table_block -->
-
+<h2>{HEADING_RESULT}</h2>
+<p>{HOWTO_RESULT}</p>	
+<table width="98%" cellspacing="0" border="0" cellpadding="5px" class="row_a">
+	<tr>
+		<td style="width: 220px;"><strong>{SEARCH_DETAIL_RESULT}:</strong></td>
+		
+	</tr>
+<!-- BEGIN searchterm_block -->
+	<tr>				
+		<td>{SEARCH_ITEM_RESULT}:</td>
+		<td>{BEGRIFF}</td>		
+	</tr>
+	<tr>				
+		<td>{SEARCH_FIELD_RESULT}:</td>
+		<td>{DISPLAYSEARCHFIELD}</td>		
+	</tr>
+<!-- END searchterm_block -->
+<!-- BEGIN group_block -->	
+	<tr>				
+		<td>{GROUP_RESULT}:</td>
+		<td>{GROUP_NAME}</td>		
+	</tr>
+<!-- END group_block -->
+<!-- BEGIN last_login_block -->		 
+	<tr>				
+		<td>{LAST_LOGIN}:</td>
+		<td>{BEFORE_OR_AFTER} {DATE_RESULT}</td>		
+	</tr>
+<!-- END last_login_block -->	
+	<tr>
+		<td colspan="2"><br /><strong>{SHOW_RESULT}:</strong></td>
+	</tr>
+	
+<!-- BEGIN no_result_block -->
+{NO_RESULT}	
+<!-- END no_result_block -->
+<!-- BEGIN result_table_block -->	
+<table width="100%" border="0" cellpadding="2" cellspacing="0" style="border-collapse: collapse;">
+	<tr style="background-color: #BDCDD9;">
+		<td align="right" style="font-weight:bold; border: 1px solid #ccc;">ID</td>
+		<td style="font-weight:bold; border: 1px solid #ccc;">{USER_NAME}</td>
+		<td style="font-weight:bold; border: 1px solid #ccc;">{REAL_NAME}</td>
+		<td style="font-weight:bold; border: 1px solid #ccc;">{EMAIL}</td>
+		<td style="font-weight:bold; border: 1px solid #ccc;">{LAST_LOGIN}</td>
+		<td style="font-weight:bold; border: 1px solid #ccc;">{LAST_IP}</td>
+	</tr>
+<!-- BEGIN result_list_block -->		
+	<tr style="background-color: {RESULT_BGCOL}">
+		<td align="center" style="border: 1px solid #ccc;">
+			<form name="edituser{RESULT_USER_ID}" method="post" action="{ADMIN_URL}/users/users.php" target="_blank">								
+			<input type="hidden" name="user_id" value="{IDKEY_USER_ID}" />
+			<input type="hidden" name="modify" value="modify" />
+			<input type="hidden" name="details" value="{RESULT_USER_ID}" />
+			<b>{RESULT_USER_ID}</b>
+			</form>
+		</td>
+		<td align="left" style="border: 1px solid #ccc;">
+			<a OnClick="javascript:if ({RESULT_USER_ID}!=1) { document.edituser{RESULT_USER_ID}.submit();} else {alert('{RESULT_ADMIN_DISABLED}');}; return false;" HREF="#" title="{RESULT_EDIT_USER}: {RESULT_DISPLAYNAME}">{RESULT_USERNAME}</a>
+		</td>
+		<td align="left" style="border: 1px solid #ccc;">
+		{RESULT_DISPLAYNAME}
+		</td>
+		<td align="left" style="border: 1px solid #ccc;">
+			<a href="mailto:{RESULT_EMAIL}">{RESULT_EMAIL}</a>
+		</td>
+		<td align="left" style="border: 1px solid #ccc;">
+		{RESULT_LASTLOGIN}/({RESULT_DAYS_INACTIVE})
+		</td>
+		<td align="left" style="border: 1px solid #ccc;">
+		{RESULT_LAST_IP}
+		</td>							
+	</tr>
+<!-- END result_list_block -->	
+	<tr>
+		<td colspan="6" style="font-size:smaller;" align="center">{HINT_EDIT}</td>
+	</tr>
+</table>
+</td>
+</tr>
+</table>
+<!-- END result_table_block -->
+

programming_language: PHP
filename: info.php
change_type: ModificationType.MODIFY
diff: @@ -1,26 +1,18 @@
 <?php
-
-// $Id: info.php 591 2009-03-01 19:42:05Z BerndJM $
-
 /*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2008, Ryan Djurovich
-
- Website Baker is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- Website Baker is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Website Baker; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- -----------------------------------------------------------------------------------------
+  *
+ * WBCE CMS
+ * Way Better Content Editing.
+ * Visit http://wbce.org to learn more and to join the community.
+ *
+ * @copyright Ryan Djurovich (2004-2009)
+ * @copyright WebsiteBaker Org. e.V. (2009-2015)
+ * @copyright WBCE Project (2015-)
+ * @license GNU GPL2 (or any later version)
+ 
+  v0.50 (florian; 08.05.2017)
+  !fix XSS vulnerability (reported by strukt93@gmail.com)
+ 
   v0.41 (marmot; 25.05.2013)
   ! admin url is now set by config.php
   ! notice regarding mktime
@@ -65,7 +57,7 @@
 $module_directory = 'user_search';
 $module_name = 'User search';
 $module_function = 'tool';
-$module_version = '0.41';
+$module_version = '0.50';
 $module_platform = '2.8.3';
 $module_author = 'Bernd Michna';
 $module_license = 'GNU General Public License';

programming_language: PHP
filename: DE.php
change_type: ModificationType.MODIFY
diff: @@ -31,8 +31,8 @@ $module_description = 'Dieses Modul bietet eine Suchfunktion f&uuml;r die Benutz
 
 // Textausgaben
 $MOD_USER_SEARCH['HEADING']				= 'Benutzer Suche';
-$MOD_USER_SEARCH['HOWTO']				= 'Hier sind einige zus&auml;tzliche Funktionen f&uuml;r die Suche.<br />Sie k&ouml;nnen verschiedene Kriterien kombinieren um die Suche zu verbessern. Falls sie ein Kriterium nicht ben&ouml;tigen, lassen Sie es einfach frei.';
-$MOD_USER_SEARCH['SUBMIT_ALERT']		= 'Eine Suche ohne Suchbegriff macht keinen Sinn ;-)';
+$MOD_USER_SEARCH['HOWTO']				= 'Hier sind einige zus&auml;tzliche Funktionen f&uuml;r die Suche. <br />Sie k&ouml;nnen verschiedene Kriterien kombinieren um die Suche zu verbessern. Falls sie ein Kriterium nicht ben&ouml;tigen, lassen Sie es einfach frei.';
+$MOD_USER_SEARCH['SUBMIT_ALERT']		= 'Eine Suche ohne Suchbegriff ergibt keinen Sinn ;-)';
 $MOD_USER_SEARCH['SUBMIT_TERM_ALERT'] 	= 'Wenn Sie einen Suchberiff angeben, m&uuml;ssen Sie mindestens ein Suchfeld ausw&auml;hlen!';
 $MOD_USER_SEARCH['SEARCH_ITEM']			= 'Suchbegriff';
 $MOD_USER_SEARCH['USE_WILDCARD']		= 'Verwenden Sie * als Wildcard.';

programming_language: PHP
filename: tool.php
change_type: ModificationType.MODIFY
diff: @@ -131,10 +131,11 @@ else {
 		if (isset($_POST['realname']))  $wheretosearch += 2;
 		if (isset($_POST['email']))		$wheretosearch += 4;
 		
-		//$item = $admin->add_slashes($admin->get_post('begriff'));
+		$item_raw = $admin->add_slashes($admin->get_post('begriff'));
+		$item = $database->escapeString($item_raw);
 		
-		$xmlstoresearch .= "<searchterm>".$admin->add_slashes($admin->get_post('begriff'))."</searchterm>";
-		$item = str_replace("*", '%', $admin->add_slashes($admin->get_post('begriff')));
+		$xmlstoresearch .= "<searchterm>".$item."</searchterm>";
+		$item = str_replace("*", '%', $item);
 		
 	
 		switch($wheretosearch) {
@@ -191,14 +192,15 @@ else {
 			$xmlstoresearch .= "<before>true</before>";
 		}
 		// convert date to timestamp format to compare
-		$resultquery .= jscalendar_to_timestamp($_POST['comp_date'],TIMEZONE);
-		$xmlstoresearch .= "<date>".jscalendar_to_timestamp($_POST['comp_date'],TIMEZONE)."</date>";
+		$resultquery .= $database->escapeString(jscalendar_to_timestamp($_POST['comp_date'],TIMEZONE));
+		
+		$xmlstoresearch .= "<date>".$database->escapeString(jscalendar_to_timestamp($_POST['comp_date'],TIMEZONE))."</date>";
 		$xmlstoresearch .= "</datelastlogin>";
 		}
 	
 	// if a group was choosen modify the sql query
 	if (isset($_POST['groups'])&&($_POST['groups']!="-1")) {
-		$g_id = $_POST['groups'];
+		$g_id = $database->escapeString($_POST['groups']);
 		if ($resultquery!="") $resultquery .= ") AND";
 		$g_id = str_replace(",", '%', $g_id);
 		$resultquery .= " (groups_id LIKE '%$g_id%'";
@@ -237,7 +239,7 @@ else {
 		if ($wheretosearch != 0) {
 			// display if a search term was entered
 			$tpl->set_var('SEARCH_ITEM_RESULT', $MOD_USER_SEARCH['SEARCH_ITEM_RESULT']);
-			$tpl->set_var('BEGRIFF', $admin->add_slashes($admin->get_post('begriff')));
+			$tpl->set_var('BEGRIFF',htmlspecialchars($admin->get_post('begriff'),ENT_QUOTES, "UTF-8"));
 			$tpl->set_var('SEARCH_FIELD_RESULT', $MOD_USER_SEARCH['SEARCH_FIELD_RESULT']);
 			$tpl->set_var('DISPLAYSEARCHFIELD', $displaysearchfield);
 			$tpl->parse('searchterm_block_handle', 'searchterm_block');

programming_language: PHP