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

4510 Commits

Author SHA1 Message Date
Ben Harris
9022dcd5c5 fuzzterm: add some output to allow this to be used for testing.
Not very much, but it might be useful for testing that changes don't
unexpectedly break things.
2015-10-28 22:08:59 +00:00
Ben Harris
7a5cb2838f Emit a distinct error message when the SSH server's host key is invalid.
This also means that FUZZING can just ignore host-key verification
failure while preserving invalid-host-key errors.
2015-10-28 22:08:59 +00:00
Ben Harris
12702cb17e Fix a null-pointer dereference in ecdsa_verifysig.
Bug found with the help of afl-fuzz.
2015-10-28 22:08:59 +00:00
Ben Harris
af1460d6e5 Add FUZZING support to ssh.c.
This adds the "none" cipher and MAC, and also disables kex signure
verification and host-key checking.  Since a client like this is
completely insecure, it also rewrites the client version string to
start "ISH", which should make it fail to interoperate with a real SSH
server.  The server version string is still expected to begin "SSH" so
the real packet captures can be used against it.
2015-10-28 22:08:58 +00:00
Ben Harris
5471539a67 Handle packets with no type byte by returning SSH_MSG_UNIMPLEMENTED.
The previous assertion failure is obviously wrong, but RFC 4253 doesn't
explicitly declare them to be a protocol error.  Currently, the incoming
packet isn't logged, which might cause some confusion for log parsers.

Bug found with the help of afl-fuzz.
2015-10-28 22:08:58 +00:00
Ben Harris
1d20c1b396 Add FUZZING build option that disables the random number generator.
Starting up the random number generator is by far the slowest part of
plink's startup, and randomness is bad for fuzzing, so disabling it
should make fuzzing more effective.
2015-10-28 22:08:58 +00:00
Ben Harris
f6b81af006 Add an explicit PROXY_FUZZ that just feeds a file into the backend.
This saves the need to fork and exec "cat", which should speed things
up.  It also ensures that the network output goes to /dev/null, which
should avoid problems with blocking when writing to a full pipe.
2015-10-28 22:08:58 +00:00
Ben Harris
b9cb75e8c5 Add __AFL_INIT() to uxplink to allow afl-fuzz to skip some startup overhead. 2015-10-28 22:08:58 +00:00
Ben Harris
389eb4b7e0 When checking for an existing log, store the FILE * in a local variable.
It's not used outside logfopen, and leaving an invalid file pointer
lying around in the log context caused a segfault if the user
cancelled logging.

Bug found by afl-fuzz before it had even started fuzzing.
2015-10-28 22:08:58 +00:00
Ben Harris
7924aa945a Add a -fuzznet option to Unix plink.
It just sets the proxy command to "cat %host", which is crude and slow
but seems like a good starting point.
2015-10-28 22:08:57 +00:00
Ben Harris
5171dcb982 Check the x argument to check_boundary() more carefully.
This is a minimal fix for CVE-2015-5309, and while it's probably
unnecessary now, it seems worth committing for defence in depth and to
give downstreams something reasonably non-intrusive to cherry-pick.
2015-10-28 22:08:33 +00:00
Ben Harris
0629f1dfa5 Fix an assertion failure when loading Ed25519 keys.
"amax == 0 || a[amax] != 0"

Essentially, when decodepoint_ed() clears the top bit of the key, it
needs to call bn_restore_invariant() in case that left the high-order
word zero.

Bug found with the help of afl-fuzz.
2015-10-28 22:08:33 +00:00
Ben Harris
b94a076955 Since we have bn_restore_invariant, we may as well use it more. 2015-10-28 22:08:32 +00:00
Ben Harris
19d1ad3887 fuzzterm: Try enabling deferred implementation under afl-clang-fast 2015-10-28 22:08:32 +00:00
Ben Harris
4f34059902 bignum_set_bit: Don't abort if asked to clear an inaccessible bit
All those bits are clear anyway.

Bug found with the help of afl-fuzz.
2015-10-28 22:08:32 +00:00
Ben Harris
c0e19ca19d In get_ssh_string, don't get confused by lengths >= 0x80000000.
"confused" meaning "reading off the end of the input".

