diff --git a/lib/private/Security/Normalizer/IpAddress.php b/lib/private/Security/Normalizer/IpAddress.php index f8e55370da713..459f895b3e6bf 100644 --- a/lib/private/Security/Normalizer/IpAddress.php +++ b/lib/private/Security/Normalizer/IpAddress.php @@ -46,7 +46,7 @@ public function __construct( } /** - * Return the given subnet for an IPv6 address (64 first bits) + * Return the given subnet for an IPv6 address (48 first bits) */ private function getIPv6Subnet(string $ip): string { if ($ip[0] === '[' && $ip[-1] === ']') { // If IP is with brackets, for example [::1] @@ -58,9 +58,9 @@ private function getIPv6Subnet(string $ip): string { } $binary = \inet_pton($ip); - $mask = inet_pton('FFFF:FFFF:FFFF:FFFF::'); + $mask = inet_pton('FFFF:FFFF:FFFF::'); - return inet_ntop($binary & $mask).'/64'; + return inet_ntop($binary & $mask).'/48'; } /** @@ -85,7 +85,7 @@ private function getEmbeddedIpv4(string $ipv6): ?string { /** - * Gets either the /32 (IPv4) or the /64 (IPv6) subnet of an IP address + * Gets either the /32 (IPv4) or the /48 (IPv6) subnet of an IP address */ public function getSubnet(): string { if (filter_var($this->ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { diff --git a/tests/lib/Security/Normalizer/IpAddressTest.php b/tests/lib/Security/Normalizer/IpAddressTest.php index bb487659ced39..3df2c130e9c85 100644 --- a/tests/lib/Security/Normalizer/IpAddressTest.php +++ b/tests/lib/Security/Normalizer/IpAddressTest.php @@ -51,20 +51,20 @@ public function subnetDataProvider() { '192.168.0.123/32', ], [ - '2001:0db8:85a3:0000:0000:8a2e:0370:7334', - '2001:db8:85a3::/64', + '2001:0db8:0000:0000:0000:8a2e:0370:7334', + '2001:db8::/48', ], [ '2001:db8:3333:4444:5555:6666:7777:8888', - '2001:db8:3333:4444::/64', + '2001:db8:3333::/48', ], [ '::1234:5678', - '::/64', + '::/48', ], [ '[::1]', - '::/64', + '::/48', ], ]; }