antonioribeiro / firewall

Firewall package for Laravel applications
BSD 3-Clause "New" or "Revised" License
1.39k stars 162 forks source link

Invalid IP #188

Open arwinvdv opened 1 year ago

arwinvdv commented 1 year ago

In our laravel application we added this:

if (app('firewall')->isBeingAttacked()) {
    return app('firewall')->responseToAttack();
}

But with some attacks we got a exception like InvalidArgumentException: The value ""{${print(9347655345-4954366)}}"" is not a valid IP address. in /../vendor/maxmind-db/reader/src/MaxMind/Db/Reader.php:175

We surround it with

try {
    // Check if user is attacking server
    if (app('firewall')->isBeingAttacked()) {
        return app('firewall')->responseToAttack();
    }
} catch (InvalidArgumentException) {
    return app('firewall')->responseToAttack();
}

But than we got an error exception like ErrorException: Trying to access array offset on value of type null in /.../vendor/pragmarx/firewall/src/Support/AttackBlocker.php:272

I replaced the catch return with an abort() now, but is there a better way to handle this?