Bug found with the help of afl-fuzz.
2015-10-28 22:08:32 +00:00
Ben Harris
7707aa24d6 rsa2_pubkey_bits: Cope correctly with a NULL return from rsa2_newkey()
Dereferencing it is not correct.
Bug found with the help of afl-fuzz.
2015-10-28 22:08:32 +00:00
Ben Harris
63b47ed9d5 Another ecdsa_newkey crash: initialise ec->privateKey earlier.
This one might be exploitable, since without the fix, ecdsa_freekey()
tries to wipe the bignum pointed to by an uninitialised pointer.

Bug found with the help of afl-fuzz.
2015-10-28 22:08:32 +00:00
Ben Harris
f69b371bcd ecdsa_newkey: fix a crash where the second curve name is missing or corrupt.
Bug found with the help of afl-fuzz.
2015-10-28 22:08:32 +00:00
Ben Harris
e3fe709a8f More robust control sequence parameter handling.
Parameters are now accumulated in unsigned integers and carefully checked
for overflow (which is turned into saturation).  Things that consume them
now have explicit range checks (again, saturating) to ensure that their
inputs are sane.  This should make it much harder to cause overflow by
supplying ludicrously large numbers.

Fixes two bugs found with the help of afl-fuzz.  One of them may be
exploitable and is CVE-2015-5309.
2015-10-28 22:08:19 +00:00
Ben Harris
1a009ab2e9 Fuzzable terminal emulator. 2015-10-28 21:46:30 +00:00
Ben Harris
323c3c70c9 Gratuitous colour ramps in the colour test file. 2015-10-28 21:38:36 +00:00
Ben Harris
5936c55c7f Check the x argument to check_boundary() more carefully.
This is a minimal fix for CVE-2015-5309, and while it's probably
unnecessary now, it seems worth committing for defence in depth and to
give downstreams something reasonably non-intrusive to cherry-pick.
2015-10-27 19:59:46 +00:00
Ben Harris
6056396f77 More robust control sequence parameter handling.
Parameters are now accumulated in unsigned integers and carefully checked
for overflow (which is turned into saturation).  Things that consume them
now have explicit range checks (again, saturating) to ensure that their
inputs are sane.  This should make it much harder to cause overflow by
supplying ludicrously large numbers.

Fixes two bugs found with the help of afl-fuzz.  One of them may be
exploitable and is CVE-2015-5309.
2015-10-27 19:59:14 +00:00
Ben Harris
f7365a2d57 Handle packets with no type byte by returning SSH_MSG_UNIMPLEMENTED.
The previous assertion failure is obviously wrong, but RFC 4253 doesn't
explicitly declare them to be a protocol error.  Currently, the incoming
packet isn't logged, which might cause some confusion for log parsers.

Bug found with the help of afl-fuzz.
2015-10-24 22:45:48 +01:00
Ben Harris
c445c745ec When checking for an existing log, store the FILE * in a local variable.
It's not used outside logfopen, and leaving an infalid file pointer
lying around in the log context caused a segfault if the user
cancelled logging.

Bug found by afl-fuzz before it had even started fuzzing.
2015-10-24 22:45:48 +01:00
Ben Harris
e170041a5d rsa2_pubkey_bits: Cope correctly with a NULL return from rsa2_newkey()
Dereferencing it is not correct.
Bug found with the help of afl-fuzz.

Conflicts:
	sshrsa.c
2015-10-24 22:32:59 +01:00
Simon Tatham
758ac4c206 Initialise the random state in ssh_test_for_upstream().
This protects the Unix platform sharing code in the case where no salt
file exists yet in the connection-sharing directory, in which case
make_dirname() will want to create one by using some random bytes, and
prior to this commit, would fail an assertion because the random
number generator wasn't set up.

