1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 18:07:59 +00:00
Commit Graph

4152 Commits

Author SHA1 Message Date
Simon Tatham
a8658edb17 Paste error in comment.
SSH2_MSG_KEX_DH_GEX_REQUEST_OLD and SSH2_MSG_KEX_DH_GEX_REQUEST were
correctly _defined_ as different numbers, but the comments to the
right containing the hex representations of their values were
accidentally the same.
2015-04-27 06:54:21 +01:00
Simon Tatham
16c46ecdaf Add smemclrs of all hash states we destroy. 2015-04-26 23:55:33 +01:00
Simon Tatham
9d5a164021 Use a timing-safe memory compare to verify MACs.
Now that we have modes in which the MAC verification happens before
any other crypto operation and hence will be the only thing seen by an
attacker, it seems like about time we got round to doing it in a
cautious way that tries to prevent the attacker from using our memcmp
as a timing oracle.

So, here's an smemeq() function which has the semantics of !memcmp but
attempts to run in time dependent only on the length parameter. All
the MAC implementations now use this in place of !memcmp to verify the
MAC on input data.
2015-04-26 23:31:11 +01:00
Simon Tatham
183a9ee98b Support OpenSSH encrypt-then-MAC protocol extension.
This causes the initial length field of the SSH-2 binary packet to be
unencrypted (with the knock-on effect that now the packet length not
including MAC must be congruent to 4 rather than 0 mod the cipher
block size), and then the MAC is applied over the unencrypted length
field and encrypted ciphertext (prefixed by the sequence number as
usual). At the cost of exposing some information about the packet
lengths to an attacker (but rarely anything they couldn't have
inferred from the TCP headers anyway), this closes down any
possibility of a MITM using the client as a decryption oracle, unless
they can _first_ fake a correct MAC.

ETM mode is enabled by means of selecting a different MAC identifier,
all the current ones of which are constructed by appending
"-etm@openssh.com" to the name of a MAC that already existed.

We currently prefer the original SSH-2 binary packet protocol (i.e. we
list all the ETM-mode MACs last in our KEXINIT), on the grounds that
it's better tested and more analysed, so at the moment the new mode is
only activated if a server refuses to speak anything else.
2015-04-26 23:30:32 +01:00
Simon Tatham
78989c97c9 Fix a few memory leaks.
Patch due to Chris Staite.
2015-04-26 10:49:24 +01:00
Simon Tatham
84e239dd88 Divide the Bugs panel in half.
It overflowed as a result of the previous commit.
2015-04-25 10:54:18 +01:00
Simon Tatham
62a1bce7cb Support RFC 4419.
PuTTY now uses the updated version of Diffie-Hellman group exchange,
except for a few old OpenSSH versions which Darren Tucker reports only
support the old version.

FIXME: this needs further work because the Bugs config panel has now
overflowed.
2015-04-25 10:54:18 +01:00
Jacob Nevins
63dddfc00f Old Dropbear servers have the ssh-close-vs-request bug.
Add automatic bug detection. (Versions verified by Matt Johnston.)
2015-04-23 23:42:45 +01:00
Simon Tatham
9fec2e7738 Fix a dangerous cross-thread memory access.
When a winhandl.c input thread returns EOF to the main thread, the
latter might immediately delete the input thread's context. I
carefully wrote in a comment that in that case we had to not touch ctx
ever again after signalling to the main thread - but the test for
whether that was true, which also touched ctx, itself came _after_ the
SetEvent which sent that signal. Ahem.

