1
1
Граф коммитов

5513 Коммитов

Автор SHA1 Сообщение Дата
Jakub Jelen
4975487c18 config: Include files with relative paths
The libssh versions before this included files with relative path based
on the current working directory, which can result unexpected results
and is different from the OpenSSH include behavior. The manual page for
ssh_config lists:

> iles without absolute paths are assumed to be in ~/.ssh if included in
> a user configuration file or /etc/ssh if included from the system
> configuration file.

This is following the semantics as close as possible with a difference
that we do not use the hardcoded ~/.ssh for user configuration files,
but the path defined with SSH_OPTIONS_SSH_DIR, which is already used
to reference any other files in used home directory.

Fixes #93

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-02-10 18:22:20 +01:00
Jakub Jelen
ded3a17738 options: Updated doc text to reflect reality
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-02-10 18:22:20 +01:00
Jakub Jelen
0b14e40710 Fix broken link to an issue
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
2022-02-10 14:06:18 +01:00
Jakub Jelen
24ac4a0129 misc: Initialize the host buffer
This fails if the gethostname() fails in a way that does not write the
buffer, but returns 0 as a success.

Fixes #106

Thanks oss-fuzz

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
2022-02-10 14:06:18 +01:00
Jakub Jelen
ea83a27371 libcrypto: Initialize returning size_t value
This prevents the usage of uninitialized value on error in the known
hosts hasing code if invalid (empty) hostname is used.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
2022-02-10 14:05:24 +01:00
Jakub Jelen
d171a6e444 match: Optimize pattern matching even more
The adjacent question marks and asterisks can be simplified to single
wildcard so there is no need to excersise all the recursive pattern
matching.

These inputs were generated by oss-fuzz and probably caused also the
previously reported timeouts.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-02-10 11:21:19 +01:00
Jakub Jelen
44665f33a4 fuzz: Add a testcase for each fuzzer with a corpus
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-02-10 11:21:19 +01:00
Jakub Jelen
2e68cfbf40 fuzz: Add known_hosts file fuzzer
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-02-10 11:21:19 +01:00
Jakub Jelen
bf7149f205 match: Limit recursion to 16
This is more than enough as it reflects to 16 asterisks in the match
string is more than enough. With larger values oss-fuzz was generating
long match strings with asterisks interleaved with normal characters,
which were timing out.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-02-09 17:39:12 +01:00
Jakub Jelen
354438e758 match: Reformat match_pattern
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-02-09 17:39:12 +01:00
Jakub Jelen
314c57d414 fuzz: Get rid of cpp mess in fuzzers
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-02-08 19:13:45 +01:00
Andreas Schneider
2756eae1c7 gitlab-ci: Use coverity build env
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-01-28 09:12:12 +01:00
Andreas Schneider
afcb85bfda gitlab-ci: Sort build env variables
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-01-28 09:11:11 +01:00
Jakub Jelen
86ee3f5a00 tests: Skip the workaround forcing SHA1 signatures
In certificate authentication with OpenSSH 8.0, the SHA2 signatures were
not accepted correctly [1]. This was not an issue up until the OpenSSH
8.8p1, which does no longer allow SHA1 signatures by default so this
broke the CI and tests against the new OpenSSH [2].

Fixes !107

[1] https://bugzilla.mindrot.org/show_bug.cgi?id=3016
[2] https://gitlab.com/libssh/libssh-mirror/-/issues/107

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-01-28 08:54:07 +01:00
Fabian Vogt
14991ad071 Soften behaviour of the Compression=no/yes option
Currently Compression=no (the default) force-disables zlib algos, while
Compression=yes force-enables it. This means that mismatching options between
client and server lead to connection failure. This can easily happen if the
server has default settings but the client specifies Compression=yes.

OpenSSH treats the option as a "prefer compression" setting:
Compression=no  -> none,zlib@openssh.com,zlib (default)
Compression=yes -> zlib@openssh.com,zlib,none

This commit changes the libssh behaviour to the same as OpenSSH.

Signed-off-by: Fabian Vogt <fabian@ritter-vogt.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-01-05 11:26:30 +01:00
Andreas Schneider
6f634af4fb libssh: Deprecate the SCP API
See also
https://lists.mindrot.org/pipermail/openssh-unix-dev/2021-September/039616.html