It would be neater to just return FALSE from ssh_test_for_upstream in
that situation - if there's no salt file, then no sharing socket can
be valid anyway - but that would involve doing more violence to the
code structure than I'm currently prepared to do for a minor elegance
gain.
2015-10-24 16:44:37 +01:00
Jacob Nevins
48eafd66aa Update docs/usage for 'plink -shareexists'. 2015-10-22 01:48:35 +01:00
Jacob Nevins
9dd9860cc8 Update docs for Ed25519 and ChaCha20-Poly1305. 2015-10-22 01:48:02 +01:00
Jacob Nevins
9f9d72ec58 PuTTYgen's default hasn't been 1024 bits since 0.63. 2015-10-22 01:46:28 +01:00
Simon Tatham
c01dff38a3 Fix a double-free in Windows Pageant.
Reported by Colin Harrison; occurred on the error path in which the
user clicks 'cancel' in the passphrase box.
2015-10-18 20:24:51 +01:00
Tim Kosse
3a43bec44c Fix a format string vulnerability if MALLOC_LOG is set.
(cherry picked from commit e443fd3a77)
2015-10-17 17:35:22 +01:00
Tim Kosse
9c8a3cb6fb Fix format string vulnerabilities.
Reported by Jong-Gwon Kim. Also fixes a few memory leaks in the
process.

(cherry picked from commit 6a70f944f6)
2015-10-17 17:35:15 +01:00
Simon Tatham
5c76a93a44 Sanitise bad characters in log file names.
On Windows, colons are illegal in filenames, because they're part of
the path syntax. But colons can appear in automatically constructed
log file names, if an IPv6 address is expanded from the &H placeholder.

Now we coerce any such illegal characters to '.', which is a bit of a
bodge but should at least cause a log file to be generated.

(cherry picked from commit 64ec5e03d5)
2015-10-17 17:33:31 +01:00
Simon Tatham
fbea11f44b Shout more loudly if we can't open a log file.
A user points out that logging fopen failures to the Event Log is a
bit obscure, and it's possible to proceed for months in the assumption
that your sessions are being correctly logged when in fact the
partition was full or you were aiming them at the wrong directory. Now
we produce output visibly in the PuTTY window.

(cherry picked from commit e162810516)
2015-10-17 17:33:31 +01:00
Simon Tatham
31c5784d4b Command-line options to log sessions.
Log files, especially SSH packet logs, are often things you want to
generate in unusual circumstances, so it's good to have lots of ways
to ask for them. Particularly, it's especially painful to have to set
up a custom saved session to get diagnostics out of the command-line
tools.

I've added options '-sessionlog', '-sshlog' and '-sshrawlog', each of
which takes a filename argument. I think the fourth option (session
output but filtered down to the printable subset) is not really a
_debugging_ log in the same sense, so it's not as critical to have an
option for it.

(cherry picked from commit 13edf90e0a)
2015-10-17 17:33:31 +01:00
Simon Tatham
a815c3a8e1 Fix spurious EAGAIN in Plink host key (and other) prompts.
Plink sets standard input into nonblocking mode, meaning that read()
from fd 0 in an interactive context will typically return -1 EAGAIN.
But the prompt functions in uxcons.c, used for verifying SSH host keys
and suchlike, were doing an unguarded read() from fd 0, and then
panicking and aborting the session when they got EAGAIN.

Fixed by inventing a wrapper around read(2) which handles EAGAIN but
passes all other errors back to the caller. (Seemed slightly less
dangerous than the stateful alternative of temporarily re-blockifying
the file descriptor.)

(cherry picked from commit bea758a7ae)

Conflicts:
	unix/uxcons.c

Cherry-picker's notes: the conflict was a trivial one. The new
function block_and_read() by this commit appears just before
verify_ssh_host_key(), which has a new prototype on the source branch,
close enough to disrupt the patch hunk's context. Easily fixed.
2015-10-17 17:30:53 +01:00
Simon Tatham
8c803e725e Key rollover: fix the .htaccess files built by Buildscr.
The build script generates the .htaccess files that go in each
individual build and redirect generic names like 'putty.tar.gz' to the
real filenames including that build's version number. Those .htaccess
files redirect the corresponding signatures as well, so they need
updating now that we're generating signature files with a different
extension.

