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

5496 Коммитов

Автор SHA1 Сообщение Дата
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
Jakub Jelen
592d256a0b Enable freebsd runner also for jjelen
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-06-07 11:34:32 +02:00
Jakub Jelen
aac975b7b2 Unbreak build on freebsd
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-06-07 11:28:29 +02:00
Andrew Wiley
c40576c6f6 add moduli file location as an ssh_bind option
Signed-off-by: Andrew Wiley <wiley@outlook.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-06-04 22:27:51 -07:00
Andrew Wiley
6aa88e22d6 build samplesshd-cb example on Windows too
Signed-off-by: Andrew Wiley <wiley@outlook.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-06-04 22:27:51 -07:00
Andrew Wiley
bd7bef8b50 fix error checks on channel writes in samplesshd-cb example
Signed-off-by: Andrew Wiley <wiley@outlook.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-06-04 22:27:51 -07:00
Andrew Wiley
fb8d120bec make GSSAPI optional in the samplesshd-cb example
Signed-off-by: Andrew Wiley <wiley@outlook.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-06-04 22:27:51 -07:00
Xiang Xiao
286a706394 scp: Avoid allocate 8KB stack buffer in ssh_scp_deny_request
since ssh_scp_deny_request is seldom called, let's
utilize malloc to reserve the precise size memory.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I8e7a6d3153cff7691329b9487cd534a7f2887a35
2021-06-01 10:48:41 +08:00
Xiang Xiao
b6b5c59223 socket: Read the data directly into in_buffer
to avoid allocate 4KB buffer from stack

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: Id144ff764ee1ae98f87aee36793a9f0e4fce21b7
2021-05-31 21:44:08 +02:00
Xiang Xiao
f7369423a4 agent: Avoid 1KB temporary buffer in agent_talk
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I9acffc6deef534659f89ca8ddb0cd60b325aaeb2
2021-05-31 21:36:26 +02:00
Xiang Xiao
a8a74a70fa examples/ssh_server_fork: Support the multi-client through pthread
so the same code base demo both multi-process and multi-thread model

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I98554a99b7a31586be37abde7c357f81a05c3d6e
2021-05-31 12:21:42 +02:00
Xiang Xiao
3b29e2ad4c sftp: Read the data directly into packet->payload
to avoid allocate 16KB buffer from stack and one memory copy

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: Ib71cb5834b7810bf9791e13c58571e2b9fa5bca1
2021-05-27 13:45:47 +02:00
Xiang Xiao
3ab17e3fbd channels: Read into buffer directly in channel_read_buffer
to avoid allocate 8KB buffer from stack

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: Ifc198705cb8ecec6f0a609f84965382dc151693b
2021-05-27 13:45:47 +02:00
Xiang Xiao
c027585a50 Don't allocate ssh_blf_ctx from stack in bcrypt_pbkdf
to reduce the stack size requirement

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I6a91250524786af3358b0fd0f05ba8e45f76d278
2021-05-27 13:45:47 +02:00
Xiang Xiao
ef02e524df packet: Change the last argument of ssh_packet_encrypt to uint32_t
to match the implemntation in packet_crypt.c

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: Ib76c3585f67dae22ed0f1dfc10dadcd03c762032
2021-05-27 13:45:47 +02:00
Xiang Xiao
50934a542d mbedtls: Change the last argument of cipher_[de|en]crypt_cbc to size_t
to avoid their prototype different from ssh_cipher_struct

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I6cba2d4fea131f13d028226023da692494caa87d
2021-05-27 13:45:47 +02:00
Xiang Xiao
07245c1cdd Fix error: dereferencing pointer to incomplete type ‘struct timeval’
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I99d2016595966d805c9e27b5c2f2a0a5b4ad8611
2021-05-27 13:45:47 +02:00
Xiang Xiao
094aeeafbe examples/ssh_server: Free the resource in the failure path
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I60f64b9eda3ba233a825b2c4fe19d5bf7eaf2fa3
2021-05-27 13:45:47 +02:00