Fixes #91

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-01-03 14:45:16 +01:00
Andreas Schneider
a52c66008e Happy new year 2022!
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2022-01-01 06:57:24 +01:00
brian m. carlson
c573adced4 server: reply with PK_OK with correct algorithm
RFC 4252 §7 states that the public key algorithm in a
SSH_MSG_USERAUTH_PK_OK response is the public key algorithm name from
the request.  When using RSA with SHA-2, this will be either
"rsa-sha2-256" or "rsa-sha2-512" as specified by RFC 8332 §3.2.

However, currently libssh emits the public key type instead, which is
"ssh-rsa".  This is not in conformance with the RFCs, so let's fix this
by storing the signature type and emitting it in our response instead of
the public key when sending SSH_MSG_USERAUTH_PK_OK in the server.

Signed-off-by: brian m. carlson <bk2204@github.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-12-07 12:27:18 +01:00
Jakub Jelen
42d1efe4f9 bind_config: Ignore empty lines
This also avoids buffer overflow with empty lines.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-11-10 10:13:20 +01:00
Jakub Jelen
0aa3b4ee81 tests: Introduce bind configuration fuzzer
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-11-10 10:12:56 +01:00
Jakub Jelen
e5e3c6267c tests: Break bind config tests to cover also string parsing entrypoint
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-11-10 10:12:56 +01:00
Jakub Jelen
ba8ce64a1d New API to provide configuration string for bind
Similarly as we already have for the client configuraiton file

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-11-10 10:12:56 +01:00
Jakub Jelen
d76d5c633f tests: Verify the recursive includes do not crash
neither client nor server configuration parser

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-11-10 10:12:56 +01:00
Jakub Jelen
227f416183 config: Avoid infinite recursion when using Include
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-11-10 10:12:56 +01:00
Norbert Pocs
99c6eb305e examples: Missing close for 'socket_fd' when error
Defect found by covscan

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-11-09 09:36:34 +01:00
Norbert Pocs
21b6418fd9 tests: Add condition for SSHD_EXECUTABLE
Do not compile tests which need SSHD_EXECUTABLE when
it is not available

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-11-09 09:36:31 +01:00
Stanislav Zidek
ce26b56e13 client configuration fuzzing and fixes
Signed-off-by: Stanislav Zidek <szidek@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-11-02 11:33:26 +01:00
Jakub Jelen
f2f680aede channels: Avoid memory leak
Thanks oss-fuzz:

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=40116

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-11-02 11:14:26 +01:00
Andrew Wiley
1a831cfe2c emulated poll: polling for nothing should at least get socket errors
Signed-off-by: Andrew Wiley <wiley@outlook.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-10-11 14:01:09 +02:00
Sahana Prasad
95539ba0eb Adds documentation about the order of processing the IdentityFiles
specified in ~/.ssh/config.

Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-10-11 14:00:36 +02:00
Biswapriyo Nath
4a2758ecd6 cmake: Install pkgconfig file in MinGW
Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-09-29 16:35:04 +02:00
Artyom V. Poptsov
1ab2340644 channels: Fix segfaults when the channel data is freed
Calling some channel procedures on a freed channel is always resulting
in segmentation fault errors.  The reason is that when a channel is
freed with 'ssh_channel_do_free' procedure, its 'session' field is set
to NULL; then when a channel procedure tries to access any field of
'channel->session' structure it is effectively dereferencing a NULL
pointer.

The change fixes that behavior by adding a check which ensures that a
channel state is not SSH_CHANNEL_FLAG_FREED_LOCAL before accessing its
parent session.

Also the test suite is updated to check for the fixed errors, and the
Doxygen documentation updated accordingly.

There was a bug introduced in b0fb7d15: 'ssh_channel_poll',
'ssh_channel_poll_timeout' and 'ssh_channel_get_exit_status' would
compare the channel state to the 'SSH_CHANNEL_FLAG_FREED_LOCAL'
constant to check if the channel is alive.  But the procedures must
check the channel flags for the presence of
'SSH_CHANNEL_FLAG_FREED_LOCAL' bits instead.  This change fixes the
bug.

