1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00
Commit Graph

5612 Commits

Author SHA1 Message Date
Simon Tatham
fdf7de4a1c sessprep: fix detection of unbracketed IPv6 literals.
The centralisation I did in commit e3796cb77 introduced a foolish
sense error, in which I was supposed to be treating an unbracketed
colon in CONF_hostname as separating host name from a port-number-
shaped suffix if it _was_ the only one, and instead, accidentally did
so if it _wasn't_.
2019-03-22 16:32:41 +00:00
Simon Tatham
f433c82cc2 Translate more _MSC_VER values in build info.
Thanks to Sean Kain for pointing out MS's web page listing all the
known _MSC_VER values and their translations.

To make it an easier and more mechanical process to update the list in
future, I've completely replaced our previous text for each version
with a straight paste of the exact string translations from that web
page (plus Sean Kain's extra value for VS2019, which isn't listed on
that page yet). That changes the exact wording of all the previous
translations, mostly cosmetically (although it also fixes the version
number for _MSC_VER=1912).

Since many of the new translations end with a version number in
parentheses, I've removed the parens around the following explicit
statement of _MSC_VER, so they don't look silly next to each other.
2019-03-22 07:19:36 +00:00
Simon Tatham
1d8b48fd22 pscp -scp: fix spurious newlines at end of filenames.
Commit d07d7d66f introduced this bug: I replaced a manually grown
string buffer with a strbuf, and failed to replicate the part where
after I'd finished appending wire data to the string I removed the
terminating \n. That string was used as the local file name, when
downloading in SCP mode using a wildcard, so you'd get lots of local
files whose names ended inconveniently in a newline character.

Fixed by terminating the loop before we push the \n on to the strbuf
in the first place.
2019-03-21 15:23:51 +00:00
Sven Strickroth
674219b115 Use sgrowarray_nm in GetDlgItemText_alloc
GetDlgItemText_alloc is often used to get passwords from text fields,
so the memory should be freed and erased properly. Otherwise parts
of passwords might leak in memory.

Signed-off-by: Sven Strickroth <email@cs-ware.de>
2019-03-21 12:57:09 +00:00
Simon Tatham
7631875d41 Re-enable trust sigils on Restart Session.
In my eagerness to make sure we didn't _accidentally_ change the
seat's trust status back to trusted at any point, I forgot to do it on
purpose if a second SSH login phase is legitimately run in the same
terminal after the first session has ended.
2019-03-20 15:07:32 +00:00
Simon Tatham
f6d1fef2d7 Handle <limits.h> not defining PIPE_BUF.
According to POSIX, this can legally not be defined 'where the [...]
value is equal to or greater than the stated minimum, but where the
value can vary depending on the file to which it is applied'. So if
limits.h hasn't defined PIPE_BUF, we define it ourself to the stated
minimum, to wit, _POSIX_PIPE_BUF.

Apparently it is actually undefined by <limits.h> on GNU/Hurd: Debian
has been carrying this patch downstream for that reason.
2019-03-20 13:09:34 +00:00
Simon Tatham
582284fa6c Fix generation of one-bit-short RSA keys.
I carefully tested commit 801ab68ea's rewrite of invent_firstbits in
every way I could think of to ensure that I really was generating two
values whose product was at least 'minproduct'. But unfortunately the
value of 'minproduct' itself was off by a factor of two, which made
the entire system pointless!
2019-03-20 11:50:45 +00:00
Colin Watson
6ce6fe5712 Use the SELECT_* enum for a few more uxsel flags.
This cleans up some spots that were missed in 47202c4e16.
2019-03-20 11:39:05 +00:00
Simon Tatham
867e691874 Fix crash when adding an ECDSA key to Pageant.
The new_priv_openssh method for ECDSA keys was trying to initialise
the key as if it was EdDSA, leading to an assertion failure at setup
time.

