Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/social-photo-feed-widget/include/trustindex-elementor-widgets.php
+++ b/social-photo-feed-widget/include/trustindex-elementor-widgets.php
@@ -18,7 +18,7 @@
return ['trustindex'];
}
protected function render() {
-$pluginManagerInstance = new TRUSTINDEX_Feed_Instagram("instagram", __FILE__, "1.7.9", "Widgets for Social Photo Feed", "Instagram");
+$pluginManagerInstance = new TRUSTINDEX_Feed_Instagram("instagram", __FILE__, "1.8", "Widgets for Social Photo Feed", "Instagram");
echo do_shortcode('['.$pluginManagerInstance->getShortcodeName().']');
}
}
--- a/social-photo-feed-widget/social-photo-feed-widget.php
+++ b/social-photo-feed-widget/social-photo-feed-widget.php
@@ -5,7 +5,7 @@
Plugin URI: https://wordpress.org/plugins/social-photo-feed-widget/
Description: Instagram Feed Widgets. Display your Instagram feed on your website to increase engagement, sales and SEO.
Tags: instagram, instagram feed, instagram gallery, instagram photos, instagram widget
-Version: 1.7.9
+Version: 1.8
Requires at least: 6.2
Requires PHP: 7.0
Author: Trustindex.io <support@trustindex.io>
@@ -27,7 +27,7 @@
defined('ABSPATH') or die('No script kiddies please!');
require_once plugin_dir_path(__FILE__) . 'include' . DIRECTORY_SEPARATOR . 'cache-plugin-filters.php';
require_once plugin_dir_path( __FILE__ ) . 'trustindex-feed-plugin.class.php';
-$trustindex_feed_instagram = new TRUSTINDEX_Feed_Instagram("instagram", __FILE__, "1.7.9", "Widgets for Social Photo Feed", "Instagram");
+$trustindex_feed_instagram = new TRUSTINDEX_Feed_Instagram("instagram", __FILE__, "1.8", "Widgets for Social Photo Feed", "Instagram");
$pluginManagerInstance = $trustindex_feed_instagram;
register_activation_hook(__FILE__, [ $pluginManagerInstance, 'activate' ]);
register_deactivation_hook(__FILE__, [ $pluginManagerInstance, 'deactivate' ]);
--- a/social-photo-feed-widget/tabs/advanced.php
+++ b/social-photo-feed-widget/tabs/advanced.php
@@ -37,7 +37,7 @@
}
$yesIcon = '<span class="dashicons dashicons-yes-alt"></span>';
$noIcon = '<span class="dashicons dashicons-dismiss"></span>';
-$pluginUpdated = ($pluginManagerInstance->getPluginCurrentVersion() <= "1.7.9");
+$pluginUpdated = ($pluginManagerInstance->getPluginCurrentVersion() <= "1.8");
$cssInline = get_option($pluginManagerInstance->getOptionName('load-css-inline'), 0);
$css = get_option($pluginManagerInstance->getOptionName('css-content'));
?>
--- a/social-photo-feed-widget/tabs/feed-configurator.php
+++ b/social-photo-feed-widget/tabs/feed-configurator.php
@@ -45,7 +45,6 @@
delete_option($pluginManagerInstance->getOptionName('source'));
delete_option($pluginManagerInstance->getOptionName('feed-data'));
delete_option($pluginManagerInstance->getOptionName('feed-data-saved'));
-delete_option($pluginManagerInstance->getOptionName('public-id'));
delete_option($pluginManagerInstance->getOptionName('token-expires'));
delete_option($pluginManagerInstance->getOptionName('layout'));
delete_option($pluginManagerInstance->getOptionName('template'));
@@ -222,16 +221,12 @@
<input type="hidden" name="data" required="required" value="" />
</form>
<?php $connectUrl = 'https://admin.trustindex.io/source/edit_feed/type/Instagram/iframe/1'; ?>
-<?php
-if ($isReconnectingSource) {
-$connectUrl .= '/public_id/'.get_option($pluginManagerInstance->getOptionName('public-id'));
-}
-?>
<?php
$connectUrlParams = array_merge(
isset($connectPending['error']) ? [] : $connectPending,
array(
+'public_id' => get_option($pluginManagerInstance->getOptionName('public-id')),
'website' => esc_attr(urlencode(get_option('siteurl'))),
'version' => esc_attr($pluginManagerInstance->getVersion()),
),
--- a/social-photo-feed-widget/trustindex-feed-plugin.class.php
+++ b/social-photo-feed-widget/trustindex-feed-plugin.class.php
@@ -122,6 +122,25 @@
public function activate()
{
+$requestBody = [
+'platform' => 'Instagram',
+'website' => get_option('siteurl'),
+];
+$response = wp_remote_post('https://admin.trustindex.io/new/wordpress-feed/register', [
+'headers' => [
+'Content-Type' => 'application/x-www-form-urlencoded',
+'ti-secure' => hash_hmac('sha256', http_build_query($requestBody), '80ce0e06b31b34794f5088d4875480f1'),
+],
+'body' => $requestBody,
+'timeout' => '30',
+'sslverify' => false,
+]);
+if (is_wp_error($response)) {
+update_option($this->getOptionName('public-id'), $response->get_error_message(), false);
+return;
+}
+$data = json_decode(wp_remote_retrieve_body($response), true);
+update_option($this->getOptionName('public-id'), $data['public-id'] ?? $data['error'], false);
include $this->getPluginDir() . 'include' . DIRECTORY_SEPARATOR . 'activate.php';
if (!$this->getNotificationParam('rate-us', 'hidden', false) && $this->getNotificationParam('rate-us', 'active', true)) {
$this->setNotificationParam('rate-us', 'active', true);
@@ -5516,7 +5535,7 @@
return new WP_Error('expired', 'Request expired', ['status' => 401]);
}
$body = $request->get_body();
-$expected = hash_hmac('sha256', $body.$timestamp, get_option($this->getOptionName('public-id'), $request->get_param('data')['public_id']));
+$expected = hash_hmac('sha256', $body.$timestamp, get_option($this->getOptionName('public-id')));
if (!hash_equals($expected, $signature)) {
return new WP_Error('invalid_signature', 'Signature mismatch', ['status' => 403]);
}
--- a/social-photo-feed-widget/uninstall.php
+++ b/social-photo-feed-widget/uninstall.php
@@ -3,6 +3,6 @@
die;
}
require_once plugin_dir_path( __FILE__ ) . 'trustindex-feed-plugin.class.php';
-$trustindex_feed_instagram = new TRUSTINDEX_Feed_Instagram("instagram", __FILE__, "1.7.9", "Widgets for Social Photo Feed", "Instagram");
+$trustindex_feed_instagram = new TRUSTINDEX_Feed_Instagram("instagram", __FILE__, "1.8", "Widgets for Social Photo Feed", "Instagram");
$trustindex_feed_instagram->uninstall();
?>
No newline at end of file