(cherry picked from commit 6744387924)
2015-10-17 17:30:17 +01:00
Simon Tatham
4252cdbd82 Key rollover: cut and paste errors in pgpkeys.but.
What should have been links to the old DSA keys were actually a second
copy of the links to the old RSA ones. Ahem.

(cherry picked from commit b62af0f40a)
2015-10-17 17:30:17 +01:00
Simon Tatham
6c04165719 Key rollover: add a checklist item for the Download page.
Next time I do a release, I'll have to remember to adjust the download
page links to the GPG signature files.

(cherry picked from commit 7524da621b)
2015-10-17 17:30:17 +01:00
Simon Tatham
aaeaae00a9 Key rollover: put the new Master Key fingerprint in the tools.
For the moment we're also retaining the old ones. Not sure when will
be the best time to get rid of those; after the next release, perhaps?

(cherry picked from commit e88b8d21f2)
2015-10-17 17:30:17 +01:00
Simon Tatham
43865aa161 Key rollover: switch to signing using the new keys.
sign.sh's command-line syntax has changed, so I've updated the sample
command line in CHECKLST as well. Also the file extensions of the
signatures have changed, so I've updated the pre-release verification
command line in CHECKLST too.

(cherry picked from commit 11eb75a260)
2015-10-17 17:30:17 +01:00
Simon Tatham
a063e52297 Key rollover: rewrite the PGP keys manual appendix.
This gives pride of place to the new set of keys we've recently
generated, and relegates the old ones to an afterthought.

(cherry picked from commit bb68baf53b)
2015-10-17 17:30:17 +01:00
Simon Tatham
eb319f9b6e pterm: set IUTF8 on pty devices depending on charset.
In a UTF-8 pterm, it makes sense to set the IUTF8 flag (on systems
that have one) on the pty device, so that line editing will take
account of UTF-8 multibyte characters.

(cherry picked from commit 1840103c05)
2015-10-17 17:30:17 +01:00
Simon Tatham
14464764da Performance: cache character widths returned from Pango.
Profiling reveals that pterm in Pango rendering mode uses an absurd
amount of CPU when it's not even actually _drawing_ the text, because
of all the calls to pango_layout_get_pixel_extents() while
pangofont_draw_text tries to work out which characters it can safely
draw as part of a long string. Caching the results speeds things up
greatly.

(cherry picked from commit c3ef30c883)
2015-10-17 17:30:17 +01:00
Simon Tatham
0eb3bf07fc 'pterm --display' should set $DISPLAY inside the terminal.
If you open a pterm on a different display via the --display
command-line option rather than by setting $DISPLAY, I think (and
other terminals seem to agree) that it's sensible to set $DISPLAY
anyway for processes running inside the terminal.

(cherry picked from commit dc16dd5aa4)
2015-10-17 17:30:17 +01:00
Simon Tatham
417421cace New formatting directive in logfile naming: &P for port number.
Users have requested this from time to time, for distinguishing log
file names when there's more than one SSH server running on different
ports of the same host. Since we do take account of that possibility
in other areas (e.g. we cache host keys indexed by (host,port) rather
than just host), it doesn't seem unreasonable to do so here too.

(cherry picked from commit 0550943b51)
2015-10-17 17:30:17 +01:00
Simon Tatham
f59445004e Work around a failure in Windows 10 jump lists.
We've had several reports that launching saved sessions from the
Windows 10 jump list fails; Changyu Li reports that this is because we
create those IShellLink objects with a command line string starting
with @, and in Windows 10 that causes the SetArguments method to
silently do the wrong thing.

(cherry picked from commit 8bf5c1b31f)
2015-10-17 17:30:17 +01:00
Simon Tatham
d61c6cad0b Don't try to load GSSAPI libs unless we'll use them.
A user reports that in a particular situation one of the calls to
LoadLibrary from wingss.c has unwanted side effects, and points out
that this happens even when the saved session has GSSAPI disabled. So
I've evaluated as much as possible of the condition under which we
check the results of GSS library loading, and deferred the library
loading itself until after that condition says we even care about the
results.

(cherry picked from commit 9a08d9a7c1)
2015-10-17 17:30:17 +01:00