Issues (4967)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/wp-admin/update.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Update/Install Plugin/Theme administration panel.
4
 *
5
 * @package WordPress
6
 * @subpackage Administration
7
 */
8
9 View Code Duplication
if ( ! defined( 'IFRAME_REQUEST' ) && isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'update-selected', 'activate-plugin', 'update-selected-themes' ) ) )
10
	define( 'IFRAME_REQUEST', true );
11
12
/** WordPress Administration Bootstrap */
13
require_once( dirname( __FILE__ ) . '/admin.php' );
14
15
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
16
17
if ( isset($_GET['action']) ) {
18
	$plugin = isset($_REQUEST['plugin']) ? trim($_REQUEST['plugin']) : '';
19
	$theme = isset($_REQUEST['theme']) ? urldecode($_REQUEST['theme']) : '';
20
	$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
21
22
	if ( 'update-selected' == $action ) {
23
		if ( ! current_user_can( 'update_plugins' ) )
24
			wp_die( __( 'Sorry, you are not allowed to update plugins for this site.' ) );
25
26
		check_admin_referer( 'bulk-update-plugins' );
27
28
		if ( isset( $_GET['plugins'] ) )
29
			$plugins = explode( ',', stripslashes($_GET['plugins']) );
30
		elseif ( isset( $_POST['checked'] ) )
31
			$plugins = (array) $_POST['checked'];
32
		else
33
			$plugins = array();
34
35
		$plugins = array_map('urldecode', $plugins);
36
37
		$url = 'update.php?action=update-selected&amp;plugins=' . urlencode(implode(',', $plugins));
38
		$nonce = 'bulk-update-plugins';
39
40
		wp_enqueue_script( 'updates' );
41
		iframe_header();
42
43
		$upgrader = new Plugin_Upgrader( new Bulk_Plugin_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
44
		$upgrader->bulk_upgrade( $plugins );
45
46
		iframe_footer();
47
48
	} elseif ( 'upgrade-plugin' == $action ) {
49
		if ( ! current_user_can('update_plugins') )
50
			wp_die(__('Sorry, you are not allowed to update plugins for this site.'));
51
52
		check_admin_referer('upgrade-plugin_' . $plugin);
53
54
		$title = __('Update Plugin');
55
		$parent_file = 'plugins.php';
56
		$submenu_file = 'plugins.php';
57
58
		wp_enqueue_script( 'updates' );
59
		require_once(ABSPATH . 'wp-admin/admin-header.php');
60
61
		$nonce = 'upgrade-plugin_' . $plugin;
62
		$url = 'update.php?action=upgrade-plugin&plugin=' . urlencode( $plugin );
63
64
		$upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) );
65
		$upgrader->upgrade($plugin);
66
67
		include(ABSPATH . 'wp-admin/admin-footer.php');
68
69
	} elseif ('activate-plugin' == $action ) {
70
		if ( ! current_user_can('update_plugins') )
71
			wp_die(__('Sorry, you are not allowed to update plugins for this site.'));
72
73
		check_admin_referer('activate-plugin_' . $plugin);
74
		if ( ! isset($_GET['failure']) && ! isset($_GET['success']) ) {
75
			wp_redirect( admin_url('update.php?action=activate-plugin&failure=true&plugin=' . urlencode( $plugin ) . '&_wpnonce=' . $_GET['_wpnonce']) );
76
			activate_plugin( $plugin, '', ! empty( $_GET['networkwide'] ), true );
77
			wp_redirect( admin_url('update.php?action=activate-plugin&success=true&plugin=' . urlencode( $plugin ) . '&_wpnonce=' . $_GET['_wpnonce']) );
78
			die();
79
		}
80
		iframe_header( __('Plugin Reactivation'), true );
81
		if ( isset($_GET['success']) )
82
			echo '<p>' . __('Plugin reactivated successfully.') . '</p>';
83
84
		if ( isset($_GET['failure']) ){
85
			echo '<p>' . __('Plugin failed to reactivate due to a fatal error.') . '</p>';
86
87
			error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
88
			@ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
89
			wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
90
			include( WP_PLUGIN_DIR . '/' . $plugin );
91
		}
92
		iframe_footer();
93
	} elseif ( 'install-plugin' == $action ) {
94
95
		if ( ! current_user_can('install_plugins') )
96
			wp_die( __( 'Sorry, you are not allowed to install plugins on this site.' ) );
97
98
		include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
99
100
		check_admin_referer( 'install-plugin_' . $plugin );
101
		$api = plugins_api( 'plugin_information', array(
102
			'slug' => $plugin,
103
			'fields' => array(
104
				'short_description' => false,
105
				'sections' => false,
106
				'requires' => false,
107
				'rating' => false,
108
				'ratings' => false,
109
				'downloaded' => false,
110
				'last_updated' => false,
111
				'added' => false,
112
				'tags' => false,
113
				'compatibility' => false,
114
				'homepage' => false,
115
				'donate_link' => false,
116
			),
117
		) );
118
119
		if ( is_wp_error( $api ) ) {
120
	 		wp_die( $api );
121
		}
122
123
		$title = __('Plugin Install');
124
		$parent_file = 'plugins.php';
125
		$submenu_file = 'plugin-install.php';
126
		require_once(ABSPATH . 'wp-admin/admin-header.php');
127
128
		$title = sprintf( __('Installing Plugin: %s'), $api->name . ' ' . $api->version );
129
		$nonce = 'install-plugin_' . $plugin;
130
		$url = 'update.php?action=install-plugin&plugin=' . urlencode( $plugin );
131
		if ( isset($_GET['from']) )
132
			$url .= '&from=' . urlencode(stripslashes($_GET['from']));
133
134
		$type = 'web'; //Install plugin type, From Web or an Upload.
135
136
		$upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) );
