Whitelist ineffective when IPv4 address is presented in IPv6/embedded format
-
I have a white-listed IPv4 address, but it is taking no effect, because on the server, $_SERVER[‘REMOTE_ADDR’] arrives in embedded format (https://www.tcpipguide.com/free/t_IPv6IPv4AddressEmbedding-2.htm).
i.e. it’s like ::ffff:1.2.3.4
The whitelister only allows the format 1.2.3.4 to be used; but the actual value of $_SERVER[‘REMOTE_ADDR’] is not converted into this format. Result: no match can ever take place.
I have worked around this by adding this to wp-config.php:
if (preg_match(‘/^::ffff:(\d+\.\d+\.\d+\.\d+)$/’, $_SERVER[‘REMOTE_ADDR’], $matches)) $_SERVER[‘REMOTE_ADDR’] = $matches[1];
I think brute_get_ip() needs to add some similar logic.
David
- The topic ‘Whitelist ineffective when IPv4 address is presented in IPv6/embedded format’ is closed to new replies.