AuthMe / AuthMeReloaded

The best authentication plugin for the Bukkit/Spigot API!
https://www.spigotmc.org/resources/authmereloaded.6269/
GNU General Public License v3.0
628 stars 516 forks source link

Implement tempban counter by username #764

Open EbonJaeger opened 8 years ago

EbonJaeger commented 8 years ago

Currently the tempban counter will only be reset on a successful login and (I presume) a server restart. This means that a user can attempt to log in to his own account and fail x times, and that count will never be reset. Worse, an attacker can log in incorrectly without hitting the tempban threshold, potentially allowing the account's legitimate owner to be tempbanned should he make a typo in his password.

Perhaps after a time the counter should be reset, likely after the user leaves the server. This time will have to be long enough to severely discourage brute-force attacks, however.

Another solution to look into might be to use the player's IP instead of the name as the key for the counter? But then that opens the door to restarting their modem, getting a new IP, and another bunch of tries, so I guess that isn't viable after all.

ljacqu commented 8 years ago

You raise some excellent points.

We're trying to prevent two scenarios:

Both require different metrics to detect. We don't want an IP address trying 5 common passwords on 20 different accounts, and we don't want 20 people trying 5 common passwords on one username.


As for resetting the counter after a certain time, one idea is to keep a timestamp per entry. If a new failed login arrives, we can check the timestamp and if it's longer ago than some configured time (say, it was over 1 hour ago), the counter is reset to 1.

Alternatively, some sort of regularly scheduled task? Not sure how heavy that is on the server. Otherwise if there's one (legitimate) failed login attempt it might stay in the counter for days.

EbonJaeger commented 8 years ago

I think the bigger task is figuring out your first section: preventing both scenarios. Any thoughts on how to do that?

ljacqu commented 8 years ago

We have a mix of both right now. For the first scenario we would need to count fails by IP address (and then we react appropriately: ban the IP). The second scenario is how we count currently: failed logins for a given username. However, we can't react by banning the IP address to this one.

The proper reaction to the second one is locking the account for a given amount of time. I can think of two ways to do this but am curious what others would suggest to achieve that. Also if it should be possible for the genuine player to be able to unlock (and how to achieve that).

EbonJaeger commented 8 years ago

I can do a little refactor to address the first scenario. I agree that the second one requires a bit more thought and input. Shall I go ahead with that?

ljacqu commented 8 years ago

If you could, that would be lovely! Then we can set #192 as verifiable :smile:

ljacqu commented 8 years ago

Periodically cleaning up entries with old timestamps could be done with #806

EbonJaeger commented 8 years ago

Good idea.

ljacqu commented 7 years ago

As mentioned in this thread, we now properly keep track of failed login attempts by IP address, but should do so by username as well: if 10 different people target 1 username, the username could be blocked temporarily.

Cleaning up entries periodically has been done with #876, so I've renamed this task accordingly.

ljacqu commented 7 years ago

@friishon posts in #1108 the suggestion to send an email verification to the user after too many wrong logins. I think this can be considered in this issue.