1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-03 04:22:47 -05:00

Stop supporting fallback between SSH versions.

The UI now only has "1" and "2" options for SSH protocol version, which
behave like the old "1 only" and "2 only" options; old
SSH-N-with-fallback settings are interpreted as SSH-N-only.

This prevents any attempt at a protocol downgrade attack.
Most users should see no difference; those poor souls who still have to
work with SSH-1 equipment now have to explicitly opt in.
This commit is contained in:
Jacob Nevins
2016-03-28 20:23:57 +01:00
parent 43f1aa01cd
commit 16dfefcbde
9 changed files with 90 additions and 43 deletions

32
ssh.c
View File

@ -3138,15 +3138,21 @@ static int do_ssh_init(Ssh ssh, unsigned char c)
/* Anything greater or equal to "1.99" means protocol 2 is supported. */
s->proto2 = ssh_versioncmp(s->version, "1.99") >= 0;
if (conf_get_int(ssh->conf, CONF_sshprot) == 0 && !s->proto1) {
bombout(("SSH protocol version 1 required by configuration but "
"not provided by server"));
crStop(0);
}
if (conf_get_int(ssh->conf, CONF_sshprot) == 3 && !s->proto2) {
bombout(("SSH protocol version 2 required by configuration but "
"not provided by server"));
crStop(0);
if (conf_get_int(ssh->conf, CONF_sshprot) == 0) {
if (!s->proto1) {
bombout(("SSH protocol version 1 required by our configuration "
"but not provided by server"));
crStop(0);
}
} else if (conf_get_int(ssh->conf, CONF_sshprot) == 3) {
if (!s->proto2) {
bombout(("SSH protocol version 2 required by our configuration "
"but server only provides (old, insecure) SSH-1"));
crStop(0);
}
} else {
/* No longer support values 1 or 2 for CONF_sshprot */
assert(!"Unexpected value for CONF_sshprot");
}
if (s->proto2 && (conf_get_int(ssh->conf, CONF_sshprot) >= 2 || !s->proto1))
@ -3708,13 +3714,17 @@ static const char *connect_to_host(Ssh ssh, const char *host, int port,
}
/*
* If the SSH version number's fixed, set it now, and if it's SSH-2,
* send the version string too.
* The SSH version number is always fixed (since we no longer support
* fallback between versions), so set it now, and if it's SSH-2,
* send the version string now too.
*/
sshprot = conf_get_int(ssh->conf, CONF_sshprot);
assert(sshprot == 0 || sshprot == 3);
if (sshprot == 0)
/* SSH-1 only */
ssh->version = 1;
if (sshprot == 3 && !ssh->bare_connection) {
/* SSH-2 only */
ssh->version = 2;
ssh_send_verstring(ssh, "SSH-", NULL);
}