Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/ezoic-integration/ezoic-integration.php
+++ b/ezoic-integration/ezoic-integration.php
@@ -18,7 +18,7 @@
* Plugin Name: Ezoic
* Plugin URI: https://ezoic.com/
* Description: Easily integrate and connect with Ezoic using WordPress. In order to activate this plugin properly you will need an Ezoic account. You can create an account here: https://pubdash.ezoic.com/join
- * Version: 2.23.0
+ * Version: 2.23.1
* Author: Ezoic Inc.
* Author URI: https://ezoic.com/
* License: GPL-2.0+
@@ -37,7 +37,7 @@
*/
if ( ! defined( 'EZOIC_INTEGRATION_VERSION' ) ) {
- define( 'EZOIC_INTEGRATION_VERSION', '2.23.0' ); // also update version in 'class-ezoic-integration-factory.php'.
+ define( 'EZOIC_INTEGRATION_VERSION', '2.23.1' ); // also update version in 'class-ezoic-integration-factory.php'.
}
define( 'EZOIC__PLUGIN_NAME', 'Ezoic' );
define( 'EZOIC__PLUGIN_SLUG', dirname( plugin_basename( __FILE__ ) ) );
--- a/ezoic-integration/includes/class-ezoic-integration-factory.php
+++ b/ezoic-integration/includes/class-ezoic-integration-factory.php
@@ -6,7 +6,7 @@
namespace Ezoic_Namespace {
if ( ! defined( 'EZOIC_INTEGRATION_VERSION' ) ) {
- define( 'EZOIC_INTEGRATION_VERSION', '2.23.0' ); // update plugin version number
+ define( 'EZOIC_INTEGRATION_VERSION', '2.23.1' ); // update plugin version number
}
if ( ! defined( 'EZOIC_API_VERSION' ) ) {
--- a/ezoic-integration/includes/content/class-ezoic-content-export.php
+++ b/ezoic-integration/includes/content/class-ezoic-content-export.php
@@ -17,12 +17,53 @@
abstract public function get_module_name();
public function check_headers( $request ) {
- // $is_export_request = $request->get_header( $this->get_request_header() );
- // if ( is_null( $is_export_request ) || $is_export_request != 'true' ) {
- // return false;
- // }
+ return self::verify_content_signature(
+ $request->get_header( 'x-ezoic-content-auth' ),
+ (int) $request->get_header( 'x-ezoic-content-ts' )
+ );
+ }
+
+ /**
+ * Verifies the HMAC signature that authenticates every content-module request.
+ *
+ * Signing contract (backend callers must match this byte-for-byte):
+ * X-Ezoic-Content-Ts: current unix timestamp (seconds), accepted within +/- 300s
+ * X-Ezoic-Content-Auth: lowercase hex of HMAC-SHA256( key, message ) where
+ * key = the site's Ezoic OAuth client secret (plaintext value of the
+ * 'ezoic_auth_client_secret' option, issued at account linking)
+ * message = site_url() . ':' . ts
+ *
+ * site_url() is WordPress's exact stored value ('siteurl' option): scheme + host
+ * (+ optional path), no trailing slash — e.g. "https://example.com". Callers must
+ * sign the identical string; any scheme/host/trailing-slash difference fails
+ * verification and returns 401 to the caller.
+ *
+ * Fails closed: a site with no linked Ezoic OAuth secret has no legitimate
+ * content traffic, so every request is rejected.
+ */
+ public static function verify_content_signature( $provided_hmac, $ts ) {
+ if ( empty( $provided_hmac ) || empty( $ts ) ) {
+ return false;
+ }
+
+ $enc = get_option( 'ezoic_auth_client_secret' );
+ if ( ! $enc ) {
+ return false;
+ }
+
+ $secret = Ezoic_Auth::decrypt_secret( $enc );
+ if ( empty( $secret ) ) {
+ return false;
+ }
+
+ $ts = (int) $ts;
+ if ( abs( time() - $ts ) > 300 ) {
+ return false;
+ }
+
+ $expected = hash_hmac( 'sha256', site_url() . ':' . $ts, $secret );
- return true;
+ return hash_equals( $expected, (string) $provided_hmac );
}
protected function run_or_schedule_export( $request ) {
--- a/ezoic-integration/includes/content/cms/class-ezoic-cms-export.php
+++ b/ezoic-integration/includes/content/cms/class-ezoic-cms-export.php
@@ -63,7 +63,7 @@
register_rest_route('ezoic-cms/v1', '/export/verify', array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'verify_export_files' ),
- 'permission_callback' => '__return_true',
+ 'permission_callback' => array( $this, 'check_headers' ),
'show_in_index' => false,
));
--- a/ezoic-integration/includes/content/cms/class-ezoic-cms-sync.php
+++ b/ezoic-integration/includes/content/cms/class-ezoic-cms-sync.php
@@ -4,11 +4,18 @@
class Ezoic_CMS_Sync {
+ public function verify_content_request( $request ) {
+ return Ezoic_Content_Export::verify_content_signature(
+ $request->get_header( 'x-ezoic-content-auth' ),
+ (int) $request->get_header( 'x-ezoic-content-ts' )
+ );
+ }
+
public function ez_cms_sync_options_endpoint() {
register_rest_route( 'ezoic-cms/v1', '/sync/options', array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'ez_cms_sync_options' ),
- 'permission_callback' => '__return_true',
+ 'permission_callback' => array( $this, 'verify_content_request' ),
'show_in_index' => false,
));
}
@@ -17,7 +24,7 @@
register_rest_route( 'ezoic-cms/v1', '/sync/theme', array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'ez_cms_sync_origin_theme' ),
- 'permission_callback' => '__return_true',
+ 'permission_callback' => array( $this, 'verify_content_request' ),
'show_in_index' => false,
));
}
@@ -26,7 +33,7 @@
register_rest_route( 'ezoic-cms/v1', '/sync/linklists', array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'ez_cms_get_menus_and_send' ),
- 'permission_callback' => '__return_true',
+ 'permission_callback' => array( $this, 'verify_content_request' ),
'show_in_index' => false,
));
}
--- a/ezoic-integration/includes/content/cms/class-ezoic-cms.php
+++ b/ezoic-integration/includes/content/cms/class-ezoic-cms.php
@@ -111,11 +111,16 @@
$value = self::$is_enabled;
// If feature header is present, set option accordingly
if ( isset( $_SERVER[ 'HTTP_X_EZOIC_CMS' ] ) ) {
- $value = $_SERVER[ 'HTTP_X_EZOIC_CMS' ];
+ if ( Ezoic_Content_Export::verify_content_signature(
+ isset( $_SERVER['HTTP_X_EZOIC_CONTENT_AUTH'] ) ? $_SERVER['HTTP_X_EZOIC_CONTENT_AUTH'] : '',
+ isset( $_SERVER['HTTP_X_EZOIC_CONTENT_TS'] ) ? (int) $_SERVER['HTTP_X_EZOIC_CONTENT_TS'] : 0
+ ) ) {
+ $value = $_SERVER[ 'HTTP_X_EZOIC_CMS' ];
- self::$is_enabled = $value;
+ self::$is_enabled = $value;
- update_option( 'ez_cms_enabled', $value );
+ update_option( 'ez_cms_enabled', $value );
+ }
}
if ($value == null) {
--- a/ezoic-integration/includes/content/emote/class-ezoic-emote-export.php
+++ b/ezoic-integration/includes/content/emote/class-ezoic-emote-export.php
@@ -18,6 +18,9 @@
private $export_archive_name;
private $export_module;
+ /** @var array<string, bool> Per-request memo of emote key -> verify result. */
+ private static $emote_key_cache = array();
+
public function __construct() {
$this->export_transient = 'ezoic_emote_export';
$this->export_request_header = 'x-ezoic-emote-export';
@@ -67,7 +70,7 @@
register_rest_route('ezoic-emote/v1', '/export/verify', array(
'methods' => WP_REST_Server::READABLE,
'callback' => array($this, 'verify_export_files'),
- 'permission_callback' => '__return_true',
+ 'permission_callback' => array( $this, 'check_headers' ),
'show_in_index' => false,
));
@@ -88,25 +91,38 @@
register_rest_route( 'ezoic-emote/v1', '/replace', array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $this, 'emote_replace_toggle' ),
- 'permission_callback' => array( $this, 'check_headers' ),
+ 'permission_callback' => array( $this, 'check_emote_credential' ),
'show_in_index' => false,
));
register_rest_route( 'ezoic-emote/v1', '/emote', array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $this, 'emote_toggle' ),
- 'permission_callback' => array( $this, 'check_headers' ),
+ 'permission_callback' => array( $this, 'check_emote_credential' ),
'show_in_index' => false,
));
register_rest_route( 'ezoic-emote/v1', '/emote-check', array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $this, 'emote_check' ),
- 'permission_callback' => array( $this, 'check_headers' ),
+ 'permission_callback' => array( $this, 'check_emote_credential' ),
'show_in_index' => false,
));
}
+ /**
+ * Permission callback for emote toggle routes (/replace, /emote, /emote-check).
+ * publisher-backend reaches these with a per-domain emote key in the JSON body
+ * rather than an HMAC, so both credentials are accepted. Export routes remain
+ * HMAC-only via check_headers.
+ */
+ public function check_emote_credential( $request ) {
+ if ( $this->check_headers( $request ) ) {
+ return true;
+ }
+ return $this->verify_emote_key( $request->get_param( 'key' ) );
+ }
+
public function emote_replace_toggle ( $request ) {
$is_enabled = $request->get_param('is_enabled');
$emote_key = $request->get_param('key');
@@ -158,6 +174,14 @@
}
private function verify_emote_key ( $key ) {
+ if ( ! is_string( $key ) || $key === '' ) {
+ return false;
+ }
+
+ if ( array_key_exists( $key, self::$emote_key_cache ) ) {
+ return self::$emote_key_cache[ $key ];
+ }
+
$api_url = 'https://i.emote.com/api/domain/auth/verify';
$body_data = json_encode( array( 'key' => $key, 'domain' => site_url() ) );
@@ -170,18 +194,19 @@
$response = wp_remote_post( $api_url, $request_args );
- if (is_wp_error($response)) {
- error_log('Error making API request: ' . $response->get_error_message());
- return false;
+ $result = false;
+ if ( is_wp_error( $response ) ) {
+ error_log( 'Error making API request: ' . $response->get_error_message() );
} else {
- $response_body = wp_remote_retrieve_body($response);
- error_log('Error making API request: ' . $response_body);
- $data = json_decode($response_body, true);
- if (isset($data['success']) && is_bool($data['success'])) {
- return $data['success'];
+ $response_body = wp_remote_retrieve_body( $response );
+ $data = json_decode( $response_body, true );
+ if ( isset( $data['success'] ) && is_bool( $data['success'] ) ) {
+ $result = $data['success'];
}
}
- return false;
+
+ self::$emote_key_cache[ $key ] = $result;
+ return $result;
}
public function initiate_export_event ( $request ) {
--- a/ezoic-integration/includes/content/emote/class-ezoic-emote.php
+++ b/ezoic-integration/includes/content/emote/class-ezoic-emote.php
@@ -63,11 +63,16 @@
$value = self::$is_enabled;
// If feature header is present, set option accordingly
if ( isset( $_SERVER[ 'HTTP_X_EMOTE' ] ) ) {
- $value = $_SERVER[ 'HTTP_X_EMOTE' ];
+ if ( Ezoic_Content_Export::verify_content_signature(
+ isset( $_SERVER['HTTP_X_EZOIC_CONTENT_AUTH'] ) ? $_SERVER['HTTP_X_EZOIC_CONTENT_AUTH'] : '',
+ isset( $_SERVER['HTTP_X_EZOIC_CONTENT_TS'] ) ? (int) $_SERVER['HTTP_X_EZOIC_CONTENT_TS'] : 0
+ ) ) {
+ $value = $_SERVER[ 'HTTP_X_EMOTE' ];
- self::$is_enabled = $value;
+ self::$is_enabled = $value;
- update_option( 'ez_emote_enabled', $value );
+ update_option( 'ez_emote_enabled', $value );
+ }
}
if ($value == null) {
@@ -76,8 +81,8 @@
}
// Enable feature if needed
- $this->is_public_enabled = true;
- $this->is_admin_enabled = true;
+ $this->is_public_enabled = $value == 'true';
+ $this->is_admin_enabled = $value == 'true';
}
}