Project: Wordpress Plugin Jetpack by WordPress.com 6.6.1

Vulnerability: #9217825 (2018-10-30 09:27:16)

Warning

There are many false positives, or unexploitable vulnerabilities. Please create working "PoC" exploit before reporting anything to vendor!

Details:

Sink Standard::http_build_query
Risk _POST
/jetpack/class.jetpack.php:5459 (show/hide source)
5439  			$user = new WP_User( $user_id );
5440  			if ( ! $user || ! $user->exists() ) {
5441  				return false;
5442  			}
5443  		}
5444  
5445  		$token = Jetpack_Data::get_access_token( $user_id );
5446  		if ( ! $token ) {
5447  			return false;
5448  		}
5449  
5450  		$token_check = "$token_key.";
5451  		if ( ! hash_equals( substr( $token->secret, 0, strlen( $token_check ) ), $token_check ) ) {
5452  			return false;
5453  		}
5454  
5455  		require_once JETPACK__PLUGIN_DIR . 'class.jetpack-signature.php';
5456  
5457  		$jetpack_signature = new Jetpack_Signature( $token->secret, (int) Jetpack_Options::get_option( 'time_diff' ) );
5458  		if ( isset( $_POST['_jetpack_is_multipart'] ) ) {
5459 $post_data = $_POST;
5460 $file_hashes = array(); 5461 foreach ( $post_data as $post_data_key => $post_data_value ) {
Threat level 1

Callstack:

Jetpack::verify_xml_rpc_signature /jetpack/class.jetpack.php:5476 (show/hide source)
5456  
5457  		$jetpack_signature = new Jetpack_Signature( $token->secret, (int) Jetpack_Options::get_option( 'time_diff' ) );
5458  		if ( isset( $_POST['_jetpack_is_multipart'] ) ) {
5459  			$post_data   = $_POST;
5460  			$file_hashes = array();
5461  			foreach ( $post_data as $post_data_key => $post_data_value ) {
5462  				if ( 0 !== strpos( $post_data_key, '_jetpack_file_hmac_' ) ) {
5463  					continue;
5464  				}
5465  				$post_data_key = substr( $post_data_key, strlen( '_jetpack_file_hmac_' ) );
5466  				$file_hashes[$post_data_key] = $post_data_value;
5467  			}
5468  
5469  			foreach ( $file_hashes as $post_data_key => $post_data_value ) {
5470  				unset( $post_data["_jetpack_file_hmac_{$post_data_key}"] );
5471  				$post_data[$post_data_key] = $post_data_value;
5472  			}
5473  
5474  			ksort( $post_data );
5475  
5476 $body = http_build_query( stripslashes_deep( $post_data ) );
5477 } elseif ( is_null( $this->HTTP_RAW_POST_DATA ) ) { 5478 $body = file_get_contents( 'php://input' );
Jetpack::__construct /jetpack/class.jetpack.php:556 (show/hide source)
536  		add_action( 'init', array( $this, 'load_jetpack_gutenberg' ) );
537  
538  		add_action( 'set_user_role', array( $this, 'maybe_clear_other_linked_admins_transient' ), 10, 3 );
539  
540  		// Unlink user before deleting the user from .com
541  		add_action( 'deleted_user', array( $this, 'unlink_user' ), 10, 1 );
542  		add_action( 'remove_user_from_blog', array( $this, 'unlink_user' ), 10, 1 );
543  
544  		if ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST && isset( $_GET['for'] ) && 'jetpack' == $_GET['for'] ) {
545  			@ini_set( 'display_errors', false ); // Display errors can cause the XML to be not well formed.
546  
547  			require_once JETPACK__PLUGIN_DIR . 'class.jetpack-xmlrpc-server.php';
548  			$this->xmlrpc_server = new Jetpack_XMLRPC_Server();
549  
550  			$this->require_jetpack_authentication();
551  
552  			if ( Jetpack::is_active() ) {
553  				// Hack to preserve $HTTP_RAW_POST_DATA
554  				add_filter( 'xmlrpc_methods', array( $this, 'xmlrpc_methods' ) );
555  
556 $signed = $this->verify_xml_rpc_signature();
557 if ( $signed && ! is_wp_error( $signed ) ) { 558 // The actual API methods.
Jetpack::init /jetpack/class.jetpack.php:352 (show/hide source)
332  	public $json_api_authorization_request = array();
333  
334  	/**
335  	 * @var string Transient key used to prevent multiple simultaneous plugin upgrades
336  	 */
337  	public static $plugin_upgrade_lock_key = 'jetpack_upgrade_lock';
338  
339  	/**
340  	 * Holds the singleton instance of this class
341  	 * @since 2.3.3
342  	 * @var Jetpack
343  	 */
344  	static $instance = false;
345  
346  	/**
347  	 * Singleton
348  	 * @static
349  	 */
350  	public static function init() {
351  		if ( ! self::$instance ) {
352 self::$instance = new Jetpack;
353 354 self::$instance->plugin_upgrade();
Jetpack::activate_module /jetpack/class.jetpack.php:2911 (show/hide source)
2891  		 *
2892  		 * @param string $min_version Minimum version number required to use modules.
2893  		 * @param string $max_version Maximum version number required to use modules.
2894  		 * @param array $other_modules Array of other modules to activate alongside the default modules.
2895  		 */
2896  		do_action( 'jetpack_activate_default_modules', $min_version, $max_version, $other_modules );
2897  	}
2898  
2899  	public static function activate_module( $module, $exit = true, $redirect = true ) {
2900  		/**
2901  		 * Fires before a module is activated.
2902  		 *
2903  		 * @since 2.6.0
2904  		 *
2905  		 * @param string $module Module slug.
2906  		 * @param bool $exit Should we exit after the module has been activated. Default to true.
2907  		 * @param bool $redirect Should the user be redirected after module activation? Default to true.
2908  		 */
2909  		do_action( 'jetpack_pre_activate_module', $module, $exit, $redirect );
2910  
2911 $jetpack = Jetpack::init();
2912 2913 if ( ! strlen( $module ) )
WPCOM_JSON_API_Site_Settings_Endpoint::update_settings /jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php:551 (show/hide source)
531  				case 'jetpack_protect_whitelist':
532  					if ( function_exists( 'jetpack_protect_save_whitelist' ) ) {
533  						$result = jetpack_protect_save_whitelist( $value );
534  						if ( is_wp_error( $result ) ) {
535  							return $result;
536  						}
537  						$updated[ $key ] = jetpack_protect_format_whitelist();
538  					}
539  					break;
540  				case 'jetpack_sync_non_public_post_stati':
541  					Jetpack_Options::update_option( 'sync_non_public_post_stati', $value );
542  					break;
543  				case 'jetpack_search_enabled':
544  					if ( ! method_exists( 'Jetpack', 'activate_module' ) ) {
545  						break;
546  					}
547  					$is_wpcom = defined( 'IS_WPCOM' ) && IS_WPCOM;
548  					if ( $value ) {
549  						$jetpack_search_update_success = $is_wpcom
550  							? Jetpack::activate_module( $blog_id, 'search' )
551 : Jetpack::activate_module( 'search', false, false );
552 } else { 553 $jetpack_search_update_success = $is_wpcom
WPCOM_JSON_API_Site_Settings_Endpoint::callback /jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php:161 (show/hide source)
141  
142  		if ( ! is_user_logged_in() ) {
143  			return new WP_Error( 'Unauthorized', 'You must be logged-in to manage settings.', 401 );
144  		} else if ( ! current_user_can( 'manage_options' ) ) {
145  			return new WP_Error( 'Forbidden', 'You do not have the capability to manage settings for this site.', 403 );
146  		}
147  
148  		if ( 'GET' === $this->api->method ) {
149  			/**
150  			 * Fires on each GET request to a specific endpoint.
151  			 *
152  			 * @module json-api
153  			 *
154  			 * @since 3.2.0
155  			 *
156  			 * @param string sites.
157  			 */
158  			do_action( 'wpcom_json_api_objects', 'sites' );
159  			return $this->get_settings_response();
160  		} else if ( 'POST' === $this->api->method ) {
161 return $this->update_settings();
162 } else { 163 return new WP_Error( 'bad_request', 'An unsupported request method was used.' );
WPCOM_JSON_API_Site_Settings_V1_2_Endpoint::callback /jetpack/json-endpoints/class.wpcom-json-api-site-settings-v1-2-endpoint.php:130 (show/hide source)
110  	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/settings?pretty=1',
111  ) );
112  
113  class WPCOM_JSON_API_Site_Settings_V1_2_Endpoint extends WPCOM_JSON_API_Site_Settings_Endpoint {
114  
115  	public static $site_format = array(
116  		'ID'             => '(int) Site ID',
117  		'name'           => '(string) Title of site',
118  		'description'    => '(string) Tagline or description of site',
119  		'URL'            => '(string) Full URL to the site',
120  		'locale'         => '(string) Locale code of the site',
121  		'locale_variant' => '(string) Locale variant code for the site, if set',
122  		'settings'       => '(array) An array of options/settings for the blog. Only viewable by users with post editing rights to the site.',
123  	);
124  
125  
126  	function callback( $path = '', $blog_id = 0 ) {
127  		add_filter( 'site_settings_endpoint_update_locale', array( $this, 'update_locale' ) );
128  		add_filter( 'site_settings_endpoint_get',           array( $this, 'return_locale' ) );
129  		add_filter( 'site_settings_site_format',            array( $this, 'site_format' ) );
130 return parent::callback( $path, $blog_id );
131 } 132