CVE-2015-5532 (published 2017-10-23T18:29Z)

Multiple cross-site scripting (XSS) vulnerabilities in the Paid Memberships Pro (PMPro) plugin before 1.8.4.3 for WordPress allow remote attackers to inject arbitrary web script or HTML via the (1) s parameter to membershiplevels.php, (2) memberslist.php, or (3) orders.php in adminpages/ or the (4) edit parameter to adminpages/membershiplevels.php.

Severity: MEDIUM
CVSS v2 base score: 4.3 (AV:N/AC:M/Au:N/C:N/I:P/A:N)
CVSS v3 base score: 6.1, MEDIUM (CVSS:3.1/AV:N/AC:L/PR:N/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/strangerstudios/paid-memberships-pro
commit_details: repo_url: https://github.com/strangerstudios/paid-memberships-pro
author: Jason Coleman
author_date: 2015-07-06 14:40:47-04:00
msg: SECURITY PATCH: Fixes to Cross Site Scripting vulnerabilities in the PMPro settings pages in the WordPress dashboard. [Advisory ID HTB23264](https://www.htbridge.com/advisory/HTB23264). (Thanks, High-Tech Bridge Security Research Lab)
repository: repo_url: https://github.com/strangerstudios/paid-memberships-pro
repo_name: strangerstudios/paid-memberships-pro
description: WordPress membership plugin to restrict access to content and charge recurring subscriptions using Stripe, PayPal, and more. Fully open source. 100% GPL.
repo_language: PHP
owner: strangerstudios
file_changes: filename: advancedsettings.php
change_type: ModificationType.MODIFY
diff: @@ -227,10 +227,10 @@ if(pmpro_displayAds())
 				<th scope="row" valign="top">&nbsp;</th>
 				<td>
 					<label for="recaptcha_publickey"><?php _e('reCAPTCHA Public Key', 'pmpro');?>:</label>
-					<input type="text" name="recaptcha_publickey" size="60" value="<?php echo $recaptcha_publickey?>" />
+					<input type="text" name="recaptcha_publickey" size="60" value="<?php echo esc_attr($recaptcha_publickey);?>" />
 					<br /><br />
 					<label for="recaptcha_privatekey"><?php _e('reCAPTCHA Private Key', 'pmpro');?>:</label>
-					<input type="text" name="recaptcha_privatekey" size="60" value="<?php echo $recaptcha_privatekey?>" />
+					<input type="text" name="recaptcha_privatekey" size="60" value="<?php echo esc_attr($recaptcha_privatekey);?>" />
 				</td>
 			</tr>
 			<tr>
@@ -296,14 +296,14 @@ if(pmpro_displayAds())
                             <input id="<?php _e($field['field_name'], 'pmpro'); ?>"
                                    name="<?php _e($field['field_name'], 'pmpro'); ?>"
                                    type="<?php _e($field['field_type'], 'pmpro'); ?>"
-                                   value="<?php echo pmpro_getOption($field['field_name']); ?> ">
+                                   value="<?php echo esc_attr(pmpro_getOption($field['field_name'])); ?> ">
                             <?php
                             break;
                         case 'textarea':
                             ?>
                             <textarea id="<?php _e($field['field_name'], 'pmpro'); ?>"
                                       name="<?php _e($field['field_name'], 'pmpro'); ?>">
-                                <?php echo pmpro_getOption($field['field_name']); ?>
+                                <?php echo esc_textarea(pmpro_getOption($field['field_name'])); ?>
                             </textarea>
                             <?php
                             break;

programming_language: PHP
filename: discountcodes.php
change_type: ModificationType.MODIFY
diff: @@ -9,31 +9,31 @@
 	global $wpdb, $pmpro_currency_symbol;
 	
 	if(isset($_REQUEST['edit']))	
-		$edit = $_REQUEST['edit'];
+		$edit = intval($_REQUEST['edit']);
 	else
 		$edit = false;
 	
 	if(isset($_REQUEST['delete']))
-		$delete = $_REQUEST['delete'];
+		$delete = intval($_REQUEST['delete']);
 	else
 		$delete = false;
 		
 	if(isset($_REQUEST['saveid']))
-		$saveid = $_POST['saveid'];
+		$saveid = intval($_POST['saveid']);
 	else
 		$saveid = false;			
 	
 	if($saveid)
 	{
 		//get vars
-		$code = $_POST['code'];
-		$starts_month = $_POST['starts_month'];
-		$starts_day = $_POST['starts_day'];
-		$starts_year = $_POST['starts_year'];
-		$expires_month = $_POST['expires_month'];
-		$expires_day = $_POST['expires_day'];
-		$expires_year = $_POST['expires_year'];
-		$uses = $_POST['uses'];
+		$code = sanitize_text_field($_POST['code']);
+		$starts_month = intval($_POST['starts_month']);
+		$starts_day = intval($_POST['starts_day']);
+		$starts_year = intval($_POST['starts_year']);
+		$expires_month = intval($_POST['expires_month']);
+		$expires_day = intval($_POST['expires_day']);
+		$expires_year = intval($_POST['expires_year']);
+		$uses = intval($_POST['uses']);
 		
 		//fix up dates		
 		$starts = date("Y-m-d", strtotime($starts_month . "/" . $starts_day . "/" . $starts_year, current_time("timestamp")));
@@ -110,7 +110,7 @@
 				{
 					//get the values ready
 					$n = array_search($level_id, $all_levels_a); 	//this is the key location of this level's values
-					$initial_payment = $initial_payment_a[$n];
+					$initial_payment = sanitize_text_field($initial_payment_a[$n]);
 					
 					//is this recurring?
 					if(!empty($recurring_a))
@@ -125,10 +125,10 @@
 							
 					if(!empty($recurring))
 					{
-						$billing_amount = $billing_amount_a[$n];
-						$cycle_number = $cycle_number_a[$n];
-						$cycle_period = $cycle_period_a[$n];
-						$billing_limit = $billing_limit_a[$n];
+						$billing_amount = sanitize_text_field($billing_amount_a[$n]);
+						$cycle_number = intval($cycle_number_a[$n]);
+						$cycle_period = sanitize_text_field($cycle_period_a[$n]);
+						$billing_limit = intval($billing_limit_a[$n]);
 						
 						//custom trial
 						if(!empty($custom_trial_a))
@@ -143,8 +143,8 @@
 						
 						if(!empty($custom_trial))
 						{
-							$trial_amount = $trial_amount_a[$n];
-							$trial_limit = $trial_limit_a[$n];
+							$trial_amount = sanitize_text_field($trial_amount_a[$n]);
+							$trial_limit = intval($trial_limit_a[$n]);
 						}
 						else
 						{
@@ -175,8 +175,8 @@
 					
 					if(!empty($expiration))
 					{
-						$expiration_number = $expiration_number_a[$n];
-						$expiration_period = $expiration_period_a[$n];
+						$expiration_number = intval($expiration_number_a[$n]);
+						$expiration_period = sanitize_text_field($expiration_period_a[$n]);
 					}
 					else
 					{

programming_language: PHP
filename: membershiplevels.php
change_type: ModificationType.MODIFY
diff: @@ -14,28 +14,28 @@
 	global $pmpro_stripe_error, $pmpro_braintree_error, $pmpro_payflow_error, $pmpro_twocheckout_error, $wp_version;
 	
 	if(isset($_REQUEST['edit']))
-		$edit = $_REQUEST['edit'];	
+		$edit = intval($_REQUEST['edit']);
 	else
 		$edit = false;
 	if(isset($_REQUEST['copy']))
-		$copy = $_REQUEST['copy'];
+		$copy = intval($_REQUEST['copy']);
 	if(isset($_REQUEST['s']))
-		$s = $_REQUEST['s'];
+		$s = sanitize_text_field($_REQUEST['s']);
 	else
 		$s = "";
 	
 	if(isset($_REQUEST['action']))
-		$action = $_REQUEST['action'];
+		$action = sanitize_text_field($_REQUEST['action']);
 	else
 		$action = false;
 		
 	if(isset($_REQUEST['saveandnext']))
-		$saveandnext = $_REQUEST['saveandnext'];
+		$saveandnext = intval($_REQUEST['saveandnext']);
 
 	if(isset($_REQUEST['saveid']))
-		$saveid = $_REQUEST['saveid'];
+		$saveid = intval($_REQUEST['saveid']);
 	if(isset($_REQUEST['deleteid']))
-		$deleteid = $_REQUEST['deleteid'];
+		$deleteid = intval($_REQUEST['deleteid']);
 
 	if($action == "save_membershiplevel")
 	{
@@ -155,7 +155,7 @@
 	{
 		global $wpdb;
 
-		$ml_id = $_REQUEST['deleteid'];
+		$ml_id = intval($_REQUEST['deleteid']);
 	  
 		if($ml_id > 0)
 		{	  
@@ -280,7 +280,7 @@
 			
 		?>
 		<form action="" method="post" enctype="multipart/form-data">
-			<input name="saveid" type="hidden" value="<?php echo $edit?>" />
+			<input name="saveid" type="hidden" value="<?php echo esc_attr($edit); ?>" />
 			<input type="hidden" name="action" value="save_membershiplevel" />
 			<table class="form-table">
 			<tbody>
@@ -571,7 +571,7 @@
 		<p class="search-box">
 			<label class="screen-reader-text" for="post-search-input"><?php _e('Search Levels', 'pmpro');?>:</label>
 			<input type="hidden" name="page" value="pmpro-membershiplevels" />
-			<input id="post-search-input" type="text" value="<?php echo $s?>" name="s" size="30" />
+			<input id="post-search-input" type="text" value="<?php echo esc_attr($s); ?>" name="s" size="30" />
 			<input class="button" type="submit" value="<?php _e('Search Levels', 'pmpro');?>" id="search-submit" />
 		</p>
 	</form>	

programming_language: PHP
filename: memberslist-csv.php
change_type: ModificationType.MODIFY
diff: @@ -9,12 +9,12 @@
 
 	//get users
 	if(isset($_REQUEST['s']))
-		$s = $_REQUEST['s'];
+		$s = sanitize_text_field($_REQUEST['s']);
 	else
 		$s = "";
 
 	if(isset($_REQUEST['l']))
-		$l = $_REQUEST['l'];
+		$l = intval($_REQUEST['l']);
 	else
 		$l = false;
 

programming_language: PHP
filename: memberslist.php
change_type: ModificationType.MODIFY
diff: @@ -8,12 +8,12 @@
 	//vars
 	global $wpdb;
 	if(isset($_REQUEST['s']))
-		$s = trim($_REQUEST['s']);
+		$s = sanitize_text_field(trim($_REQUEST['s']));
 	else
 		$s = "";
 
 	if(isset($_REQUEST['l']))
-		$l = $_REQUEST['l'];
+		$l = intval($_REQUEST['l']);
 	else
 		$l = false;
 
@@ -23,7 +23,7 @@
 	<form id="posts-filter" method="get" action="">
 	<h2>
 		<?php _e('Members List', 'pmpro');?>
-		<a target="_blank" href="<?php echo admin_url('admin-ajax.php');?>?action=memberslist_csv&s=<?php echo $s?>&l=<?php echo $l?>" class="add-new-h2"><?php _e('Export to CSV', 'pmpro');?></a>
+		<a target="_blank" href="<?php echo admin_url('admin-ajax.php');?>?action=memberslist_csv&s=<?php echo esc_attr($s);?>&l=<?php echo $l?>" class="add-new-h2"><?php _e('Export to CSV', 'pmpro');?></a>
 	</h2>
 	<ul class="subsubsub">
 		<li>
@@ -48,7 +48,7 @@
 	<p class="search-box">
 		<label class="hidden" for="post-search-input"><?php _e('Search Members', 'pmpro');?>:</label>
 		<input type="hidden" name="page" value="pmpro-memberslist" />
-		<input id="post-search-input" type="text" value="<?php echo $s?>" name="s"/>
+		<input id="post-search-input" type="text" value="<?php echo esc_attr($s);?>" name="s"/>
 		<input class="button" type="submit" value="<?php _e('Search Members', 'pmpro');?>"/>
 	</p>
 	<?php
@@ -211,7 +211,7 @@
 							</td>
 							<td><?php echo $theuser->first_name?></td>
 							<td><?php echo $theuser->last_name?></td>
-							<td><a href="mailto:<?php echo $theuser->user_email?>"><?php echo $theuser->user_email?></a></td>
+							<td><a href="mailto:<?php echo esc_attr($theuser->user_email)?>"><?php echo $theuser->user_email?></a></td>
 							<?php do_action("pmpro_memberslist_extra_cols_body", $theuser);?>
 							<td>
 								<?php
@@ -248,7 +248,7 @@
 				{
 				?>
 				<tr>
-					<td colspan="9"><p><?php _e("No members found.", "pmpro");?> <?php if($l) { ?><a href="?page=pmpro-memberslist&s=<?php echo $s?>"><?php _e("Search all levels", "pmpro");?></a>.<?php } ?></p></td>
+					<td colspan="9"><p><?php _e("No members found.", "pmpro");?> <?php if($l) { ?><a href="?page=pmpro-memberslist&s=<?php echo esc_attr($s);?>"><?php _e("Search all levels", "pmpro");?></a>.<?php } ?></p></td>
 				</tr>
 				<?php
 				}

programming_language: PHP
filename: orders-csv.php
change_type: ModificationType.MODIFY
diff: @@ -9,52 +9,52 @@
 
 	//get users
 	if(isset($_REQUEST['s']))
-		$s = $_REQUEST['s'];
+		$s = sanitize_text_field($_REQUEST['s']);
 	else
 		$s = "";
 
 	if(isset($_REQUEST['l']))
-		$l = $_REQUEST['l'];
+		$l = intval($_REQUEST['l']);
 	else
 		$l = false;
 
 	if(isset($_REQUEST['start-month']))
-		$start_month = $_REQUEST['start-month'];
+		$start_month = intval($_REQUEST['start-month']);
 	else
 		$start_month = "1";
 
 	if(isset($_REQUEST['start-day']))
-		$start_day = $_REQUEST['start-day'];
+		$start_day = intval($_REQUEST['start-day']);
 	else
 		$start_day = "1";
 
 	if(isset($_REQUEST['start-year']))
-		$start_year = $_REQUEST['start-year'];
+		$start_year = intval($_REQUEST['start-year']);
 	else
 		$start_year = date("Y");
 
 	if(isset($_REQUEST['end-month']))
-		$end_month = $_REQUEST['end-month'];
+		$end_month = intval($_REQUEST['end-month']);
 	else
 		$end_month = date("n");
 
 	if(isset($_REQUEST['end-day']))
-		$end_day = $_REQUEST['end-day'];
+		$end_day = intval($_REQUEST['end-day']);
 	else
 		$end_day = date("j");
 
 	if(isset($_REQUEST['end-year']))
-		$end_year = $_REQUEST['end-year'];
+		$end_year = intval($_REQUEST['end-year']);
 	else
 		$end_year = date("Y");
 
 	if(isset($_REQUEST['predefined-date']))
-		$predefined_date = $_REQUEST['predefined-date'];
+		$predefined_date = sanitize_text_field($_REQUEST['predefined-date']);
 	else
 		$predefined_date = "This Month";
 
 	if(isset($_REQUEST['status']))
-		$status = $_REQUEST['status'];
+		$status = sanitize_text_field($_REQUEST['status']);
 	else
 		$status = "";
 

programming_language: PHP
filename: orders.php
change_type: ModificationType.MODIFY
diff: @@ -8,52 +8,52 @@
 	//vars
 	global $wpdb;
 	if(isset($_REQUEST['s']))
-		$s = trim($_REQUEST['s']);
+		$s = sanitize_text_field(trim($_REQUEST['s']));
 	else
 		$s = "";
 
 	if(isset($_REQUEST['l']))
-		$l = $_REQUEST['l'];
+		$l = intval($_REQUEST['l']);
 	else
 		$l = false;
 
 	if(isset($_REQUEST['start-month']))
-		$start_month = $_REQUEST['start-month'];
+		$start_month = intval($_REQUEST['start-month']);
 	else
 		$start_month = "1";
 
 	if(isset($_REQUEST['start-day']))
-		$start_day = $_REQUEST['start-day'];
+		$start_day = intval($_REQUEST['start-day']);
 	else
 		$start_day = "1";
 
 	if(isset($_REQUEST['start-year']))
-		$start_year = $_REQUEST['start-year'];
+		$start_year = intval($_REQUEST['start-year']);
 	else
 		$start_year = date("Y");
 
 	if(isset($_REQUEST['end-month']))
-		$end_month = $_REQUEST['end-month'];
+		$end_month = intval($_REQUEST['end-month']);
 	else
 		$end_month = date("n");
 
 	if(isset($_REQUEST['end-day']))
-		$end_day = $_REQUEST['end-day'];
+		$end_day = intval($_REQUEST['end-day']);
 	else
 		$end_day = date("j");
 
 	if(isset($_REQUEST['end-year']))
-		$end_year = $_REQUEST['end-year'];
+		$end_year = intval($_REQUEST['end-year']);
 	else
 		$end_year = date("Y");
 
 	if(isset($_REQUEST['predefined-date']))
-		$predefined_date = $_REQUEST['predefined-date'];
+		$predefined_date = sanitize_text_field($_REQUEST['predefined-date']);
 	else
 		$predefined_date = "This Month";
 
 	if(isset($_REQUEST['status']))
-		$status = $_REQUEST['status'];
+		$status = sanitize_text_field($_REQUEST['status']);
 	else
 		$status = "";
 
@@ -513,8 +513,8 @@
 							}
 						?>
 						</select>
-						<input name="ts_day" type="text" size="2" value="<?php echo $day?>" />
-						<input name="ts_year" type="text" size="4" value="<?php echo $year?>" />
+						<input name="ts_day" type="text" size="2" value="<?php echo esc_attr($day);?>" />
+						<input name="ts_year" type="text" size="4" value="<?php echo esc_attr($year);?>" />
 						<?php } ?>
 					</td>
 				</tr>
@@ -617,8 +617,8 @@
 				<?php } ?>
 			</select>
 
-			<input id='start-day' name="start-day" type="text" size="2" value="<?php echo $start_day?>" />
-			<input id='start-year' name="start-year" type="text" size="4" value="<?php echo $start_year?>" />
+			<input id='start-day' name="start-day" type="text" size="2" value="<?php echo esc_attr($start_day);?>" />
+			<input id='start-year' name="start-year" type="text" size="4" value="<?php echo esc_attr($start_year);?>" />
 
 
 			<span id="to"><?php _ex('To', 'Dropdown label', 'pmpro')?></span>
@@ -630,8 +630,8 @@
 			</select>
 
 
-			<input id='end-day' name="end-day" type="text" size="2" value="<?php echo $end_day?>" />
-			<input id='end-year' name="end-year" type="text" size="4" value="<?php echo $end_year?>" />
+			<input id='end-day' name="end-day" type="text" size="2" value="<?php echo esc_attr($end_day);?>" />
+			<input id='end-year' name="end-year" type="text" size="4" value="<?php echo esc_attr($end_year);?>" />
 
 			<span id="filterby"><?php _ex('filter by ', 'Dropdown label', 'pmpro')?></span>
 
@@ -776,7 +776,7 @@
 	<p class="search-box">
 		<label class="hidden" for="post-search-input"><?php _e('Search Orders', 'pmpro');?>:</label>
 		<input type="hidden" name="page" value="pmpro-orders" />
-		<input id="post-search-input" type="text" value="<?php echo $s?>" name="s"/>
+		<input id="post-search-input" type="text" value="<?php echo esc_attr($s);?>" name="s"/>
 		<input class="button" type="submit" value="<?php _e('Search Orders', 'pmpro');?>"/>
 	</p>
 

programming_language: PHP
filename: reports.php
change_type: ModificationType.MODIFY
diff: @@ -54,7 +54,7 @@
 	else
 	{
 		//view a single report
-		$report = $_REQUEST['report'];
+		$report = sanitize_text_field($_REQUEST['report']);
 		call_user_func("pmpro_report_" . $report . "_page");
 	}
 	

programming_language: PHP
filename: readme.txt
change_type: ModificationType.MODIFY
diff: @@ -101,6 +101,9 @@ Not sure? You can find out by doing a bit a research.
 3. Members are WordPress Users. PMPro provides a unique interface to view, filter and search Members or export your Members List.
 4. Offer Membership Discounts with specific price rules (restricted by level, unique pricing for each level, # of uses, expiration date.)
 
+= 1.8.4.3 = 
+* SECURITY PATCH: Fixes to Cross Site Scripting vulnerabilities in the PMPro settings pages in the WordPress dashboard. [Advisory ID HTB23264](https://www.htbridge.com/advisory/HTB23264). (Thanks, High-Tech Bridge Security Research Lab)
+
 == Changelog == 
 = 1.8.4.2 =
 * BUG: Fixed bug where dropdown to set the account page in the page settings was showing up twice.

programming_language: Markdown