Spotted by Minefield, which it looks as if I haven't run for a while.
2015-04-07 22:17:08 +01:00
Simon Tatham
6f241cef2c Clean up a stale foreign handle in winnps.c.
I had set up an event object for signalling incoming connections to
the named pipe, and then called handle_add_foreign_event to get that
event object watched for connections - but when I closed down the
listening pipe, I deleted the event object without also cancelling
that foreign-event handle, so that winhandl.c would potentially call
the callback for a destroyed object.
2015-04-07 21:54:41 +01:00
Simon Tatham
2422b18a0f Don't output negative numbers in the ESC[13t report.
A minus sign is illegal at that position in a control sequence, so if
ESC[13t should report something like ESC[3;-123;234t then we won't
accept it as input. Switch to printing the numbers as unsigned, so
that negative window coordinates are output as their 32-bit two's
complement; experimentation suggests that PuTTY does accept that on
input.
2015-03-07 20:57:26 +00:00
Simon Tatham
7d97c2a8fd Stop Windows PuTTY becoming unresponsive if server floods us.
This was an old bug, fixed around 0.59, which apparently regressed
when I rewrote the main event loop using the toplevel_callback
mechanism.

Investigation just now suggests that it has to do with my faulty
assumption that Windows PeekMessage would deliver messages in its
message queue in FIFO order (i.e. that the thing calling itself a
message queue is actually a _queue_). In fact my WM_NETEVENT seems to
like to jump the queue, so that once a steady stream of them starts
arriving, we never do anything else in the main event loop (except
deal with handles).

Worked around in a simple and slightly bodgy way, namely, we don't
stop looping on PeekMessage and run our toplevel callbacks until we've
either run out of messages completely or else seen at least one that
_isn't_ a WM_NETEVENT. That way we should reliably interleave NETEVENT
processing with processing of other stuff.
2015-03-07 17:10:36 +00:00
Jacob Nevins
06d2fb5b37 Move kh2reg.py link from svn to git. 2015-03-01 12:27:27 +00:00
Jacob Nevins
80bd6a01aa Minimal documentation for ECDSA/ECDH support. 2015-02-28 19:08:15 +00:00
Simon Tatham
45e89ed7ca Add a new checklist item.
I managed to build from completely the wrong commit this morning, so
make sure to double-check next time!
2015-02-28 15:47:45 +00:00
Simon Tatham
ac27a14689 Typo. 2015-02-28 13:10:55 +00:00
Simon Tatham
8af53d1b69 Reorganise the release checklist.
Mostly I'm rearranging things because of the new workflows that git
makes available - it's now possible (and indeed sensible) to prepare a
lot of stuff in a fairly relaxed manner in local checkouts, and then
the process of going live with the release has a lot less manual
writing of stuff and a lot more mechanical 'git push' and running of
update scripts.

However, there's one new item that was actually missed off the
previous checklist: turning off nightly pre-release builds after
making the release they were a pre-release of. Ahem.
2015-02-28 12:04:54 +00:00
Simon Tatham
12d5b00d62 New 'contrib' tool: a script for faking initial KEX.
encodelib.py is a Python library which implements some handy SSH-2
encoding primitives; samplekex.py uses that to fabricate the start of
an SSH connection, up to the point where key exchange totally fails
its crypto.

The idea is that you adapt samplekex.py to construct initial-kex
sequences with particular properties, in order to test robustness and
security fixes that affect the initial-kex sequence. For example, I
used an adaptation of this to test the Diffie-Hellman range check
that's just gone into 0.64.
2015-02-28 07:58:29 +00:00
Simon Tatham
808e414130 Merge branch 'pre-0.64' 2015-02-28 07:57:58 +00:00
Simon Tatham
2713396c91 Bump version number for 0.64 release. 2015-02-28 07:57:35 +00:00
Simon Tatham
65f69bca73 Add some missing smemclrs and sfrees.
The absence of these could have prevented sensitive private key
information from being properly cleared out of memory that PuTTY tools
had finished with.

Thanks to Patrick Coleman for spotting this and sending a patch.
2015-02-28 07:57:35 +00:00
Simon Tatham
1f75792805 Fix an erroneous length field in SSH-1 key load.
We incremented buf by a few bytes, so we must decrement the
corresponding length by the same amount, or else makekey() could
overrun.

Thanks to Patrick Coleman for the patch.
2015-02-28 07:57:35 +00:00
Simon Tatham
174476813f Enforce acceptable range for Diffie-Hellman server value.
Florent Daigniere of Matta points out that RFC 4253 actually
_requires_ us to refuse to accept out-of-range values, though it isn't
completely clear to me why this should be a MUST on the receiving end.

Matta considers this to be a security vulnerability, on the grounds
that if a server should accidentally send an obviously useless value
such as 1 then we will fail to reject it and agree a key that an
eavesdropper could also figure out. Their id for this vulnerability is
MATTA-2015-002.
2015-02-28 07:57:35 +00:00
Jacob Nevins
f004bcca17 Merge branch 'pre-0.64' 2015-02-27 09:28:05 +00:00
Jacob Nevins
db9385b3ce Refresh the Windows installer README.txt.
The most recent version of Windows it acknowledged was XP.
2015-02-27 09:26:47 +00:00
Jacob Nevins
d89fdf65a7 Merge branch 'pre-0.64' 2015-02-24 10:37:53 +00:00
Jacob Nevins
56a42d09d4 Make kh2reg.py compatible with modern Python.
Bare string exceptions aren't supported any more.
Patch by Will Aoki, plus a backward compatibility tweak from Colin Watson.
Seen working with Python 2.4.3 and 2.7.6.
2015-02-24 10:30:18 +00:00
Simon Tatham
a87a14ae0f Improve comments in winhandl.c.
To understand the handle leak bug that I fixed in git commit
7549f2da40, I had to think fairly hard
to remind myself what all this code was doing, which means the
comments weren't good enough. Expanded and rewritten some of them in
the hope that things will be clearer next time.
2015-02-07 12:50:37 +00:00
Simon Tatham
d0ca84935e Merge branch 'pre-0.64' 2015-02-07 12:50:31 +00:00
Simon Tatham
087ca595f3 Mark handles defunct before calling gotdata/sentdata.
If (say) a read handle returns EOF, and its gotdata function responds
by calling handle_free(), then we want the handle to have already had
its defunct flag set so that the handle can be destroyed. Otherwise
handle_free will set the 'done' flag to ask the subthread to
terminate, and then sit and wait for it to say it's done so -
forgetting that it signalled termination already by returning EOF, and
hence will not be responding to that signal.

Ditto for write errors on write handles, though that should happen
less often.
2015-02-07 12:50:08 +00:00
Simon Tatham
7549f2da40 Fix handle leak in winhandl.c.
The code for cleaning up handle structures works by the main thread
asking the per-handle subthread to shut down by means of setting its
'done' flag, and then once the subthread signals back through its
event object that it's done so, the main thread frees all its
resources and removes the event object from the list of things being
checked in the program's event loop.

But read threads were not sending back that final event acknowledging
a request to shut down, so their event objects were never being
cleaned up.

Bug spotted by Ronald Weiss.
2015-02-07 12:50:03 +00:00
Jacob Nevins
ced3a46c3f Merge branch 'pre-0.64' 2015-01-18 14:50:20 +00:00
Jacob Nevins
8dedf59080 Remove user-key-oriented advice from host key docs.
It would be rare to have a host keypair in .ppk format or on a client
machine to load into PuTTYgen, and it might confuse people into thinking
they are required to do so.
2015-01-18 14:50:08 +00:00
Jacob Nevins
954df095f4 Merge branch 'pre-0.64' 2015-01-08 23:50:34 +00:00
Jacob Nevins
3a9ce5074d Use local username consistently in Unix Plink.
It tries to use the local username as the remote username if it has no
better ideas, but the presence of Default Settings would defeat this,
even if it had no username set. Reported by Jonathan Amery.
2015-01-05 23:51:12 +00:00
Jacob Nevins
5904545cc1 Merge branch 'pre-0.64' 2015-01-05 23:49:25 +00:00
Jacob Nevins
f3685eb948 Fix a copy-and-pasted comment. 2015-01-05 23:48:11 +00:00
Jacob Nevins
bff08a95e7 It's a new year. 2015-01-05 23:48:11 +00:00
Simon Tatham
23208779e7 Merge branch 'pre-0.64' 2014-12-20 18:52:40 +00:00
Simon Tatham
ae4986a433 Do an smemclr(bytes) in bignum_random_in_range.
It's used for sensitive data, so we shouldn't leave it lying around
after free.
2014-12-20 18:51:42 +00:00
Simon Tatham
c46da2f079 Fix memory management in bignum_random_in_range.
We were allocating a new array in which to make up a random number
every time we went round the loop, and not freeing any of them. Now we
allocate a single array to use for all loop iterations, and clear and
free it properly afterwards.

Patch due to Tim Kosse.
2014-12-20 18:51:42 +00:00
Simon Tatham
02dd708116 Fix a handle leak in Windows PSFTP.
We were checking the return value of CreateThread for validity, but
not keeping it to free afterwards if it _was_ valid. Also, we weren't
closing ctx->event in the valid case either. Patch due to Tim Kosse.
2014-12-20 18:48:30 +00:00
Simon Tatham
0acc74d711 Fixes to memory management in the elliptic curve code.
There was an error-handling path testing the wrong variable; an
inappropriate call to ec_point_free in decodepoint() (in fact, that
function always gets passed a pointer to an ec_point structure that's
not a dynamically allocated block at all or not in its own right, so
we should have just cleared its contents without freeing the structure
itself); a missing return on an error path which would have caused the
same structure to be freed a second time; and two missing freebn in
ecdsa_sign.

Patch due to Tim Kosse.
2014-12-20 18:43:32 +00:00
Simon Tatham
fe24f4dfba Add a missing freeaddrinfo() in Unix sk_newlistener.
If we use getaddrinfo to translate the source IP address into a
sockaddr, then we need to freeaddrinfo the returned data later. Patch
due to Tim Kosse.
2014-12-20 17:00:01 +00:00
Simon Tatham
dd0f1e5cc7 Close the remote file handle if sftp_put_file's fstat fails.
Instead of abruptly returning from sftp_put_file in that situation, we
now send an FXP_CLOSE instead. Patch due to Tim Kosse.
2014-12-20 16:59:55 +00:00
Simon Tatham
d23c0972cd Merge branch 'pre-0.64' 2014-11-22 16:42:01 +00:00
Simon Tatham
8c09f85a64 Stop referring to Plink as "PuTTY Link".
I don't think anyone has ever actually called it that, colloquially
_or_ formally, and if anyone ever did (in a bug report, say) I'd
probably have to stop and think to work out what they meant. It's
universally called Plink, and should be officially so as well :-)
2014-11-22 16:39:25 +00:00
Simon Tatham
91645175f7 Another missing initialisation.
This one spotted in the old-fashioned way, by actually attempting a
Plink raw connection and wondering why it didn't seem to be reading
from standard input! Turns out 'bufsize' is uninitialised until the
first send, which can inhibit any stdin reading if it gets a large
enough nonsense value.
2014-11-22 16:35:54 +00:00
Simon Tatham
6903e761d5 Consistently use &def for %makefile_extra pieces.
mkfiles.pl was giving a couple of annoying perl warnings, because some
makefile_extra strings were never set by Recipe. We already have the
&def function to convert undefs into "" for this reason, but weren't
using it everywhere. Now I think we are.
2014-11-22 16:30:29 +00:00
Simon Tatham
c269dd0135 Move echo/edit state change functionality out of ldisc_send.
I'm not actually sure why we've always had back ends notify ldisc of
changes to echo/edit settings by giving ldisc_send(ldisc,NULL,0,0) a
special meaning, instead of by having a separate dedicated notify
function with its own prototype and parameter set. Coverity's recent
observation that the two kinds of call don't even have the same
requirements on the ldisc (particularly, whether ldisc->term can be
NULL) makes me realise that it's really high time I separated the two
conceptually different operations into actually different functions.

While I'm here, I've renamed the confusing ldisc_update() function
which that special operation ends up feeding to, because it's not
actually a function applying to an ldisc - it applies to a front end.
So ldisc_send(ldisc,NULL,0,0) is now ldisc_echoedit_update(ldisc), and
that in turn figures out the current echo/edit settings before passing
them on to frontend_echoedit_update(). I think that should be clearer.
2014-11-22 16:18:00 +00:00