CVE-2014-125035 (published 2023-01-02T16:15Z)

A vulnerability classified as problematic was found in Jobs-Plugin. Affected by this vulnerability is an unknown functionality. The manipulation leads to cross site scripting. The attack can be launched remotely. The identifier of the patch is b8a56718b1d42834c6ec51d9c489c5dc20471d7b. It is recommended to apply a patch to fix this issue. The identifier VDB-217189 was assigned to this vulnerability.

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/mrbobbybryant/Jobs-Plugin
commit_details: repo_url: https://github.com/mrbobbybryant/Jobs-Plugin
author: Adam Silverstein
author_date: 2014-12-01 08:25:49-07:00
msg: Whitespace/code cleanup

* add limits and no_count_rows to optimize queries
* add some missing output escaping
* change some spaces to tabs, some remain
* add coding standards spacing to JS as well
* cast post id as (int) to avoid XSS vector
repository: repo_url: https://github.com/mrbobbybryant/Jobs-Plugin
repo_name: mrbobbybryant/Jobs-Plugin
repo_language: PHP
owner: mrbobbybryant
file_changes: filename: hrm-jobs.php
change_type: ModificationType.MODIFY
diff: @@ -30,7 +30,7 @@ if ( is_object($screen) && 'job' == $screen->post_type ) {
 	wp_enqueue_script( 'reorder-js', plugins_url( '/js/reorder.js', __FILE__), array('jquery'), '', true );
 	wp_enqueue_script( 'jquery-ui-datepicker' );
   	wp_enqueue_script( 'field-date-js', plugins_url('js/Field_Date.js', __FILE__), array('jquery-core', 'jquery-ui-core', 'jquery-ui-datepicker'), '', true );
-	wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
+	wp_enqueue_style( 'jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
   }
 }
 add_action( 'admin_enqueue_scripts', 'hrm_jobs_enqueue_scripts' );
