What happened?
Hi 👋,
I noticed that when setting the prefix to 0, the package does not properly append the prefix to the IP address before passing it to Symfony’s IpUtils::checkIp().
According to Symfony’s implementation, a CIDR of /0 should be treated as a match-all network (0.0.0.0/0 or ::/0). However, in this package, the prefix is omitted when the prefix value equals 0, causing the IP check to fail instead of matching all.
Expected behavior:
0.0.0.0/0 should match any incoming IPv4 address (as per Symfony IpUtils semantics).
Actual behavior:
Because of this line:
https://github.com/solutionforest/filament-firewall/blob/3.x/src/FilamentFirewall.php#L21
the prefix 0 is ignored:
if ($record->prefix_size) {
$ip = (string) str($ip)->finish('/')->finish($record->prefix_size);
}
and the value passed to IpUtils::checkIp() becomes 0.0.0.0 (without /0), resulting in a failed check.
Environment:
- filament-firewall version: 3.x
- PHP: 8.3
- Laravel: 11.x
How to reproduce the bug
Just add IP with Prefix = 0
Package Version
2.0.4
PHP Version
8.3.x
Laravel Version
11.x
Which operating systems does with happen with?
No response
Notes
No response
What happened?
Hi 👋,
I noticed that when setting the prefix to 0, the package does not properly append the prefix to the IP address before passing it to Symfony’s IpUtils::checkIp().
According to Symfony’s implementation, a CIDR of /0 should be treated as a match-all network (0.0.0.0/0 or ::/0). However, in this package, the prefix is omitted when the prefix value equals 0, causing the IP check to fail instead of matching all.
Expected behavior:
0.0.0.0/0 should match any incoming IPv4 address (as per Symfony IpUtils semantics).
Actual behavior:
Because of this line:
https://github.com/solutionforest/filament-firewall/blob/3.x/src/FilamentFirewall.php#L21
the prefix 0 is ignored:
and the value passed to IpUtils::checkIp() becomes 0.0.0.0 (without /0), resulting in a failed check.
Environment:
How to reproduce the bug
Just add IP with Prefix = 0
Package Version
2.0.4
PHP Version
8.3.x
Laravel Version
11.x
Which operating systems does with happen with?
No response
Notes
No response