This is what I get for not having taken cryptsuite.py all the way to
testing every top-level signature algorithm.
2019-03-20 08:00:03 +00:00
Simon Tatham
93c29b2277 sign.sh: add Windows on Arm builds to the signing list.
Oops - completely forgot to sign those!
2019-03-20 08:00:03 +00:00
Jacob Nevins
142427afae Fix for MIT KfW and user-specified GSS DLLs.
Fill in all the function pointers for 3rd party Windows GSS DLLs, not
just some of them. These were missed out when GSS key exchange was added
in d515e4f1a3.
2019-03-19 23:55:26 +00:00
Jacob Nevins
c7c6bc8f93 Acknowledge Unix pageant. 2019-03-18 23:09:24 +00:00
Jacob Nevins
d7c1f894d6 Acknowledge Windows-on-Arm builds. 2019-03-18 23:08:09 +00:00
Jacob Nevins
4f3abe5215 FIXME about Windows resource CHMfulness hint.
The thing I added in 8b7458119f turns out not to be visible in
Explorer's UI, at least. Oh well, maybe it'll be useful to someone.
2019-03-18 22:02:13 +00:00
Jacob Nevins
7c0242459c Remove note about .CHM on network drives.
Should be more or less moot since 67d3791de8.
2019-03-18 21:53:45 +00:00
Jacob Nevins
65d3afcaa1 Remove all trace of the Inno Setup installer.
(Hopefully.)
We haven't even built it for the past two releases.
2019-03-18 21:53:45 +00:00
Jacob Nevins
a60d455c27 Grow the Windows Licence dialog.
It was cutting off the last line or so, on some fairly standard
Win7/Win10 installations.
2019-03-18 20:32:55 +00:00
Jacob Nevins
57020eef82 Grow PuTTYgen and Pageant About boxes.
To match a2b040ee09 for PuTTY/PuTTYtel.
2019-03-18 20:32:06 +00:00
Jacob Nevins
c78f59fd9d Document ACL restriction options for Pageant.
These are just cross-references to the existing descriptions in the
"Using PuTTY" section.
2019-03-17 15:17:52 +00:00
Jacob Nevins
6d98399a27 Document Unix puttygen /dev/urandom default.
This changed in 025599ec99 (before 0.71).
2019-03-17 15:08:37 +00:00
Jacob Nevins
627d95e365 Document new Unix Pageant features in 0.71.
Better late than never.
These originated in:
 - e6b06c900f: --gui-prompt, --tty-prompt
 - 4467fa4d2a: --askpass
 - 0603256964: -L
2019-03-17 14:58:55 +00:00
Jacob Nevins
63b63b6243 Set trust status appropriately for rlogin.
Previously, all output in an rlogin session had spurious trust sigils.
2019-03-17 13:40:56 +00:00
Simon Tatham
bda765dbd2 Post-0.71 checklist updates. 2019-03-16 16:58:51 +00:00
Simon Tatham
c1fa520f98 release.pl: allow for installer-only sha*sums.
Now there are lines in the checksum lists that don't correspond
directly to files we uploaded as part of the main release process,
release.pl needs to ignore them to avoid embarrassing upload failures.
2019-03-16 16:46:50 +00:00
Simon Tatham
abfc751c3e Update version number for 0.71 release. 2019-03-16 12:26:06 +00:00
Simon Tatham
c081f3e234 Reorganise the default cipher preference order.
After all the side-channel removal work I've done, I'm demoting
Blowfish and Arcfour right to the bottom of the pile, because they're
the ciphers that still have cache and timing leaks in them. (Neither
one can be sanitised without making it _extremely_ slow - the factor
of 4.5 slowdown in DES would be small by comparison).

Single-DES is also still below the warning threshold for simply being
too weak (irrespective of side channels), but it's above the other two.
2019-03-16 12:25:23 +00:00
Simon Tatham
31b4c6ad9c Draft FAQ entries for the spoofing defences. 2019-03-16 12:25:23 +00:00
Simon Tatham
514796b7e4 Add an interactive anti-spoofing prompt in Plink.
At the point when we change over the seat's trust status to untrusted
for the last time, to finish authentication, Plink will now present a
final interactive prompt saying 'Press Return to begin session'. This
is a hint that anything after that that resembles an auth prompt
should be treated with suspicion, because _PuTTY_ thinks it's finished
authenticating.

