73

Some websites display a remaining password retry count when I input wrong passwords more than twice. For example, displaying that there are 3 retries remaining until locking out my account. Is this dangerous from security perspective ?

Snappie
  • 307
  • 1
  • 2
  • 6
Ahmet Arslan
  • 849
  • 1
  • 5
  • 9
  • 49
    One consideration is that this can easily reveal whether a username exists on the site. This may be undesirable if user names are emails and the site is something personal like foot-fetish.com You can avoid this by returning a fake number for non-existent accounts – paj28 Jan 16 '19 at 16:25
  • 11
    Would it be so implausibly difficult for a hacker to count the number of failed attempts before receiving the locked account message? By this logic you should be asking whether displaying the "Account locked" message is a security risk. – MonkeyZeus Jan 16 '19 at 16:51
  • 3
    @MonkeyZeus But with a number displayed the hacker knows when to stop before the account gets blocked and the failed attempt gets noticed. They then can wait some time until the owner logged in and resets the counter. – BlackJack Jan 16 '19 at 17:45
  • @BlackJack Not necessarily. If the user made 2 attempts right before the hacker made their first attempt then I would really hope that they don't think that a single failure results in a locked account. At any rate no threat model was mentioned by OP so open-ended conjecture like this really does nothing... – MonkeyZeus Jan 16 '19 at 17:53
  • 5
    Why has nobody considered that the retry count could be based on ip or device recognition? – Nightwolf Jan 17 '19 at 08:34
  • @Nightwolf That's what I was thinking too, instead of by account name. – GrumpyCrouton Jan 17 '19 at 14:49
  • Don't lock out accounts, lock out the IP address that's making the failed access attempts. [fail2ban](http://www.fail2ban.org) is your friend there. – Shadur Jan 18 '19 at 07:52
  • @paj28 I don't think that solves the problem you mentioned. All it does is extend the problem to every possible email address (as far as the attacker can tell) – Lightness Races in Orbit Jan 18 '19 at 18:20
  • 10
    no no no... do NOT lock out IPs for WEBSITE logins. SSH? Sure. But a lot of companies/schools/apartment complexes/hotels/etc NAT their entire internal space out through a single IP, and you could block a ton of unaffiliated users by banning by IP. – Angelo Schilling Jan 18 '19 at 23:11
  • @nightwolf because that's a terrible idea that's either trivially surmountable (e.g. if done by cookie) or could lead to a denial of service against someone (device ID by mac address, for example) or to a whole lot of someones (IP address). – Rob Moir Jan 19 '19 at 16:05
  • @RobMoir The practice of locking out IP can work to protect against brute force attempts by locking the ip for 5 mins. Displaying a count of how many attempts available before temp ban seems completely reasonable, as well as ban time remaining. If a legitimate user receives an abused IP they will at most be denied 5 mins and then be clear to proceed. This obviously depends on your threat model. – Nightwolf Jan 22 '19 at 13:16
  • @Nightwolf I understand that. But how do you address the issues that Angelo and myself pointed out? I could trivially lock out about 7500 people from using your service with very little effort if you're blocking by IP address. – Rob Moir Jan 22 '19 at 13:19
  • @RobMoir So my suggestion is simply note that there is currently a timed lockout and two factor auth is required to log in (email link and password / cellphone and password) until timed lock expires. – Nightwolf Jan 22 '19 at 13:39
  • An adversary can simply check the retry count by choosing a random other user and possibly another IP address. It's very likely that most users are at their maximum number of retries left after all, as they would log out only after logging in. If "leaking" this information would make your system vulnerable you would be in trouble, regardless if you display it or not. – Maarten Bodewes Jan 31 '19 at 03:08

8 Answers8

147

Locking accounts is a bad idea in the first place. It might seem like you're making your organization more secure by keeping out "bad people" who are "guessing" at passwords using brute force attacks, but what have you really solved? Even with this policy and a perfect userbase who never makes security mistakes, an attacker can perform a denial-of-service attack on your organization by repeatedly using the password "aaa" to lock out the accounts of critical users. Consider what happens if your attacker gets a copy of the list of usernames for your entire IT department: Suddenly, IT itself — the organization that would otherwise be able to unlock other users — is itself completely shut down.

Always consider what the threat model is before implementing a policy. A "bad guy" determined to hurt your organization will find alternative attack vectors. Your lockout policy won't even faze a nation-state actor (like Russia or China or the NSA); a determined hacker will just find other ways around it (like social engineering); and it will only hurt legitimate users of your service, no matter how low or high you set the lockout counter.

Moral of the story: Don't lock out accounts. Instead, do what Apple does with the iPhone: Each login try doubles the login delay, so that after a dozen failures or so, you have to wait one hour between each successive attempt. That's long enough to prevent "bad guys" from performing brute-force attacks, but still short enough that a legitimate user can spend that hour figuring out what their password was and typing it in properly after lunch — or contacting IT and apologetically asking for help. (Similarly, "flooding" policies can often be implemented at the IP-address level in your firewall, not just at the user-account level in your software, if you're concerned about a dedicated attacker trying to brute-force many different accounts.)

And if you don't lock out accounts, you don't need to have a counter — or display it.

[see also: this excellent answer on a similar question]

Sean Werkema
  • 2,954
  • 2
  • 6
  • 9
  • 53
    Solid advice. Although I still call this locking accounts, it's just with a short timeout – paj28 Jan 16 '19 at 16:24
  • 5
    I agree with this for lock-and-forget implementations, but short-duration locks (automatically unlock again after a few minutes) can be useful for rate-limiting brute force attacks. – Joel Coehoorn Jan 16 '19 at 16:46
  • Unless you can afford continuous 24/7/365 active monitoring by live human beings for your service — enough live human beings to deal with the worst-case scenario even at 3 AM on Christmas Day — your implementation _is_ some form of set-it-and-forget-it, and thus still shouldn't use account lockouts. And that's pretty nearly every service out there. – Sean Werkema Jan 16 '19 at 17:23
  • And don't forget that some of us are *required* by a set of even more insane laws to enforce lockouts for failed login attempts. There is a reason that even the NIST includes a ''shall'' lockout clause (generously high at 100 attempts). Because more often than not it is the gov't that is requiring us to do the lockouts. – Ruscal Jan 16 '19 at 18:07
  • 12
    But should you have a display that informs the user of how long the login delay will be for the next attempt? – Yozarian22 Jan 16 '19 at 21:54
  • 2
    I would have a captcha show up for a user who has many failed login attempts. Should stop most abuse. – Qwertie Jan 17 '19 at 01:29
  • 3
    Gradually increasing lock times is a sensible thing to do on a physical device. But one still shouldn't do even that on an account that can be accessed over the internet. The attacker can keep sending password attempts even while the account is locked, and each time the lock expires the legitimate user will have only a brief time during which they could log in before the attacker cause it to be locked again. Instead lock IP addresses and lock prefixes if multiple addresses in a prefix have been locked out. – kasperd Jan 17 '19 at 03:24
  • 3
    That 'aaa' DoS attack is interestingly specific. You don't happen to have an actual history of an attack like that, do you? Perhaps a reference pointer for me to look up? I would love to read about it. – Michael Macha Jan 17 '19 at 03:46
  • 5
    @MichaelEricOberlin: Anecdotally, we had a case of one user with a constantly locked account. After many hours spent investigating, it turned out to be a coworker/nemesis of the user who kept doing it to spite the user. It wasn't on a company wide scale but it also doesn't quite require expert skills to lock out someone you want to. – Flater Jan 17 '19 at 13:46
  • 3
    Does the same principle of locking out not work with Apple, where you can effectively drive up the lockout counter until people can't log in for a significant amount of time? Maybe not permanent, but still an impactful denial of service, no? – Flater Jan 17 '19 at 13:47
  • 14
    For an online system, doubling the lock-out time doesn't *really* help all that much. Being locked out with your whole IT department for a couple of days is anooying enough, but it's also not that hard to do repeat your attack at increasing intervals, still keeping your team locked out more or less indefinitely. – Jasper Jan 17 '19 at 15:05
  • 1
    @kasperd the lock could be tied to a specific IP rather than connected to the account, couldn't it? Just discarding traffic of that type from that source rather than interacting with it. – Andrew Jan 17 '19 at 15:30
  • We lock accounts where I work but we also use a service to block specific devices and IP addresses to prevent the situation described here.. or at least prevent it in a way we care about. It only applies to external accounts that log in to the service we provide and not internal employee accounts. Internal accounts are easy to reset and investigate here. But the point is there are services that can block suspicious IPs and devices, so locking shouldn't be universally discounted. –  Jan 17 '19 at 18:57
  • (1) A security system that locks accounts with no ‘magic bullet’ way of getting in (e.g., console logins are never locked, because the server is physically secured) is, of course, fundamentally broken. So we should assume that, even if a bad (or mischievous) user locks the accounts of the IT staff, they will have a way of getting in anyway. So, as [Flater](https://security.stackexchange.com/q/201566/34757#comment404075_201596) and [Jasper](https://security.stackexchange.com/q/201566/34757#comment404086_201596) say, isn’t locking the IT staff out for an hour really just as bad? … (Cont’d) – Scott - Слава Україні Jan 17 '19 at 19:09
  • (Cont’d) …  (2) It seems to me that your last sentence doesn’t make much sense.  If you double the login delay after each failed attempt, you are still keeping track of failed logins.  The fact that you are storing *2^n* rather than *n* doesn’t really make it any less of a counter. – Scott - Слава Україні Jan 17 '19 at 19:09
  • @SeanWerkema If login delay is too high and there is denial-of-service attack going on so many request will be in queue that server can no longer accept new request. Isn't this a possibility ? – mystery Jan 18 '19 at 06:04
  • @Andrew My comment did suggest locking out IP addresses (and in some cases prefixes). But definitely don't discard the traffic. One should still respond with an appropriate error message, just don't try to validate username or password before sending the error message if the client IP is in a locked out range. – kasperd Jan 18 '19 at 09:48
  • 3
    Doubling the login time is better than locking accounts outright, but it's still a denial of service. Dealing with a doubling login time isn't really much of an inconvenience to an adversary who automates the process of bogus logins. – jamesdlin Jan 19 '19 at 01:15
  • "a nation-state actor (like Russia or China or the NSA)" – Interesting set of *nations*. – Daniel Jan 20 '19 at 16:30
  • As for DoS'ing admin users, these accounts could be protected in a different way, e.g. whitelisted to the company's IPs. – Charlie Harding Jan 20 '19 at 20:56
  • @Scott: I used to run a blank root password with that theory behind it. I had rigged up securetty so that remote logins as root were simply not possible. – Joshua Jan 21 '19 at 02:47
  • @kasperd IP-level blocks will affect people using a VPN to access your service (I get this regularly, since I use a VPN regularly, and it's very annoying). – Logan Pickup Jan 21 '19 at 06:16
  • I remember in high school the kids would lock each other out by guessing the wrong password. Someone got smart and locked the teacher out too so he couldn't unlock accounts. I'm sure some did this on purpose to have an excuse not to work, though presumably maturity should have heightened by the time people enter the workplace. – northerner Jan 21 '19 at 06:46
  • @LoganPickup VPN has nothing to do with it. Rather the issue is two other things: **1.** You may have chosen to use a provider who has a lot of abusive customers. **2.** You may have chosen a provider who uses NAT. – kasperd Jan 21 '19 at 07:28
  • @northerner What does it matter if maturity has heightened? We are talking about a scenario where anybody on the internet can attack you. And somewhere on the internet you can find at least one person who isn't mature and maybe even someone who is straight out nefarious. – kasperd Jan 21 '19 at 07:30
  • 1
    I've always cautioned against account lockouts for this very reason. Not only are they a nuisance to users who haven't logged on in a while and can't remember which variation of their password they used, but more importantly (from a security standpoint), they create a serous DoS vector. A friend of mine once developed a web app with an aggressive lockout policy (against my advice to him). To drive my point home (and mess with my friend), I locked him out of his own app just by using his email and a bunch of bogus passwords. – Lily Finley Jan 21 '19 at 14:51
  • I hate the ever increasing time outs. If they are used, then they need some limit, otherwise you still have a denial of service, if just for one user. – Maarten Bodewes Jan 31 '19 at 03:03
32

It depends on your lockout mechanism. If invalid logins get reset after some time AND a locked account does not get unlocked, showing a counter can help an attacker not to lock out an account. But a skilled attacker will have determined the lockout policy up front and will take this into account when guessing the password. So the impact is limited.

Also, relying on this to protect your login mechanism is missing the point. You should have a decent password policy and a lockout policy to match. If the password policy is strong, an attacker will have to guess a large number of times before getting it right. If you lock an account after 20 attempts, you have little chance of getting compromised.

You must ask yourself: what is the benefit of showing this information to a genuine user? Often, this problems with lockout occurs because the number of tries is set too low. 3 or 5 are common choices. NIST (Currently unavailable due to government shutdown so no direct reference yet) suggests less than 100 attempts.

NIST has a point: think of a password which no attacker will guess in 3 attempts, but which they will guess in 100 attempts. All attackers use different dictionaries and approaches. If a password is unsafe to withstand 100 guesses it can also be breached using fewer attempts - although that is less likely. Therefore a good password policy is a must.

I will add the NIST references when the site comes back up. Troy hunt has some good blog posts which summarize password and login mechanisms. He is a fan of the NIST guidelines as well.

Silver
  • 1,824
  • 11
  • 23
  • 6
    You're looking for NIST Special Publication 800-63 which can normally be seen here (hotlinked to the relevant section): https://pages.nist.gov/800-63-3/sp800-63b.html#throttle Of course, because they took the special effort to put that server into maintenance mode instead of just walking away (grumble) then you'll have to use the Wayback Machine to see it right now: https://web.archive.org/web/20181223021935/https://pages.nist.gov/800-63-3/sp800-63b.html#throttle – Ruscal Jan 16 '19 at 16:08
  • 1
    What I like is to remember at least the last failed password (Hashes). And if the same one is used do not increase the fail counter. This greatly helps with misremembered or scripted clients to not regularly lock out the offender. – eckes Jan 16 '19 at 23:56
  • If an attacker only has to guess 1000s of times to get your password than it is not a strong password. – Qwertie Jan 17 '19 at 01:30
  • @Qwertie, I will change it to a more vague description ;) – Silver Jan 17 '19 at 10:08
5

In principle, no, it should not be a security risk. If it were, then you would be relying on security through obscurity (hidden information).

Hiding a count would, at best, be a minor inconvenience to an adversary.

In contrast, hiding a count can be a significant inconvenience to legitimate users. It's not uncommon that I sometimes enter the wrong password and then re-enter it a few more times assuming that I made a typo. If I know that I will be locked out with another incorrect attempt, I'll go look up my password and copy/paste or type it carefully. If, however, I unwittingly lock myself out of my account, now I need to go through a lot of extra trouble to get it unlocked.

jamesdlin
  • 2,015
  • 1
  • 12
  • 13
2

To give another perspective on this: it doesn't matter for a skilled attacker.

How are online accounts compromised today typically1? There are two variations of one technique that are commonly used.

Databases with password hashes (or passwords in plaintext) get stolen and are cracked offline by attackers. After successfully cracking a hash the correct password is served to the login mechanism on the first try, so this control is ineffective.

This can either be the database of the service in question or the database of another service. Unfortunately people tend to reuse their passwords with several services so chances are high, that once a password is matched to an e-mail adress, it can be used on another site. An attacker might have two or three passwords to choose from, but probably not 20. Again, this control is ineffective.

So what level of security does this control establish? The level that is necessary to protect from inexperienced script kiddies, malicious ex-partners and nosy parents that want to take a look at your personal account and try five passwords at random. No more, but no less.


1 Then there are of course other techniques that are more "advanced" like keylogging, (spear)-phishing, MitM etc. which are as well not mitigated by this control.

Tom K.
  • 7,913
  • 3
  • 30
  • 53
1

Only two scenario is possible with it but rather showing account lockout time policy risk is more over lockout time.

E.g.

  • once can configure the hydra or some other tool to brute force the login and wait after 3 attempts. if you don't have sufficient locking time it can cause an account compromise.

  • if you have 30 mins or so locking time then its though we can configure the tool for brute force and wait after three attempts it will take years to crack the password.

to conclude this their no risk involve in displaying account lockout attempt.

1

I lean in general towards the less information you give to an attacker the better. As @security-beast mentioned a tool can be configured to wait the appropriate amount of time. Giving them the information for that configuration is not necessarily ideal.

However, you have to balance this with the needs of your users. Do you find that the system admins spend an inordinate amount of time unlocking accounts because your users keep locking them? If that's the case then your analysis may indicate that you get more benefit from displaying the number of retries to your users so they know when they need to wait before locking their accounts. In other cases the opposite will be true, but either way the answer should be the result of an objective analysis of the trade-offs for the particular system.

Hope this helps.

jfran3
  • 111
  • 9
  • I hadn't seen Silver's comment when I posted, but I would second the NIST guidelines as a good base to start with. – jfran3 Jan 16 '19 at 09:31
0

Security Risk is subjective it will depend on what you are trying to protect the objective of the security control and any other security control in place that mitigate or compensate the risk.

Based on this different companies / business will have different acceptance to same risk.

If in a generic way providing how many attempts your still have might not impose a risk (e.g.: PIN in your smart card to make phone calls) In other situations it might be a risk (e.g.: trying to brute force mobile phone access) where you can stop before the last attempt and wait some time so the user resets the counter with a valid access...

You should check on the objective of the security control, what you are trying to protect and what security controls you have in place that will compensate or at least monitor abnormal situations.

Based on all this then you can decide if it is an acceptable risk or not for your specifics.

Hugo
  • 1,701
  • 11
  • 12
0

At some point I was at a company where they just had a few guys test their security. One of these things those guys found is that the there was no account lockout when there where too many incorrect passwords. However much to the CISO's delight they could not prove that they could actually get in by brute forcing the password. The reason for this was that the account lockout was silent and lasted for about 15 minutes.

Ask yourself what you gain by displaying such a message and what you lose in security by doing so. It is perfectly valid to not give any notification of locking an accoutn due to too many incorrect login attempts. If you give such a message you will just help an attacker in figuring out when he is wasting his time brute forcing. If you don't they are less likely to figure it out but it might lead to more calls/mails to your helpdesk which might be costly. An FAQ or help page might reduce this.

Also implementing the countdown will, probably, mean more code and more code means more bugs. This is not something you want in a security mechanism. Add to that that you implement it wrong it might allow attackers to enumerate usernames which is doubly problematic if they are email addresses. Hell, if you implement it using an unsigned cookie it might actually give the attacker the ability to prevent a lockout happening at all.

In general your security will be improved if your error messages give as little information as possible.

Brandhout
  • 66
  • 1
  • I'm a pentester. If I give the advice "limit login attempts" and the customer replies "prove that it's vulnerable", I would be annoyed. It is a matter of luck whether I can get in via this method. Do you want to rely on luck, or would you rather apply logic and discover that, indeed, if *one* of your users sets a bad password, and *one* attacker gets lucky, you are pwned? Therefore, I would be annoyed to have to prove it. Then, if I later hear that there was a silent lock-out (so you let me do the work, knowing it cannot succeed), I would feel like you doubly wasted my time. – Luc Jan 19 '19 at 22:33
  • 1
    So you annoyed the pentester, now let's switch to user mode. I cannot get into my account even though I know it must be one of those five passwords. Now I have to go through other steps to recover my account. Later I discover that my password was correct, but that the system just did not let me in because of too many attempts. Instead of wasting time trying different passwords, and feeding the site more and more possible passwords (giving my passwords more exposure), it would have been very nice if the system could have just told me. – Luc Jan 19 '19 at 22:36
  • Finally, let's look at the situation as an attacker. If I can create an account, I can try 100 incorrect attempts on my own account (1. do login attempt in Firefox; 2. copy as curl from developer toolbar; 3. use Bash one-liner: `for i in {1..100}; do ; done`) and then see if I can still login. Nope! So there is a lock-out in place. Now I create another account and write a similar script that does first one invalid attempt, then two, then three... and in between I check if I can still login. This all takes about five minutes. Hiding the retry count is not a significant hindrance. – Luc Jan 19 '19 at 22:49
  • @Luc you right hiding the retry count is not a massive hurdle for a determined attacker, but it is a hurdle none the less. – Brandhout Jan 21 '19 at 06:24
  • What I might not have made clear in my anecdote is that the accounts were silently locked for a short period of time so pentest finding was incorrect, which is why they were asked to prove it. The point was that silent locking an account is perfectly valid way of doing this, it actually is done in practice and it shows that is can add hindrance to your attacker. You completely right that there are trade offs to be made and that is not perfect security, but that is always the case. – Brandhout Jan 21 '19 at 06:30