PluginProbe
wpForo Forum / 3.1.6
wpForo Forum v3.1.6
3.1.6 3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 All 138 releases
← All changes | classes/AIAjaxTrait.php +7 -9 3.1.53.1.6 View file →
@@ -276,19 +276,17 @@
276 276 set_transient( $transient_key, $current_count + 1, $seconds_until_midnight );
277 277 }
278 278
279 279 /**
280 - * Get the client IP address, considering proxy headers.
280 + * Get the client IP address.
281 281 *
282 + * Uses REMOTE_ADDR only to prevent IP spoofing via X-Forwarded-For headers.
283 + * Proxy headers (CF-Connecting-IP, X-Forwarded-For) can be spoofed by clients
284 + * when the server is not behind a trusted reverse proxy, allowing attackers
285 + * to bypass IP-based rate limits.
286 + *
282 287 * @return string Client IP address
283 288 */
284 289 protected function get_client_ip() {
285 - $ip_keys = [ 'HTTP_CF_CONNECTING_IP', 'HTTP_X_FORWARDED_FOR', 'REMOTE_ADDR' ];
286 - foreach ( $ip_keys as $key ) {
287 - if ( ! empty( $_SERVER[ $key ] ) ) {
288 - $ip = explode( ',', sanitize_text_field( wp_unslash( $_SERVER[ $key ] ) ) )[0];
289 - return trim( $ip );
290 - }
291 - }
292 - return '0.0.0.0';
290 + return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ?? '0.0.0.0' ) );
293 291 }
294 292 }