Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/yop-poll/build/admin.asset.php
+++ b/yop-poll/build/admin.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '21c3160f6f8b0e088808');
+<?php return array('dependencies' => array('lodash', 'react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '0679579517c037dd8712');
--- a/yop-poll/build/frontend.asset.php
+++ b/yop-poll/build/frontend.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react-jsx-runtime', 'wp-api-fetch', 'wp-element', 'wp-i18n'), 'version' => '3edf8aaeff40ad1ea880');
+<?php return array('dependencies' => array('react-jsx-runtime', 'wp-api-fetch', 'wp-element', 'wp-i18n'), 'version' => '65890347d9fdb0cbe645');
--- a/yop-poll/includes/REST/class-rest-auth.php
+++ b/yop-poll/includes/REST/class-rest-auth.php
@@ -15,6 +15,44 @@
'permission_callback' => '__return_true',
),
) );
+
+ register_rest_route( $this->namespace, '/auth/status', array(
+ array(
+ 'methods' => WP_REST_Server::READABLE,
+ 'callback' => array( $this, 'auth_status' ),
+ 'permission_callback' => '__return_true',
+ ),
+ ) );
+ }
+
+ /**
+ * Report whether the current visitor is logged in, and hand back fresh
+ * nonces bound to that user. The frontend polls this while a WP login/
+ * registration popup is open, so voting works regardless of where the
+ * popup finally lands (core login, WooCommerce My Account, registration,
+ * social-login plugins, etc.) instead of relying on the redirect hitting
+ * wp_login_redirect().
+ */
+ public function auth_status( $request ) {
+ // The REST cookie-auth middleware calls wp_set_current_user(0) when no
+ // _wpnonce is present. Re-authenticate from the session cookie so the
+ // nonces bind to the just-logged-in user, not user 0.
+ if ( ! is_user_logged_in() ) {
+ $user_id = wp_validate_auth_cookie( '', 'logged_in' );
+ if ( $user_id ) {
+ wp_set_current_user( $user_id );
+ }
+ }
+
+ $logged_in = is_user_logged_in();
+ $poll_id = (int) $request->get_param( 'poll_id' );
+ nocache_headers();
+
+ return $this->success( array(
+ 'loggedIn' => $logged_in,
+ 'nonce' => ( $logged_in && $poll_id > 0 ) ? wp_create_nonce( 'yop_poll_vote_' . $poll_id ) : '',
+ 'wpRestNonce' => $logged_in ? wp_create_nonce( 'wp_rest' ) : '',
+ ) );
}
public function wp_login_redirect( $request ) {
--- a/yop-poll/includes/REST/class-rest-base.php
+++ b/yop-poll/includes/REST/class-rest-base.php
@@ -45,16 +45,45 @@
}
public function get_client_ip() {
- $ip = '';
+ $remote_addr = ! empty( $_SERVER['REMOTE_ADDR'] )
+ ? trim( sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) )
+ : '';
+
+ // By default, trust only the connection's origin address. Client-controlled
+ // forwarding headers (Client-IP, X-Forwarded-For) are consulted ONLY when the
+ // admin has explicitly opted in for a known reverse-proxy setup. This prevents
+ // an unauthenticated attacker from spoofing the header to rotate their IP and
+ // bypass the "Block Voters by IP" restriction. See CVE-2022-1600.
+ if ( ! $this->trust_proxy_headers() ) {
+ return $remote_addr;
+ }
+
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
- $ip = sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) );
- } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
- $ip = sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) );
- $ip = explode( ',', $ip )[0];
- } elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
- $ip = sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
+ $ip = trim( sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) ) );
+ if ( filter_var( $ip, FILTER_VALIDATE_IP ) ) {
+ return $ip;
+ }
+ }
+ if ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
+ $forwarded = sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) );
+ $ip = trim( explode( ',', $forwarded )[0] );
+ if ( filter_var( $ip, FILTER_VALIDATE_IP ) ) {
+ return $ip;
+ }
}
- return trim( $ip );
+
+ return $remote_addr;
+ }
+
+ /**
+ * Whether the admin has opted in to trusting client-supplied proxy headers
+ * (X-Forwarded-For / Client-IP) when determining the voter's IP.
+ */
+ protected function trust_proxy_headers() {
+ $settings = json_decode( get_option( 'yop_poll_settings', 'false' ), true );
+ return is_array( $settings )
+ && isset( $settings['general']['use-custom-headers-for-ip'] )
+ && 'yes' === $settings['general']['use-custom-headers-for-ip'];
}
protected function build_date_interval( int $number, string $unit ): ?DateInterval {
--- a/yop-poll/yop_poll.php
+++ b/yop-poll/yop_poll.php
@@ -3,7 +3,7 @@
* Plugin Name: YOP Poll
* Plugin URI: https://yop-poll.com
* Description: The flexible WordPress poll plugin — rebuilt for speed, security, and ease of use.
- * Version: 7.0.5
+ * Version: 7.0.6
* Requires at least: 6.5
* Requires PHP: 7.4
* Author: YOP
@@ -18,7 +18,7 @@
exit;
}
-define( 'YOP_POLL_VERSION', '7.0.5' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- YOP_POLL_ is the established plugin prefix; distribution slug is yop-poll.
+define( 'YOP_POLL_VERSION', '7.0.6' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- YOP_POLL_ is the established plugin prefix; distribution slug is yop-poll.
define( 'YOP_POLL_FILE', __FILE__ ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- YOP_POLL_ is the established plugin prefix; distribution slug is yop-poll.
define( 'YOP_POLL_DIR', plugin_dir_path( __FILE__ ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- YOP_POLL_ is the established plugin prefix; distribution slug is yop-poll.
define( 'YOP_POLL_URL', plugin_dir_url( __FILE__ ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- YOP_POLL_ is the established plugin prefix; distribution slug is yop-poll.