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

New bug workaround: KEXINIT filtering.

We've occasionally had reports of SSH servers disconnecting as soon as
they receive PuTTY's KEXINIT. I think all such reports have involved
the kind of simple ROM-based SSH server software you find in small
embedded devices.

I've never been able to prove it, but I've always suspected that one
possible cause of this is simply that PuTTY's KEXINIT is _too long_,
either in number of algorithms listed or in total length (especially
given all the ones that end in @very.long.domain.name suffixes).

If I'm right about either of those being the cause, then it's just
become even more likely to happen, because of all the extra
Diffie-Hellman groups and GSSAPI algorithms we just threw into our
already-long list in the previous few commits.

A workaround I've had in mind for ages is to wait for the server's
KEXINIT, and then filter our own down to just the algorithms the
server also mentioned. Then our KEXINIT is no longer than that of the
server, and hence, presumably fits in whatever buffer it has. So I've
implemented that workaround, in anticipation of it being needed in the
near future.

(Well ... it's not _quite_ true that our KEXINIT is at most the same
length as the server. In fact I had to leave in one KEXINIT item that
won't match anything in the server's list, namely "ext-info-c" which
gates access to SHA-2 based RSA. So if we turn out to support
absolutely everything on all the server's lists, then our KEXINIT
would be a few bytes longer than the server's, even with this
workaround. But that would only cause trouble if the server's outgoing
KEXINIT was skating very close to whatever buffer size it has for the
incoming one, and I'm guessing that's not very likely.)

((Another possible cause of this kind of disconnection would be a
server that simply objects to seeing any KEXINIT string it doesn't
know how to speak. But _surely_ no such server would have survived
initial testing against any full-featured client at all!))
This commit is contained in:
Simon Tatham
2022-08-30 18:51:33 +01:00
parent cec8c87626
commit 5e2acd9af7
8 changed files with 138 additions and 5 deletions

View File

@ -3573,6 +3573,32 @@ auto-detection relies on the version string in the server's greeting,
and PuTTY has to decide whether to expect this bug \e{before} it sees
the server's greeting. So this is a manual workaround only.
\S{config-ssh-bug-filter-kexinit} \q{Chokes on PuTTY's full \cw{KEXINIT}}
At the start of an SSH connection, the client and server exchange long
messages of type \cw{SSH_MSG_KEXINIT}, containing lists of all the
cryptographic algorithms they're prepared to use. This is used to
negotiate a set of algorithms that both ends can speak.
Occasionally, a badly written server might have a length limit on the
list it's prepared to receive, and refuse to make a connection simply
because PuTTY is giving it too many choices.
A workaround is to enable this flag, which will make PuTTY wait to
send \cw{KEXINIT} until after it receives the one from the server, and
then filter its own \cw{KEXINIT} to leave out any algorithm the server
doesn't also announce support for. This will generally make PuTTY's
\cw{KEXINIT} at most the size of the server's, and will otherwise make
no difference to the algorithm negotiation.
This flag is a minor violation of the SSH protocol, because both sides
are supposed to send \cw{KEXINIT} proactively. It still works provided
\e{one} side sends its \cw{KEXINIT} without waiting, but if both
client and server waited for the other one to speak first, the
connection would deadlock. We don't know of any servers that do this,
but if there is one, then this flag will make PuTTY unable to speak to
them at all.
\S{config-ssh-bug-sig} \q{Requires padding on SSH-2 \i{RSA} \i{signatures}}
Versions below 3.3 of \i{OpenSSH} require SSH-2 RSA signatures to be