Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset of failure counter on successful login #2102

Closed
1 of 3 tasks
snajak opened this issue Apr 2, 2018 · 4 comments
Closed
1 of 3 tasks

Reset of failure counter on successful login #2102

snajak opened this issue Apr 2, 2018 · 4 comments

Comments

@snajak
Copy link

snajak commented Apr 2, 2018

Environment:

Fill out and check ([x]) the boxes which apply. If your Fail2Ban version is outdated,
and you can't verify that the issue persists in the recent release, better seek support
from the distribution you obtained Fail2Ban from

  • Fail2Ban version (including any possible distribution suffixes):
  • OS, including release name/version: Debian on raspberrypi
  • Fail2Ban installed via OS/distribution mechanisms: apt-get
  • You have not applied any additional foreign patches to the codebase
  • Some customizations were done to the configuration (provide details below is so)

The issue:

I would like to ask, if it would be possible to add a function to reset the counter by a successful login. Assume ban on 5 false logins. Now 4 false logins, 5th is successful. Logout and one more false login kicks the user out, although he has been shown valid to the system before. With this feature one could allow longer ban times, as it reduces the risk of getting blocked significantly. Assume a user has to login frequently, e.g. copying files, etc., he could esily be band when in 20 authenications 5 are false.

The old denyhost had another nice reature, that I am missing: Check of valid and infalid usernames. A useful setting was that a correct username had e.g. 10 attempts, an invalid one 5.

Steps to reproduce

5

Expected behavior

Counter gets reset after successful login.

Observed behavior

ban counter=5, user after 4 false logins has success at 5th login. After login again, e.g. a sectiond shell with a false login, he looses all access.

Any additional information

Configuration, dump and another helpful excerpts

standard debian installation without no modification

Any customizations done to /etc/fail2ban/ configuration

Relevant parts of /var/log/fail2ban.log file:

preferably obtained while running fail2ban with loglevel = 4

Relevant lines from monitored log files in question:

@sebres sebres changed the title Counter rest on successful login Reset of failure counter on successful login Apr 3, 2018
@sebres
Copy link
Contributor

sebres commented Apr 3, 2018

So you wanna really allow someone (who has an account) try other user accounts and then do one success login to forget invalid attempts?
Just imagine someone has an account restricted-user, and then tries to logon as root (with interim successful logins to reset failed attempts).
This will be never accepted so in this form by fail2ban. Just because it is intrinsically vulnerable.

In the newer versions (>= 0.10) for multiple tries inside the same connect (with an connection-id, specified using tag <F-MLFID>...</F-MLFID> enclosed) you could use non-empty match for tag <F-MLFFORGET>...</F-MLFFORGET> to forget previous failed attempts.
Be sure you've also specified a user-name patterns in the filter like <F-USER>\S+</F-USER>, otherwise fail2ban will not be able to differentiate between the attempts of good and bad user (that trying different users).
See our sshd-filter for example.

@snajak
Copy link
Author

snajak commented Apr 5, 2018 via email

@sebres sebres self-assigned this Apr 5, 2018
@ghost
Copy link

ghost commented Mar 24, 2020

Had this been implemented? If yes, what commit contains the implementation?

@sebres
Copy link
Contributor

sebres commented Mar 24, 2020

Had this been implemented? If yes, what commit contains the implementation?

Well, indeed (but at the moment partially). #2279 provides new "flag" tags <F-MLFGAINED> that can allow to forget failures from current session only (if user name is not switched).

There is also another PR #1243 addressing that... but it should be extended to close multiple legitimate users issue (follow the same rules as #2279 does - reset only if single user name was used, so a user login does not change), see #1243 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants