1
1

4205 Коммитов

Автор SHA1 Сообщение Дата
Anderson Toshiyuki Sasaki
68b0c7a934 CVE-2018-10933: Check channel state when OPEN_FAILURE arrives
When a SSH2_MSG_OPEN_FAILURE arrives, the channel state is checked
to be in SSH_CHANNEL_STATE_OPENING.

Fixes T101

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 09:19:03 +02:00
Anderson Toshiyuki Sasaki
459868c4a5 CVE-2018-10933: Check channel state when OPEN_CONFIRMATION arrives
When a SSH2_MSG_OPEN_CONFIRMATION arrives, the channel state is checked
to be in SSH_CHANNEL_STATE_OPENING.

Fixes T101

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 09:19:03 +02:00
Anderson Toshiyuki Sasaki
5d7414467d CVE-2018-10933: Set correct state after sending MIC
After sending the client token, the auth state is set as
SSH_AUTH_STATE_GSSAPI_MIC_SENT.  Then this can be expected to be the
state when a USERAUTH_FAILURE or USERAUTH_SUCCESS arrives.

Fixes T101

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 09:19:03 +02:00
Anderson Toshiyuki Sasaki
20981bf229 CVE-2018-10933: Introduce SSH_AUTH_STATE_AUTH_NONE_SENT
The introduced auth state allows to identify when a request without
authentication information was sent.

Fixes T101

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 09:19:03 +02:00
Anderson Toshiyuki Sasaki
825f4ba964 CVE-2018-10933: Introduce SSH_AUTH_STATE_PASSWORD_AUTH_SENT
The introduced auth state allows to identify when authentication using
password was tried.

Fixes T101

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 09:19:03 +02:00
Anderson Toshiyuki Sasaki
2bddafeb70 CVE-2018-10933: Introduced new auth states
Introduced the states SSH_AUTH_STATE_PUBKEY_OFFER_SENT and
SSH_AUTH_STATE_PUBKEY_AUTH_SENT to know when SSH2_MSG_USERAUTH_PK_OK and
SSH2_MSG_USERAUTH_SUCCESS should be expected.

Fixes T101

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 09:19:03 +02:00
Andreas Schneider
16b876d07f examples: Use ssh_session_update_known_hosts() for updating known_hosts
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 08:58:31 +02:00
Andreas Schneider
a80caec19b cmake: Disable deprecation warnings for old known_hosts API
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 08:56:46 +02:00
Andreas Schneider
d6b6fff7f7 cmake: Only check for -Wno-gnu-zero-variadic-macro-arguments with clang
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 08:46:25 +02:00
Andreas Schneider
259d7de153 include: Mark old known_hosts API as deprecated
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-13 22:08:41 +02:00
Tilo Eckert
d13517e922 chacha: remove re-declared type
re-declaring typedefs are not supported by some compilers

Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
2018-10-13 22:08:39 +02:00
Tilo Eckert
45058285fc knownhosts: Fix invalid read of known_hosts token
Fixes invalid read introduced by commit 21962d.
Accessing tokens[4] for a known_hosts line of
three tokens led to randomly rejected host keys.

This commit completely removes the check because
the optional comments field may contain whitespace.

Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
2018-10-13 22:08:36 +02:00
Jakub Jelen
42bd7cdf6c tests: Add aes-gcm ciphers tests
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-09 13:05:38 +02:00
Jakub Jelen
72bd2fe197 libmbedtls: Support OpenSSH-compatible AES-GCM ciphers using mbedTLS
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-09 13:05:38 +02:00
Jakub Jelen
a2120e168b libmbedtls: Simplify the cipher setup
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-09 13:05:38 +02:00
Jakub Jelen
5790036a23 libgcrypt: Implement OpenSSH-compatible AES-GCM ciphers using libgcrypt
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-09 13:05:38 +02:00
Jakub Jelen
032f486f27 cmake: Link against gpg-error
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-09 13:05:38 +02:00
Jakub Jelen
46090facba libcrypto: Implement OpenSSH-compatible AES-GCM ciphers using OpenSSL
The commit also propares the internals throughout the code base
for the inclusion of a new AEAD cipher, because previously, the
source code counted only with chacha20-poly1305 cipher, which
is very specific in many cases.

The SSH_HMAC_AEAD_GCM mac algorithm is not actually used, but the name
needed to be defined so we can match in the algorithms selection per
OpenSSH specification (MACs are ignored in case GCM is select as a cipher [1]).

If the provided OpenSSL does not provide  EVP_aes_128_gcm()  function,
the AES-GCM ciphers will not be compiled in.

[1] https://cvsweb.openbsd.org/src/usr.bin/ssh/PROTOCOL.chacha20poly1305?annotate=HEAD

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-09 12:05:40 +02:00
Jakub Jelen
777786d76c libcrypto: Do not use magic numbers for AES block size
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-09 12:05:40 +02:00
Jakub Jelen
101df98e54 libcrypto: Avoid double free
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-09 12:05:40 +02:00
Andreas Schneider
f747e46f33 init: Only add DllMain if we create a shared library
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-09 11:40:31 +02:00
Andreas Schneider
275f73125d packet: Use a stack buffer for the header
This removes the allocation for the header buffer for each packet we
send.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-10-08 09:27:12 +02:00
Andreas Schneider
422376efd4 packet: Reformat packet_send2()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-10-08 09:27:09 +02:00
Andreas Schneider
3245b50795 sftp: Only prepend header data once
This reduces memory moving.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-10-08 09:27:06 +02:00
Andreas Schneider
508dfc5251 sftp: Reformat sftp_packet_write()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-10-08 09:26:59 +02:00
Andreas Schneider
43a40999da agent: Use (PUSH|PULL)_BE_U32 in agent_talk()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-10-05 14:38:43 +02:00
Andreas Schneider
e701913fc8 agent: Just use uint32_t for the count
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-10-05 14:38:43 +02:00
Andreas Schneider
aec9fa4442 sftp: Use bytearray macros
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-10-05 14:38:43 +02:00
Andreas Schneider
85a274ff3c include: Add macros for bytearray handling
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-10-05 14:38:43 +02:00
Andreas Schneider
e210b61148 examples: Reformat knownhosts
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-05 14:38:43 +02:00
Andreas Schneider
f09ca85ebf cmake: Always build position independent code
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-02 14:48:02 +02:00
Andreas Schneider
096d966e43 gitlab-ci: Report errors on debian 2018-09-27 18:06:23 +02:00
Anderson Toshiyuki Sasaki
cc513c4c9a messages: Fixed possible memory leak in ssh_message_queue
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 15:21:30 +02:00
Anderson Toshiyuki Sasaki
31202822a7 examples: Add null checks in libssh_scp.c
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 15:21:30 +02:00
Anderson Toshiyuki Sasaki
6118628424 examples: Fix libssh_scp.c code style
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 15:21:30 +02:00
Anderson Toshiyuki Sasaki
00e5ef1b3c examples: Fix possible memory leak in libssh_scp.c
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 15:21:30 +02:00
Anderson Toshiyuki Sasaki
6eef4b4a3c tests: Add frees to avoid memory leak errors
The added frees are unnecessary, but the static analyser does not know.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 15:21:30 +02:00
Anderson Toshiyuki Sasaki
79e907402e tests: Replace ssh_buffer_free() with SSH_BUFFER_FREE()
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 15:21:30 +02:00
Anderson Toshiyuki Sasaki
ca7da823c3 tests: Replace ssh_string_free() with SSH_STRING_FREE()
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 15:21:30 +02:00
Anderson Toshiyuki Sasaki
2eaa23a20e tests: Replace ssh_key_free() with SSH_KEY_FREE()
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 15:21:30 +02:00
Anderson Toshiyuki Sasaki
143b5e2e50 tests: Use SSH_STRING_FREE_CHAR
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 15:21:30 +02:00
Anderson Toshiyuki Sasaki
11d480134c include: Add SSH_KEY_FREE
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 15:21:30 +02:00
Andreas Schneider
3786db4cdf gitlab-ci: Get build and test errors from mingw
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 08:45:41 +02:00
Andreas Schneider
9cf341bad3 gitlab-ci: Use -DCMAKE_BUILD_TYPE=UndefinedSanitizer
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-26 16:55:28 +02:00
Andreas Schneider
e57f0273a6 cmake: Add UndefinedSanitizer
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-26 16:54:31 +02:00
Andreas Schneider
3d74c3802e cmake: Also add DEFAULT_LINK_FLAGS for Solaris
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-26 16:53:29 +02:00
Anderson Toshiyuki Sasaki
667fb5f9a9 cmake: Rewritten AddCMockaTest.cmake
This changes add_cmocka_test() to receive compiler options, the
libraries to be linked to the test, and the linker options.  The way the
tests are declared in tests/unittests and tests/client were updated.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-26 16:27:22 +02:00
Alberto Aguirre
14f5624ff5 sftpserver: allocate packet on sftp_server_new
Ensure sftp_server_new allocates the packet and payload as
sftp_packet_read now expects the packet and payload to be
pre-allocated.

Similarly, ensure sftp_get_client_message does not free the packet.

Signed-off-by: Alberto Aguirre <albaguirre@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-25 16:41:54 +02:00
David Wedderwille
9adc2d36eb connector: Add checks if file descriptor is a socket
Fixes T104

Signed-off-by: David Wedderwille <davidwe@posteo.de>
2018-09-25 14:37:25 +02:00
Andreas Schneider
1e5e09563a socket: Pass MSG_NOSIGNAL to send()
This avoid that we get a SIGPIPE.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-25 14:37:25 +02:00