Authenticated Option Deletion Vulnerability in Social Media and Share Icons (Ultimate Social Media)
Recently we have been finding a lot of vulnerabilities in WordPress plugins through monitoring our websites for what look to be requests related to hacking attempts against plugins that don’t have known vulnerabilities and then checking over the plugins for exploitable vulnerabilities. That has lead to us finding quite a few vulnerabilities in the current versions of plugins. In attempt to catch more of this type of issue we have been looking around for more data so that we can catch more of these vulnerabilities. That lead us to look at the Social Media and Share Icons (Ultimate Social Media) plugin, despite it looking like it might not have been the target of a hacker. While reviewing that we found a fairly serious vulnerability, though not one that hackers would likely be interested in exploiting.
One of things we review during this type of check is AJAX accessible functions since we have seen those to be a frequent source of issues. Despite the fact that that all of the functions look to be intended only to be accessible to Administrator level users, no check was being done to insure that lower level users were not accessing them. Most of them were still protected to an extent due to fact that a valid nonce was being checked for. That wasn’t the case for the function sfsi_DeleteSkin(), which is located in the file /libs/controllers/sfsi_iconsUpload_contoller.php. While that function is intended for deleting custom skins for the the plugin, the code allows you to delete any option from the wp_options table, since it doesn’t do anything to limit what you can pass to the delete_option() function:
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | function sfsi_DeleteSkin() { $upload_dir = wp_upload_dir(); if($_REQUEST['action'] == 'DeleteSkin' && isset($_REQUEST['iconname']) && !empty($_REQUEST['iconname'])) { $imgurl = get_option( $_REQUEST['iconname'] ); $path = parse_url($imgurl, PHP_URL_PATH); if(is_file($_SERVER['DOCUMENT_ROOT'] . $path)) { unlink($_SERVER['DOCUMENT_ROOT'] . $path); } delete_option( $_REQUEST['iconname'] ); die(json_encode(array('res'=>'success'))); } else { die(json_encode(array('res'=>'error'))); } } |
Through that any logged in user could delete critical settings from website and make it non-functional.
After contacting the developer part of the issue was fixed in version 1.5.2, you can see that there is now a nonce check and the options that can be deleted is limited. That prevents the vulnerability from being exploited, but this function and the rest of the AJAX accessible still lack a proper check to make sure that lower level users are not accessing it.
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 | function sfsi_DeleteSkin() { if ( !wp_verify_nonce( $_POST['nonce'], "deleteCustomSkin")) { echo json_encode(array('res'=>"error")); exit; } $upload_dir = wp_upload_dir(); if($_POST['action'] == 'DeleteSkin' &&; isset($_POST['iconname']) && !empty($_POST['iconname']) && current_user_can('manage_options')) { $iconsArray = array( "rss_skin","email_skin","facebook_skin","twitter_skin","google_skin", "share_skin","youtube_skin","linkedin_skin","pintrest_skin","instagram_skin" ); if(in_array($_POST['iconname'], $iconsArray)) { $imgurl = get_option( $_POST['iconname'] ); $path = parse_url($imgurl, PHP_URL_PATH); if(is_file($_SERVER['DOCUMENT_ROOT'] . $path)) { unlink($_SERVER['DOCUMENT_ROOT'] . $path); } delete_option( $_POST['iconname'] ); die(json_encode(array('res'=>'success'))); } else { die(json_encode(array('res'=>'error'))); } } else { die(json_encode(array('res'=>'error'))); } } |
Proof of Concept
The following proof of concept will delete the siteurl option wp_options table, when logged in to WordPress.
Make sure to replace “[path to WordPress]” with the location of WordPress.
http://[path to WordPress]/wp-admin/admin-ajax.php?action=DeleteSkin&iconname=siteurl
Timeline
- 6/23/2016 – Developer notified.
- 6/28/2106 – Version 1.5.2 released, which fixes issue.