137
		$upgrader->install($api->download_link);
138
139
		include(ABSPATH . 'wp-admin/admin-footer.php');
140
141 View Code Duplication
	} elseif ( 'upload-plugin' == $action ) {
142
143
		if ( ! current_user_can( 'upload_plugins' ) ) {
144
			wp_die( __( 'Sorry, you are not allowed to install plugins on this site.' ) );
145
		}
146
147
		check_admin_referer('plugin-upload');
148
149
		$file_upload = new File_Upload_Upgrader('pluginzip', 'package');
150
151
		$title = __('Upload Plugin');
152
		$parent_file = 'plugins.php';
153
		$submenu_file = 'plugin-install.php';
154
		require_once(ABSPATH . 'wp-admin/admin-header.php');
155
156
		$title = sprintf( __('Installing Plugin from uploaded file: %s'), esc_html( basename( $file_upload->filename ) ) );
157
		$nonce = 'plugin-upload';
158
		$url = add_query_arg(array('package' => $file_upload->id), 'update.php?action=upload-plugin');
159
		$type = 'upload'; //Install plugin type, From Web or an Upload.
160
161
		$upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) );
162
		$result = $upgrader->install( $file_upload->package );
163
164
		if ( $result || is_wp_error($result) )
165
			$file_upload->cleanup();
166
167
		include(ABSPATH . 'wp-admin/admin-footer.php');
168
169
	} elseif ( 'upgrade-theme' == $action ) {
170
171
		if ( ! current_user_can('update_themes') )
172
			wp_die(__('Sorry, you are not allowed to update themes for this site.'));
173
174
		check_admin_referer('upgrade-theme_' . $theme);
175
176
		wp_enqueue_script( 'customize-loader' );
177
		wp_enqueue_script( 'updates' );
178
179
		$title = __('Update Theme');
180
		$parent_file = 'themes.php';
181
		$submenu_file = 'themes.php';
182
		require_once(ABSPATH . 'wp-admin/admin-header.php');
183
184
		$nonce = 'upgrade-theme_' . $theme;
185
		$url = 'update.php?action=upgrade-theme&theme=' . urlencode( $theme );
186
187
		$upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( compact('title', 'nonce', 'url', 'theme') ) );