@@ -46,13 +46,13 @@ require_once 'render-admin.php';
  * Create Sorting Admin Page
  */
 function hrm_jobs_add_menu_page() {
-	add_submenu_page( 
-		'edit.php?post_type=job', 
-		'Reorder Jobs', 
-		'Reorder Jobs', 
-		'edit_pages', 
-		'reorder_jobs', 
-		'hrm_jobs_render_admin' 
+	add_submenu_page(
+		'edit.php?post_type=job',
+		'Reorder Jobs',
+		'Reorder Jobs',
+		'edit_pages',
+		'reorder_jobs',
+		'hrm_jobs_render_admin'
 	);
 }
 
@@ -64,14 +64,16 @@ function hrm_jobs_list_shortcode ( $atts, $content = null ) {
 	$args = array(
 		'post_type' => 'job',
 		'orderby' => 'menu_order',
-		'order' => 'ASC'
+		'order' => 'ASC',
+		'post_per_page' => 100, /* add a reasonable max # rows */
+		'no_found_rows' => true, /* don't generate a count as part of query */
 	);
 
 	$jobs = new WP_Query( $args );
 	?>
-		
+
 	<?php   if ( $jobs->have_posts() ) : ?>
-	    	
+
 			<table id="job-list">
 				<tr>
 					<th>Job Title</th>
@@ -79,20 +81,20 @@ function hrm_jobs_list_shortcode ( $atts, $content = null ) {
 					<th></th>
 				</tr>
 				<?php while ( $jobs->have_posts() ) : $jobs->the_post(); ?>
-					
+
 					<?php $jobUrl = get_permalink(); ?>
 
 				<tr>
 					<td id="<?php the_id(); ?>"><?php the_title(); ?></td>
 					<td><?php the_terms( $post->ID, 'location') ?></td>
-					<td><a href="<?php echo esc_url($jobUrl) ?>">Learn More</a></td>
+					<td><a href="<?php echo esc_url( $jobUrl ) ?>">Learn More</a></td>
 				</tr>
-					
+
 				<?php endwhile; ?>
-	    	</table>
+			</table>
 
 			<?php else: ?>
-			<p><?php _e('You have no Jobs to display.', 'hrm_jobs'); ?></p>
+			<p><?php _e( 'You have no Jobs to display.', 'hrm_jobs' ); ?></p>
 			<?php endif; ?>
 		</div>
 

programming_language: PHP
filename: jobs-cpt.php
change_type: ModificationType.MODIFY
diff: @@ -1,6 +1,6 @@
 <?php
 function hrm_jobs_posttype() {
-    
+
     $labels = array(
         'name'               => 'Jobs',
         'singular_name'      => 'Job',
@@ -17,7 +17,7 @@ function hrm_jobs_posttype() {
         'not_found'          => 'No jobs found.',
         'not_found_in_trash' => 'No jobs found in Trash.',
     );
-    
+
     $args = array(
         'labels'             => $labels,
         'public'             => true,
@@ -45,7 +45,7 @@ function hrm_jobs_my_rewrite_flush() {
 register_activation_hook( __FILE__, 'hrm_jobs_my_rewrite_flush' );
 
 function hrm_location_tax() {
-    
+
     $labels = array(
             'name'                       => _x( 'Locations', 'taxonomy general name' ),
             'singular_name'              => _x( 'Location', 'taxonomy singular name' ),

programming_language: PHP
filename: jobs-fields.php
change_type: ModificationType.MODIFY
diff: @@ -1,14 +1,14 @@
-<?php 
+<?php
 
 /**
  * Adds a meta box to the post editing screen
  */
 function hrm_custom_meta() {
-    add_meta_box( 
-      'hrm_meta', 
-      __( 'Job Listing', 'hrm-jobs' ), 
-      'hrm_meta_callback', 
-      'job' 
+    add_meta_box(
+      'hrm_meta',
+      __( 'Job Listing', 'hrm-jobs' ),
+      'hrm_meta_callback',
+      'job'
     );
 }
 add_action( 'add_meta_boxes', 'hrm_custom_meta' );
@@ -25,8 +25,8 @@ function hrm_meta_callback( $post ) {
           <div class="meta-th">
             <label for="job-id" class="hrm-row-title"><?php _e( 'Job ID', 'hrm-textdomain' )?></label>
           </div>
-          <div class="meta-td">  
-            <input type="text" name="job-id" id="job-id" value="<?php if ( isset ( $hrm_stored_meta['job-id'] ) ) echo $hrm_stored_meta['job-id'][0]; ?>" />
+          <div class="meta-td">
+            <input type="text" name="job-id" id="job-id" value="<?php if ( isset ( $hrm_stored_meta['job-id'] ) ) echo esc_attr( $hrm_stored_meta['job-id'][0] ); ?>" />
           </div>
       </div>
       <div class="meta-row">
@@ -34,7 +34,7 @@ function hrm_meta_callback( $post ) {
             <label for="date_listed" class="wpdt-row-title"><?php _e( 'Date Listed', 'hrm-textdomain' )?></label>
           </div>
           <div class="meta-td">
-            <input type="text" size="10" class="wpdt-row-content datepicker" name="date_listed" id="date_listed" value="<?php if ( isset ( $hrm_stored_meta['date_listed'] ) ) echo $hrm_stored_meta['date_listed'][0]; ?>" />
+            <input type="text" size="10" class="wpdt-row-content datepicker" name="date_listed" id="date_listed" value="<?php if ( isset ( $hrm_stored_meta['date_listed'] ) ) echo esc_attr( $hrm_stored_meta['date_listed'][0] ); ?>" />
           </div>
       </div>
       <div class="meta-row">
@@ -42,7 +42,7 @@ function hrm_meta_callback( $post ) {
             <label for="application_deadline" class="wpdt-row-title"><?php _e( 'Application Deadline', 'hrm-textdomain' )?></label>
           </div>
           <div class="meta-td">
-            <input type="text" size="10" class="wpdt-row-content datepicker" name="application_deadline" id="application_deadline" value="<?php if ( isset ( $hrm_stored_meta['application_deadline'] ) ) echo $hrm_stored_meta['application_deadline'][0]; ?>" />
+            <input type="text" size="10" class="wpdt-row-content datepicker" name="application_deadline" id="application_deadline" value="<?php if ( isset ( $hrm_stored_meta['application_deadline'] ) ) echo esc_attr( $hrm_stored_meta['application_deadline'][0] ); ?>" />
           </div>
       </div>
       <div class="meta-row">
@@ -54,7 +54,7 @@ function hrm_meta_callback( $post ) {
 
               $content = get_post_meta( $post->ID, 'principle_duties', true );
               $editor_id = 'principle_duties';
-              $settings = array( 
+              $settings = array(
                 'textarea_rows' => 5,
               );
 
@@ -68,7 +68,7 @@ function hrm_meta_callback( $post ) {
           <label for="minimum-requirements" class="wpdt-row-title"><?php _e( 'Minimum Requirements', 'hrm-textdomain' )?></label>
         </div>
         <div class="meta-td">
-          <textarea name="minimum-requirements" class ="hrm-textarea" id="minimum-requirements"><?php if ( isset ( $hrm_stored_meta['minimum-requirements'] ) ) echo $hrm_stored_meta['minimum-requirements'][0]; ?></textarea>
+          <textarea name="minimum-requirements" class ="hrm-textarea" id="minimum-requirements"><?php if ( isset ( $hrm_stored_meta['minimum-requirements'] ) ) echo esc_attr( $hrm_stored_meta['minimum-requirements'][0] ); ?></textarea>
         </div>
       </div>
       <div class="meta-row">
@@ -76,7 +76,7 @@ function hrm_meta_callback( $post ) {
           <label for="preferred-requirements" class="wpdt-row-title"><?php _e( 'Preferred Requirements', 'hrm-textdomain' )?></label>
         </div>
         <div class="meta-td">
-          <textarea name="preferred-requirements" class ="hrm-textarea" id="preferred-requirements"><?php if ( isset ( $hrm_stored_meta['preferred-requirements'] ) ) echo $hrm_stored_meta['preferred-requirements'][0]; ?></textarea>
+          <textarea name="preferred-requirements" class ="hrm-textarea" id="preferred-requirements"><?php if ( isset ( $hrm_stored_meta['preferred-requirements'] ) ) echo esc_attr( $hrm_stored_meta['preferred-requirements'][0] ); ?></textarea>
         </div>
       </div>
       <div class="meta-row">
@@ -99,17 +99,17 @@ function hrm_meta_callback( $post ) {
  * Saves the custom meta input
  */
 function hrm_meta_save( $post_id ) {
- 
+
     // Checks save status
     $is_autosave = wp_is_post_autosave( $post_id );
     $is_revision = wp_is_post_revision( $post_id );
     $is_valid_nonce = ( isset( $_POST[ 'hrm_nonce' ] ) && wp_verify_nonce( $_POST[ 'hrm_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';
- 
+
     // Exits script depending on save status
     if ( $is_autosave || $is_revision || !$is_valid_nonce ) {
         return;
     }
- 
+
     // Checks for input and sanitizes/saves if needed
     if( isset( $_POST[ 'job-id' ] ) ) {
         update_post_meta( $post_id, 'job-id', sanitize_text_field( $_POST[ 'job-id' ] ) );
@@ -122,7 +122,7 @@ function hrm_meta_save( $post_id ) {
     if( isset( $_POST[ 'minimum-requirements' ] ) ) {
         update_post_meta( $post_id, 'minimum-requirements', sanitize_text_field( $_POST[ 'minimum-requirements' ] ) );
     }
-    
+
     if( isset( $_POST[ 'date_listed' ] ) ) {
         update_post_meta( $post_id, 'date_listed', sanitize_text_field( $_POST[ 'date_listed' ] ) );
     }
@@ -145,15 +145,15 @@ add_action( 'save_post', 'hrm_meta_save' );
  * Change Placeholder text in Default title field.
  */
 function change_default_title( $title ){
- 
+
     $screen = get_current_screen();
- 
+
     if ( 'job' == $screen->post_type ){
         $title = "Enter Job Title Here";
     }
- 
+
     return $title;
 }
- 
+
 add_filter( 'enter_title_here', 'change_default_title' );
 

programming_language: PHP
filename: reorder.js
change_type: ModificationType.MODIFY
diff: @@ -1,11 +1,11 @@
 jQuery(document).ready(function($) {
-	$('div#jobs-admin-sort').each(function() {
+	$( 'div#jobs-admin-sort' ).each(function() {
 
-		var sortList = $('ul#custom-type-list');
+		var sortList = $( 'ul#custom-type-list' );
 
 		sortList.sortable({
 			update: function(event, ui) {
-				$('#loading-animation').show(); // Show the animate loading gif while waiting
+				$( '#loading-animation' ).show(); // Show the animate loading gif while waiting
 
 				opts = {
 					url: ajaxurl, // ajaxurl is defined by WordPress and points to /wp-admin/admin-ajax.php
@@ -15,17 +15,17 @@ jQuery(document).ready(function($) {
 					dataType: 'json',
 					data:{
 						action: 'save_sort', // Tell WordPress how to handle this ajax request
-						order: sortList.sortable('toArray').toString() // Passes ID's of list items in	1,3,2 format
+						order: sortList.sortable( 'toArray' ).toString() // Passes ID's of list items in	1,3,2 format
 					},
 					success: function(response) {
-						$('div#message').remove();
-						$('#loading-animation').hide(); // Hide the loading animation
-						$('div#jobs-admin-sort h2:first').after('<div id="message" class="updated below-h2"><p>Jobs sort order has been saved</p></div>');
+						$( 'div#message' ).remove();
+						$( '#loading-animation' ).hide(); // Hide the loading animation
+						$( 'div#jobs-admin-sort h2:first' ).after( '<div id="message" class="updated below-h2"><p>Jobs sort order has been saved</p></div>' );
 						return;
 					},
 					error: function(xhr,textStatus,e) {
-						$('#loading-animation').hide(); // Hide the loading animation
-						$('div#jobs-admin-sort h2:first').after('<div id="message" class="error below-h2"><p>There was an error saving the sort order. Please try again later.</p></div>');
+						$( '#loading-animation' ).hide(); // Hide the loading animation
+						$( 'div#jobs-admin-sort h2:first' ).after( '<div id="message" class="error below-h2"><p>There was an error saving the sort order. Please try again later.</p></div>' );
 						return;
 					}
 				};

programming_language: JavaScript
filename: render-admin.php
change_type: ModificationType.MODIFY
diff: @@ -4,23 +4,26 @@ function hrm_jobs_render_admin() {
 	$args = array(
 		'post_type' => 'job',
 		'orderby' => 'menu_order',
-		'order' => 'ASC'
+		'order' => 'ASC',
+		'post_per_page' => 100, /* add a reasonable max # rows */
+		'no_found_rows' => true, /* don't generate a count as part of query */
+
 	);
 
 	$jobs = new WP_Query( $args );
 	?>
 		<div id="jobs-admin-sort" class="wrap">
 		<div id="icon-job-admin" class="icon32"><br /></div>
-		<h2><?php _e('Sort Job Positions', 'hrm_jobs'); ?> <img src=" <?php echo admin_url(); ?>/images/loading.gif" id="loading-animation" /></h2>
+		<h2><?php _e('Sort Job Positions', 'hrm_jobs'); ?> <img src="<?php echo esc_url( admin_url() . '/images/loading.gif' ); ?>" id="loading-animation" /></h2>
 			<?php if ( $jobs->have_posts() ) : ?>
-	    	<p><?php _e('<strong>Note:</strong> this only affects the Jobs listed using the shortcode functions', 'hrm_jobs'); ?></p>
+			<p><?php _e('<strong>Note:</strong> this only affects the Jobs listed using the shortcode functions', 'hrm_jobs'); ?></p>
 			<ul id="custom-type-list">
 				<?php while ( $jobs->have_posts() ) : $jobs->the_post(); ?>
 					<li id="<?php the_id(); ?>"><?php the_title(); ?></li>
 				<?php endwhile; ?>
-	    	</ul>
+			</ul>
 			<?php else: ?>
-			<p><?php _e('You have no Jobs to sort.', 'hrm_jobs'); ?></p>
+			<p><?php _e( 'You have no Jobs to sort.', 'hrm_jobs' ); ?></p>
 			<?php endif; ?>
 		</div>
 
@@ -31,11 +34,14 @@ add_action( 'admin_menu', 'hrm_jobs_add_menu_page');
 
 function hrm_jobs_save_order() {
 
+	//@todo add a nonce here to verify user intent
+	//@todo add a capability check to ensure use caps
+
 	global $wpdb; // WordPress database class
 		$order = explode(',', $_POST['order']);
 		$counter = 0;
 		foreach ($order as $item_id) {
-			$wpdb->update($wpdb->posts, array( 'menu_order' => $counter ), array( 'ID' => $item_id) );
+			$wpdb->update( $wpdb->posts, array( 'menu_order' => $counter ), array( 'ID' => (int) $item_id) );
 			$counter++;
 		}
 		die(1);

programming_language: PHP