Annoying and useless delays on password entry errors

Bug #138654 reported by Bogdan Butnaru
72
This bug affects 13 people
Affects Status Importance Assigned to Milestone
Ubuntu
Invalid
Undecided
Unassigned
pam (Ubuntu)
Triaged
Wishlist
Unassigned

Bug Description

Binary package hint: sudo

Hello! This is about Ubuntu Gutsy, though it applies to the other versions as well.

My problem is that every password-entry that requires the user's log-in password has an annoying little delay of a few seconds when entering a mistaken password before asking again for it. (I linked sudo above, but this applies to the login on the console and on the GDM screen, the screen-savers, gksu I think, and I'm sure I forget some. SSH does this too, I think, but I've been using public-key logins for too long and I forget.)

Example: run "sudo ls" in a terminal, type a wrong password, and watch how you're forced to wait before being told it's wrong and asked to try again.

I think this is supposed to be a security feature attempting to discourage brute-forcing a password. However, it's annoyingly intrusive, and I doubt it's that effective or useful in many cases. (Though I must agree it's relatively simple.)

First of all, this isn't really as effective a security measure as it might seem: For most cases it's very simple to get around this by attempting a password, killing the process after 100ms if it doesn't answer and retrying. This effectively reduces the time cost for an attempt to $PROCESS_START_TIME+$PASSWORD_ENTRY_TIME+100ms, which is typically much less than the three or so seconds sudo forces a user to wait. For instance, if I'd try to use sudo to brute force a password I'd run "sudo echo 'found it'" (to make sure I get the answer quickly) in a loop, killing the process 100ms after entering a password attempt and not receiving any output.

Granted, there's the added time cost of re-starting the process, but every password entry fails after three errors, so simply removing the delay would decrease the brute-force time by at most a factor of three. Which isn't really much, is it?

First proposal: given the above attack, I suggest lowering the delay to about half a second. This would make brute force about five time easier than it is now (which I believe isn't a great concern), and would be almost unnoticeable by a normal user.

Second proposal: the system should keep for each password a global count of recent failures. Any anti-brute-force measures should be activated only when the number of consecutive failures grows. The counter would be reset on success, and would decay in time.

This second proposal is I think optimal. It sounds a bit complicated. However, I believe all the programs above actually make use of common PAM modules (also, I think the delay is controlled by those), so this would be easy to implement just once.

Note that every element of the second proposal is important: the counters must be per-machine global, not per-process or per-session (so an attacker can't just kill a process and retry), and there must be separate counters for each password (so you can't reset it by entering a known password, and an attempt to brute-force one user's password doesn't inconvenience other users).

Note also that this scheme is both more protective and convenient:
(a) the delay can grow with the number of attempts, eg. 3 secs after three failures, 10 secs after twenty failures, one minute and a big nasty warning after a hundred consecutive failures. (This way, a legitimate user would notice something is amiss instead of just resetting the counter.)
(b) the measures are activated even if the attacker tries to use the technique above. Even if he kills the process, he'll still get the delay _even for the first attempt_ after several errors.
(c) users don't have to wait each time they make a typo in a password entry field.

Revision history for this message
Bogdan Butnaru (bogdanb) wrote :

After a bit more reading-up I see most of this should be possible by simply updating the default configuration in /etc/pam.d

The delay can be removed by adding parameter to common-auth's pam_unix, and the counting by using pam_tally. I can't figure out how to add a growing timeout; perhaps a new module is needed, that might need a new module.

I'm moving this to pam-runtime, as it's a PAM configuration issue rather than a sudo problem. I see pam-runtime owns /etc/pam.d/other, but I can't figure out which package owns the /etc/pam.d/common-* files; pam-runtime has them listed in /usr/share/pam, but I don't know how they get into /etc/pam.d. Please leave a note if you know.

Changed in sudo:
status: New → Invalid
Revision history for this message
Kees Cook (kees) wrote :

Since this is a global timeout for PAM, reducing it would change the behavior for network services. However, as you point out, this isn't a very effective way to discourage brute-forcing (especially for network attempts -- it just forks another copy).

Changed in pam:
importance: Undecided → Wishlist
status: New → Triaged
Revision history for this message
Martin Pitt (pitti) wrote :

> For most cases it's very simple to get around this by attempting a password, killing the process after 100ms if it doesn't answer and retrying.

This does not actually work, since as an user you are not allowed to kill a suid root process. So you can only fork processes like hell, which is bound by nproc.

I still think that this is a sensible security measure.

Revision history for this message
Martin Pitt (pitti) wrote :

I'd set this to wontfix. Kees, do you agree?

Revision history for this message
Bogdan Butnaru (bogdanb) wrote : Re: [Bug 138654] Re: Annoying and useless delays on password entry errors

No, but you can kill it's parent shell. You can do 'bash -c "sudo
cmd"' and kill bash. On my attempts this killed the "sudo" after a
single bad password. Sure, bash is a bit overweight and would slow
things down, but you can emulate whatever happens there with less
bloat. Or use dash, at the least.

On 9/13/07, Martin Pitt <email address hidden> wrote:
> > For most cases it's very simple to get around this by attempting a
> password, killing the process after 100ms if it doesn't answer and
> retrying.
>
> This does not actually work, since as an user you are not allowed to
> kill a suid root process. So you can only fork processes like hell,
> which is bound by nproc.
>
> I still think that this is a sensible security measure.
>
> --
> Annoying and useless delays on password entry errors
> https://bugs.launchpad.net/bugs/138654
> You received this bug notification because you are a direct subscriber
> of the bug.
>

--
Bogdan Butnaru — <email address hidden>
"I think I am a fallen star, I should wish on myself." – O.

Revision history for this message
Bogdan Butnaru (bogdanb) wrote :

Oh, and I can press Ctrl-C at any moment at a "sudo" prompt and try
again. (Depending on your POV that might be a bug in sudo, but
anyway.)

On 9/13/07, Bogdan Butnaru <email address hidden> wrote:
> No, but you can kill it's parent shell. You can do 'bash -c "sudo
> cmd"' and kill bash. On my attempts this killed the "sudo" after a
> single bad password. Sure, bash is a bit overweight and would slow
> things down, but you can emulate whatever happens there with less
> bloat. Or use dash, at the least.
>
> On 9/13/07, Martin Pitt <email address hidden> wrote:
> > > For most cases it's very simple to get around this by attempting a
> > password, killing the process after 100ms if it doesn't answer and
> > retrying.
> >
> > This does not actually work, since as an user you are not allowed to
> > kill a suid root process. So you can only fork processes like hell,
> > which is bound by nproc.
> >
> > I still think that this is a sensible security measure.
> >
> > --
> > Annoying and useless delays on password entry errors
> > https://bugs.launchpad.net/bugs/138654
> > You received this bug notification because you are a direct subscriber
> > of the bug.
> >
>
>
> --
> Bogdan Butnaru — <email address hidden>
> "I think I am a fallen star, I should wish on myself." – O.
>

--
Bogdan Butnaru — <email address hidden>
"I think I am a fallen star, I should wish on myself." – O.

Revision history for this message
glasscheetah (vroom22-deactivatedaccount) wrote :

What comment do you have to add to common-auth's pam_unix to disable the delay?

Revision history for this message
Bogdan Butnaru (bogdanb) wrote :

"nodelay". "$ man pam_unix" for details

Revision history for this message
Patrick Horn (phrh) wrote :

I don't like having to use nodelay -- I like the fact that it gives a delay when I make a mistake but 2 seconds is just too long.

I would vote for just changing the delay to 0.5 seconds, since this is as simple as changing a constant in pam_unix

Revision history for this message
Andy Owen (the-new-andy) wrote :

It would be nice if you had some number of attempts (e.g. 3) with no delay, and then after that have a delay. (e.g. 2 seconds). This way, a brute force attack is still impossible, but the more common case of making a typo in the password isn't annoying.

ShawnJGoff (shawnjgoff)
Changed in hundredpapercuts:
status: New → Confirmed
Revision history for this message
Steve Langasek (vorlon) wrote :

this bug is not trivially fixable, so it is not a paper cut.

Changed in hundredpapercuts:
status: Confirmed → Invalid
Revision history for this message
mati (mati-wroc) wrote :

Steve, are you sure? Patrick Horn's patch is a one-liner, implementing Andy Owen's approach (3 attemps with no delay) shouldn't be hard too.

Please reconsider.

Changed in hundredpapercuts:
status: Invalid → New
Revision history for this message
ShawnJGoff (shawnjgoff) wrote :

I would like to know what about this bug is nontrivial since there is already a patch here.

Revision history for this message
Steve Langasek (vorlon) wrote :

I'm not sure the proposed patch actually addresses the original request (is a 4x reduction in the delay, from 2 seconds to .5 seconds, that much of an improvement?), but regardless, this is not just a usability issue, there's also a security issue here. Any changes to the behavior of PAM failure delays needs to be evaluated in the context of all PAM services on the system, not just for the sudo and desktop login cases.

Changed in hundredpapercuts:
status: New → Invalid
Revision history for this message
Timmmm (tdhutt) wrote :

Steve: Yes, 0.5s is a vast improvement over 2s, and I would consider this 'fixed'.

Perhaps this should be two bugs, one paper-cut: "Default password delay is too long", and one that is (as you say) harder to fix: "First few local password attempts should be instant".

I think you can easily fix the first part. The second is not so important since 0.5s isn't nearly as annoying as 2s.

Cheers.

Revision history for this message
walther (walther-tw) wrote :

Hard-coded numbers are always bad. Why not simply make this value configurable?
Also I have to admit, I don't understand why pam_unix applies this delay. Is this not what pam_delay (whose delay _is_ configureable) is made for?

Revision history for this message
Dražen Lučanin (kermit666) wrote :

What I would suggest to keep both the security and user friendliness in entering passwords would be to add a certain number of no-delay attempts (e.g. 3).

This way humans would get a certain number of quick retype attempts in case of typos or different keyboard layouts (often the case with me, as I switch between US and Croatian, depending on what I'm doing).

After this initial number, let the exponential delay kick in (2 s, 4 s, ... or whatever it currently is) to prevent any bot-attacks.

For a brute force attack, a couple of extra attempts isn't a significant advantage and for humans that makes all the difference in making the system more responsive.

no longer affects: hundredpapercuts
Revision history for this message
Mike Doherty (doherty) wrote :

Is this actually going to get fixed? There hasn't been a meaningful update in a year and a half.

Revision history for this message
Mike Doherty (doherty) wrote :

(Just a reminder that when combined with bug 1308265, it can get pretty annoying. This is worth fixing.)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.