188
		$upgrader->upgrade($theme);
189
190
		include(ABSPATH . 'wp-admin/admin-footer.php');
191
	} elseif ( 'update-selected-themes' == $action ) {
192
		if ( ! current_user_can( 'update_themes' ) )
193
			wp_die( __( 'Sorry, you are not allowed to update themes for this site.' ) );
194
195
		check_admin_referer( 'bulk-update-themes' );
196
197
		if ( isset( $_GET['themes'] ) )
198
			$themes = explode( ',', stripslashes($_GET['themes']) );
199
		elseif ( isset( $_POST['checked'] ) )
200
			$themes = (array) $_POST['checked'];
201
		else
202
			$themes = array();
203
204
		$themes = array_map('urldecode', $themes);
205
206
		$url = 'update.php?action=update-selected-themes&amp;themes=' . urlencode(implode(',', $themes));
207
		$nonce = 'bulk-update-themes';
208
209
		wp_enqueue_script( 'updates' );
210
		iframe_header();
211
212
		$upgrader = new Theme_Upgrader( new Bulk_Theme_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
213
		$upgrader->bulk_upgrade( $themes );
214
215
		iframe_footer();
216
	} elseif ( 'install-theme' == $action ) {
217
218
		if ( ! current_user_can('install_themes') )
219
			wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) );
220
221
		include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); //for themes_api..
222
223
		check_admin_referer( 'install-theme_' . $theme );
224
		$api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false, 'tags' => false) ) ); //Save on a bit of bandwidth.
225
226
		if ( is_wp_error($api) )
227
	 		wp_die($api);
228
229
		wp_enqueue_script( 'customize-loader' );
230
231
		$title = __('Install Themes');
232
		$parent_file = 'themes.php';
233
		$submenu_file = 'themes.php';
234
		require_once(ABSPATH . 'wp-admin/admin-header.php');
235
236
		$title = sprintf( __('Installing Theme: %s'), $api->name . ' ' . $api->version );
237
		$nonce = 'install-theme_' . $theme;
238
		$url = 'update.php?action=install-theme&theme=' . urlencode( $theme );
239
		$type = 'web'; //Install theme type, From Web or an Upload.
240
241
		$upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) );
242
		$upgrader->install($api->download_link);
243
244
		include(ABSPATH . 'wp-admin/admin-footer.php');
245
246 View Code Duplication
	} elseif ( 'upload-theme' == $action ) {
247
248
		if ( ! current_user_can( 'upload_themes' ) ) {
249
			wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) );
250
		}
251
252
		check_admin_referer('theme-upload');
253
254
		$file_upload = new File_Upload_Upgrader('themezip', 'package');
255
256
		wp_enqueue_script( 'customize-loader' );
257
258
		$title = __('Upload Theme');
259
		$parent_file = 'themes.php';
260
		$submenu_file = 'theme-install.php';
261
262
		require_once(ABSPATH . 'wp-admin/admin-header.php');
263
264
		$title = sprintf( __('Installing Theme from uploaded file: %s'), esc_html( basename( $file_upload->filename ) ) );
265
		$nonce = 'theme-upload';
266
		$url = add_query_arg(array('package' => $file_upload->id), 'update.php?action=upload-theme');
267
		$type = 'upload'; //Install plugin type, From Web or an Upload.
268
269
		$upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) );
270
		$result = $upgrader->install( $file_upload->package );
271
272
		if ( $result || is_wp_error($result) )
273
			$file_upload->cleanup();
274
275
		include(ABSPATH . 'wp-admin/admin-footer.php');
276
277
	} else {
278
		/**
279
		 * Fires when a custom plugin or theme update request is received.
280
		 *
281
		 * The dynamic portion of the hook name, `$action`, refers to the action
282
		 * provided in the request for wp-admin/update.php. Can be used to
283
		 * provide custom update functionality for themes and plugins.
284
		 *
285
		 * @since 2.8.0
286
		 */
287
		do_action( "update-custom_{$action}" );
288
	}
289
}
290