This is of course an annoying inconvenience for interactive users, so
I've tried to reduce its impact as much as I can. It doesn't happen in
GUI PuTTY at all (because the trust sigil system is used instead); it
doesn't happen if you use plink -batch (because then the user already
knows that they _never_ expect an interactive prompt); and it doesn't
happen if Plink's standard input is being redirected from anywhere
other than the terminal / console (because then it would be pointless
for the server to try to scam passphrases out of the user anyway,
since the user isn't in a position to enter one in response to a spoof
prompt). So it should only happen to people who are using Plink in a
terminal for interactive login purposes, and that's not _really_ what
I ever intended Plink to be used for (which is why it's never had any
out-of-band control UI like OpenSSH's ~ system).

If anyone _still_ doesn't like this new prompt, it can also be turned
off using the new -no-antispoof flag, if the user is willing to
knowingly assume the risk.
2019-03-16 12:25:23 +00:00
Simon Tatham
76d8d363be Seat method to set the current trust status.
In terminal-based GUI applications, this is passed through to
term_set_trust_status, to toggle whether lines are prefixed with the
new trust sigil. In console applications, the function returns false,
indicating to the backend that it should employ some other technique
for spoofing protection.
2019-03-16 12:25:23 +00:00
Simon Tatham
9c367eba4c Add a per-line 'trusted' status in Terminal.
This indicates that a line contains trusted information (originated by
PuTTY) or untrusted (from the server). Trusted lines are prefixed by a
three-column signature consisting of the trust sigil (i.e. PuTTY icon)
and a separating space.

To protect against a server using escape sequences to move the cursor
back up to a trusted line and overwrite its contents, any attempt to
write to a termline is preceded by a call to check_trust_status(),
which clears the line completely if the terminal's current trust
status is different from the previous state of that line.

In the terminal data structures, the trust sigil is represented by
0xDFFE (an otherwise unused value, because it's in the surrogate
space). For bidi purposes I've arranged to treat that value as
direction-neutral, so that it will appear on the right if a terminal
line needs it to. (Not that that's currently likely to happen, with
PuTTY not being properly localised, but it's a bit of futureproofing.)

The bidi system is also where I actually insert the trust sigil: the
_logical_ terminal data structures don't include it. term_bidi_line
was a convenient place to add it, because that function was already
transforming a logical terminal line into a physical one in a way that
also generates a logical<->physical mapping table for handling mouse
clicks and cursor positioning; so that function now adds the trust
sigil as well as running the bidi algorithm.

(A knock-on effect of _that_ is that the log<->phys position map now
has to have a value for 'no correspondence', because if the user does
click on the trust sigil, there's no logical terminal position
corresponding to that. So the map can now contain the special value
BIDI_CHAR_INDEX_NONE, and anyone looking things up in it has to be
prepared to receive that as an answer.)

Of course, this terminal-data transformation can't be kept _wholly_
within term_bidi_line, because unlike proper bidi, it actually reduces
the number of visible columns on the line. So the wrapping code
(during glyph display and also copy and paste) has to take account of
the trusted status and use it to ignore the last 3 columns of the
line. This is probably not done absolutely perfectly, but then, it
doesn't need to be - trusted lines will be filled with well-controlled
data generated from the SSH code, which won't be doing every trick in
the book with escape sequences. Only untrusted terminal lines will be
using all the terminal's capabilities, and they don't have this sigil
getting in the way.
2019-03-16 12:25:23 +00:00
Simon Tatham
2a5d8e05e8 Add a TermWin method to draw a 'trust sigil'.
This is not yet used by anything, but the idea is that it'll be a
graphic in the terminal window that can't be replicated by a server
sending escape sequences, and hence can be used as a reliable
indication that the text on a particular terminal line is generated by
PuTTY itself and not passed through from the server. This will make it
possible to detect a malicious server trying to mimic local prompts to
trick you out of information that shouldn't be sent over the wire
(such as private-key passphrases).

The trust sigil I've picked is a small copy of the PuTTY icon, which
is thematically nice (it can be read as if the PuTTY icon is the name
of the speaker in a dialogue) and also convenient because we had that
graphic available already on all platforms. (Though the contortions I
had to go through to make the GTK 1 code draw it were quite annoying.)

The trust sigil has the same dimensions as a CJK double-width
character, i.e. it's 2 character cells wide by 1 high.
2019-03-16 12:25:23 +00:00
Simon Tatham
e21afff605 Move sanitisation of k-i prompts into the SSH code.
Now, instead of each seat's prompt-handling function doing the
control-char sanitisation of prompt text, the SSH code does it. This
means we can do it differently depending on the prompt.

In particular, prompts _we_ generate (e.g. a genuine request for your
private key's passphrase) are not sanitised; but prompts coming from
the server (in keyboard-interactive mode, or its more restricted SSH-1
analogues, TIS and CryptoCard) are not only sanitised but also
line-length limited and surrounded by uncounterfeitable headers, like
I've just done to the authentication banners.

This should mean that if a malicious server tries to fake the local
passphrase prompt (perhaps because it's somehow already got a copy of
your _encrypted_ private key), you can tell the difference.
2019-03-16 12:25:23 +00:00
Simon Tatham
767a9c6e45 Add a 'from_server' flag in prompts_t.
This goes with the existing 'to_server' flag (indicating whether the
values typed by the user are going to be sent over the wire or remain
local), to indicate whether the _text of the prompts_ has come over
the wire or is originated locally.

Like to_server, nothing yet uses this. It's a hedge against the
possibility of maybe having an option for all the auth prompts to work
via GUI dialog boxes.
2019-03-16 12:25:23 +00:00
Simon Tatham
530b6fed5d Anti-spoofing protection for SSH auth banners.
The banner text sent by the server was already being run through a
StripCtrlChars. Now it's run through one in line-limiting mode, and
surrounded by header and footer lines long enough that the line-length
limit wouldn't allow the server to counterfeit one. So it should now
be reliably possible to tell what is banner text sent by the server,
and what is not.
2019-03-16 12:25:23 +00:00
Simon Tatham
3936616feb Add line-length limit feature in StripCtrlChars.
Now it can optionally check that output lines don't go beyond a
certain length (measured in terminal columns, via wcwidth, rather than
bytes or characters). In this mode, lines are prefixed with a
distinctive character (namely '|'), and if a line is too long, then it
is broken and the continuation line gets a different prefix ('>').

When StripCtrlChars is targeting a terminal, it asks the terminal to
call wcwidth on its behalf, so it can be sure to use the same idea as
the real terminal about which characters are wide (i.e. depending on
the configuration of ambiguous characters).

This mode isn't yet used anywhere.
2019-03-16 12:25:23 +00:00
Simon Tatham
da1c8f15b1 Limit the number of combining chars per terminal cell.
The previous unlimited system was nicely general, but unfortunately
meant you could easily DoS a PuTTY-based terminal by sending a
printing character followed by an endless stream of identical
combining chars. (In fact, due to accidentally-quadratic linked list
management, you'd DoS it by using up all the CPU even before you got
the point of making it allocate all the RAM.)

The new limit is chosen to be 32, more or less arbitrarily. Overlong
sequences of combining characters are signalled by turning the whole
character cell into U+FFFD REPLACEMENT CHARACTER.
2019-03-16 12:25:23 +00:00
Simon Tatham
b9d0371c47 Add validation of remote keys in ECC Diffie-Hellman.
In both the Weierstrass and Montgomery forms, we now check that the
provided curve point isn't a silly one, like the identity or a torsion
point, which will give little or no variation in the possible outputs
of key exchange.
2019-03-16 12:25:23 +00:00
Simon Tatham
5fbd294c20 Add missing dh_validate_f in GSSAPI key exchange.
This checks that the public Diffie-Hellman value sent by the server is
not an obviously silly one like 1 or -1 (mod p). We already had the
validation function, and were using it in standard DH key exchange,
but the parallel code in the GSSAPI case missed it out.
2019-03-16 12:25:23 +00:00
Simon Tatham
03777723e5 Fix crash printing a width-2 char in a width-1 terminal.
If the terminal is one column wide, it's not possible to print a
double-width CJK character at all - it won't fit. Replace it with
U+FFFD to indicate that impossibility.

The previous behaviour was to notice that we're in the rightmost
column of the terminal, and invoke the LATTR_WRAPPED2 special case to
wrap to the leftmost column on the next line. But in a width-1
terminal, the rightmost column _is_ the leftmost column, so this would
leave us no better off, and we would have fallen through into the next
case while in exactly the situation we'd tried to rule out.
2019-03-16 12:25:23 +00:00
Simon Tatham
daf91ef8ae Fix crash on ESC#6 + combining chars + GTK + odd-width terminal.
When we're displaying double-width text as a result of the VT100 ESC#6
escape sequence or its friends, and the terminal width is an odd
number of columns, we divide by 2 the number of characters we'll even
try to display, and round _down_: if there's a rightmost odd column,
it stays blank, and doesn't show the left half of a double-width char.

In the GTK redraw function, that rounding-down can set the 'len'
variable to zero. But when we're displaying a character with Unicode
combining chars on top, that fails an assertion that len == 1, because
at the top of the function we set it to 1.

The fix is just to return early if len is reduced to zero by that
rounding: if we're not displaying any characters, then we don't have
to do anything at all.
2019-03-16 12:25:23 +00:00
Simon Tatham
3edc1b330d Disallow REP escape sequence with no prior graphic char.
The REP escape (ESC [ nnn b) causes the previously printed graphic
character to be repeated another nnn times. So if it's sent as the
very first thing in a terminal session, when there _is_ no previously
printed graphic character, there's nothing sensible it can do.

In fact, in that situation, it does something decidedly _not_
sensible: it takes the uninitialised value term->last_graphic_char and
sends it directly to term_display_graphic_char, with undesirable
results if it's not actually a printing character. In particular, the
value 0 is treated as a combining char (because it has zero wcwidth),
leading to a knock-on assertion failure when compressing the
scrollback lines (which uses \0 as a terminating value for sequences
of combining characters, precisely because it expects it never to show
up in an actual cc slot!).
2019-03-16 12:25:23 +00:00
Simon Tatham
d828549995 RSA kex: enforce the minimum key length.
I completely forgot to check that the server had actually sent a key
of at least MINKLEN bits, as RFC 4432 clearly says that it MUST.
Without this restriction, not only can a server trick the client into
using a shared secret with inadequate entropy, but it can send a key
so short that the client attempts to generate a secret integer of
negative length, with integer-overflowing results.
2019-03-16 12:25:23 +00:00
Simon Tatham
5c926d9ea4 Switch to using poll(2) in place of select(2).
I've always thought poll was more hassle to set up, because if you
want to reuse part of your pollfds list between calls then you have to
index every fd by its position in the list as well as the fd number
itself, which gives you twice as many indices to keep track of than if
the fd is always its own key.

But the problem is that select is fundamentally limited to the range
of fds that can fit in an fd_set, which is not the range of fds that
can _exist_, so I've had a change of heart and now have to go with
poll.

For the moment, I've surrounded it with a 'pollwrapper' structure that
lets me treat it more or less like select, containing a tree234 that
maps each fd to its location in the list, and also translating between
the simple select r/w/x classification and the richer poll flags.
That's let me do the migration with minimal disruption to the call
sites.

In future perhaps I can start using poll more directly, and/or using
the richer flag system (though the latter might be fiddly because of
sometimes being constrained to use the glib event loop). But this will
do for now.
2019-03-16 12:25:23 +00:00
Simon Tatham
47202c4e16 Introduce an enum of the uxsel / select_result flags.
Those magic numbers 1,2,4 were getting annoying. Time to replace them
while I can still remember what they do.
2019-03-16 12:25:23 +00:00
Simon Tatham
9f0e0b02e3 Include the installer versions of binaries in checksum files.
Those hashes aren't directly needed for authenticating downloaded
files (the installer itself is checksummed, which covers all the files
it will unpack from itself). But they'll surely come in useful for
other purposes sooner or later, so we should arrange to keep them
somewhere easy to find.
2019-03-16 12:25:23 +00:00
Jacob Nevins
8b7458119f Tweak version string resources for EMBED_CHM.
So that it's possible to distinguish the CHMful from the CHMless binary
without running it.
2019-03-16 12:25:23 +00:00
Jacob Nevins
a8d3008143 Stop shipping old WinHelp (.HLP) file.
The executables were already ignoring it.

This is a minimal change; PUTTY.HLP can still be built, and there's
still all the context IDs lying around.

Buildscr changes are untested.
2019-03-16 12:25:23 +00:00
Simon Tatham
67d3791de8 Stop looking for putty.chm alongside the binary.
With this change, we stop expecting to find putty.chm alongside the
executable file. That was a security hazard comparable to DLL
hijacking, because of the risk that a malicious CHM file could be
dropped into the same directory as putty.exe (e.g. if someone ran
PuTTY from their browser's download dir)..

Instead, the standalone putty.exe (and other binaries needing help)
embed the proper CHM file within themselves, as a Windows resource,
and if called on to display the help then they write the file out to a
temporary location. This has the advantage that if you download and
run the standalone putty.exe then you actually _get_ help, which
previously didn't happen!

The versions of the binaries in the installer don't each contain a
copy of the help file; that would be extravagant. Instead, the
installer itself writes a registry entry pointing at the proper help
file, and the executables will look there.

Another effect of this commit is that I've withdrawn support for the
older .HLP format completely. It's now entirely outdated, and
supporting it through this security fix would have been a huge pain.
2019-03-16 12:25:23 +00:00
Simon Tatham
63a58759b5 Sanity-check the 'Public-Lines' field in ppk files.
If it's too large, memory allocation can fail, or worse,
under-allocate due to integer overflow.
2019-03-16 12:25:23 +00:00
Jacob Nevins
baa04337a4 Make 'scctest' compile according to instructions. 2019-03-16 12:12:34 +00:00