Signed-off-by: Artyom V. Poptsov <poptsov.artyom@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-09-15 11:04:45 +02:00
Andreas Schneider
76b7e0e9b5 cpack: Do not package .cache directory used by clangd
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-08-26 14:58:38 +02:00
Jakub Jelen
f8817c0c35 tests: Simple reproducer for rekeying with different kex
We do not use SHA1 as it is disabled in many systems

Verifies CVE-2021-3634

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-08-18 14:13:56 +02:00
Jakub Jelen
f5211239f9 CVE-2021-3634: Create a separate length for session_id
Normally, the length of session_id and secret_hash is the same,
but if we will get into rekeying with a peer that changes preference
of key exchange algorithm, the new secret hash can be larger or
smaller than the previous session_id causing invalid reads or writes.

Resolves https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=35485

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-08-18 14:13:56 +02:00
Jakub Jelen
a3b2229a4e More consistent logging
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-08-18 14:13:56 +02:00
Andreas Schneider
fd9fda67f9 gitlab-ci: Fix indentation and complaints by yamllint
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-08-17 14:04:12 +02:00
Andreas Schneider
a7d2fe9503 Add editorconfig config file
See https://editorconfig.org/ for details.

(neo)vim: https://github.com/editorconfig/editorconfig-vim
emacs:    https://github.com/editorconfig/editorconfig-emacs

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-08-12 20:02:35 +02:00
Kevin Jones
188d0785e1 Update is_cert_type to account for security key certificates.
Signed-off-by: Kevin Jones <kevin@vcsjones.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-08-12 20:02:31 +02:00
Norbert Pocs
63f97a3d03 Fix some compiler warnings
Covscan analyzer was used

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-08-12 20:02:25 +02:00
Jakub Jelen
6daa95f9c1 .gitlab-ci: Allow failure of windows runners as they are broken
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-08-11 19:33:12 +02:00
Jeremy Cross
d1abe26be3 [#48/T22] Added missing server reply on auth-agent-req when a reply was requested by the client. PuTTY for Windows chokes without this reply if "Allow agent forwarding" is enabled. Reply will be successful if channel_auth_agent_req_function callback is defined. Based on an unmerged patch by Jon Simons.
Signed-off-by: Jeremy Cross <jcross@beyondtrust.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-07-07 14:17:07 +02:00
Jeremy Cross
0bee5d5e97 fixed issue with ssh_connector when data has been consumed by a channel callback
Signed-off-by: Jeremy Cross <jcross@beyondtrust.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-07-07 11:05:25 +02:00
Serdar Sanli
7dfed5c3cb Fix error in documentation
Signed-off-by: Serdar Sanli <mserdarsanli@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-07-06 11:25:32 +02:00
Xiang Xiao
925dc92d52 misc: Avoid the 4KB stack buffer in ssh_bind_options_expand_escape
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: Icfd24fdb8c7f549b8cb72d793cfc767979740fdc
2021-06-16 11:58:07 +02:00
Xiang Xiao
9eba361ca2 misc: Avoid the 4KB stack buffer in ssh_path_expand_escape
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I908ef4dfa960bf89f8e42f99af2f8bcdbb006bc8
2021-06-16 11:58:06 +02:00
Xiang Xiao
f2bd44969b Make the max file line length configurable
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I0bc70f4459a6eaa6f4c87887a5ee7822faf22443
2021-06-16 11:56:53 +02:00
Xiang Xiao
dbe504ea0a Make the transfer buffer size configurable
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I5052bac703b5a0c289ca5c28569cadeb54d3d507
2021-06-16 11:56:44 +02:00
Xiang Xiao
14276f0b51 log: add ssh_vlog to save the stack space
and add LOG_SIZE macro to control the buffer size

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I3eaeea001fc531fdb55074fc3a9d140b27847c1f
2021-06-10 14:56:29 +02:00
Xiang Xiao
672c1f8a3a windows: Define PATH_MAX to MAX_PATH
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: Ib3358ecb029d93c263d3cb39da25e82a772ae2c7
2021-06-10 09:22:32 +02:00