Hey Stian,
I agree that we could make something work with a Firewall / intrusion detection system if it’s decided that this is too complex to add directly to Keycloak.
What I had in mind was a configurable sliding-time window rate limit that would prevent a client from making too many requests for a particular user in short time frames. E.g. limit each client to making at most 1 login request within a sliding
5 sec interval for each user. The 5 sec timespan could be made configurable or even be computed relative to the token timeout settings.
Perhaps another alternative is to offer an admin alert to ensure that Keycloak admins are aware of clients that are incorrectly using/abusing the authentication workflow. I guess it could work the same way as the blocking rate limit, with the
exception of the fact that it would just send an email to the Keycloak admin instead of directly blocking the offending client.
The OOM was indeed our fault as we were not using the paging options, I just mentioned it to provide additional context for the scenario that we experienced and to explain the reason that we had some down-time based upon these excessive logins.
All that said, perhaps you’re right about the fact that this may be better handled in logic external to Keycloak. In any case, I think its a worthwhile discussion and appreciate your input!
Thanks,
The brute force protection is there only to prevent guessing the password through a brute force attack. It's not there to stop DOS attacks. We don't have any rate limiting at the moment and I believe that's something that would be better introduced
with a firewall / intrusion detection system.
It's non-trivial to add, especially with the fact that a single client that invokes the direct grant login could have thousands of legitimate users. I don't think a simple implementation would be much value and not replace a full fledged firewall.
What did you have in mind with regards to requirements? Ability to configure max number of requests per-client? Per-user?
For the OOM the events endpoints supports pagination as well as date ranges which should prevent and OOM issue when querying it.