Commit Graph

6794 Commits

Author SHA1 Message Date
Jakub Jelen
fef36def3d docs: Add missing channel requests
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/836>
2026-06-03 10:42:34 +02:00
Jakub Jelen
e2a2578eb0 docs: Add SK algorithms to the list of supported
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/836>
2026-06-03 10:42:33 +02:00
Jakub Jelen
d2eb9d4b36 docs: Add hostbound pubkey authentication
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/836>
2026-06-03 10:40:59 +02:00
Jakub Jelen
d496a89556 docs: Update list of implemented SFTP extensions
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/836>
2026-06-03 10:40:58 +02:00
Jakub Jelen
de3a5d1dc9 Use RFC9987 names for auth-agent request and channel
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/836>
2026-06-03 10:40:58 +02:00
Jakub Jelen
13b4c1f582 docs: Update list of implemented mechanism to match reality
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/836>
2026-06-03 10:40:58 +02:00
Jakub Jelen
7a543c7b44 docs: Reformat long lines
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/836>
2026-06-03 10:40:58 +02:00
Jakub Jelen
ae4191aa3e Add support for RFC9987 messages without openssh suffix
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/836>
2026-06-03 10:40:58 +02:00
Jakub Jelen
615142a87a Reformat ssh_packet_channel_open
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/836>
2026-06-03 10:40:58 +02:00
Jakub Jelen
01aded0a14 docs: SSH Agent is now RFC
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/836>
2026-06-03 10:40:58 +02:00
Jiami Lin
9075952491 packet: avoid logging uninitialized sequence number
ssh_packet_unimplemented() tries to unpack the uint32 sequence number from SSH_MSG_UNIMPLEMENTED. If the packet payload is malformed and does not contain the full sequence number, ssh_buffer_unpack() fails, but the function still logs seq. Return after the failed unpack so the uninitialized local variable is not formatted into the log message.

Signed-off-by: Jiami Lin <jiami3us@icloud.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/834>
2026-06-03 10:38:45 +02:00
Arthur Chan
55e729ba91 OSS-Fuzz: Fix blocking of ssh mock session
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/782>
2026-06-01 13:56:49 +02:00
Sudharshan Hegde
97fbcaa492 config: number of password prompts implementation
Signed-off-by: Sudharshan Hegde <sudharshanhegde68@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/832>
2026-06-01 13:55:08 +02:00
Sudharshan Hegde
e2954fbb76 config: Implement preferredAuthentications option
Signed-off-by: Sudharshan Hegde <sudharshanhegde68@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/832>
2026-06-01 13:51:05 +02:00
Sudharshan Hegde
32c7d7afa7 auth: extract ssh_auth_method_from_name() helper function
Signed-off-by: Sudharshan Hegde <sudharshanhegde68@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/832>
2026-06-01 13:51:04 +02:00
David Cermak
d94a96bf23 string: Made ssh_string_new() to zero-init payload on creation
Additional hardening realated to 3ce8bf3289 fix that
switches ssh_string_new() to calloc() so the payload bytes
are zero-initialised. ssh_string is used throughout libssh as a
byte container for wire data and crypto material; the uninitialised
payload is never semantically meaningful, and zeroing it kills the
"forgot to check read_len" class of bugs at the source.

Signed-off-by: David Cermak <d_cermak@centrum.cz>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/829>
2026-05-08 14:23:34 +02:00
Jakub Jelen
bc3c8181e1 Fix semantics of strchr() for C23
In c23, strchr finally returns const char for const char pointers, which broke
CI after updating to Fedora 44 (gcc 16). The same issue surfaced on tumbleweed.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/830>
2026-05-05 18:29:53 +02:00
Jakub Jelen
f04a1fee42 CI: Use mold for opensuse
the original way of using this through update-alternatives no longer work

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/830>
2026-05-05 10:12:38 +02:00
Jakub Jelen
23b406f48e tests: Implement code coverage for ssh_userauth_kbdint_getprompt()
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/827>
2026-05-05 10:03:17 +02:00
Jakub Jelen
45cd13469c auth: Avoid off-by-one overflow during kbdint authentication
Based on incomplete !754

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/827>
2026-05-05 10:03:17 +02:00
Jakub Jelen
8e82aabc21 tests: Initialize pointers
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/827>
2026-05-05 10:03:17 +02:00
Colin Baumgarten
a33da974ef torture_packet: Improve checking of ssh_packet_socket_callback() return value
ssh_packet_socket_callback() will not return error codes like
SSH_ERROR on failure. Instead it will always return an unsigned
size_t value representing the number of bytes which have been
processed.

So adjust the assert in the test accordingly, making sure that all
input bytes have actually been processed.

Signed-off-by: Colin Baumgarten <colin.baumgarten@hubersuhner.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/824>
2026-05-04 16:56:06 +02:00
Colin Baumgarten
655601d357 packet: Avoid redundant recursive calls in the socket data callback
After processing a packet and before returning the processed size,
ssh_packet_socket_callback() recursively calls itself if there are
still unprocessed bytes remaining in the socket buffer.

This is redundant because this function is already called in a loop
by its only caller until the socket buffer is drained or only a
partial packet remains.

The recursive call was introduced with c92f54102e at a time
where ssh_packet_socket_callback() was not yet called in a loop.
The loop was only introduced later by 186116f34a.

So remove the redundant recursive call, but leave a log message in
place to allow following packet processing from the logs.

Signed-off-by: Colin Baumgarten <colin.baumgarten@hubersuhner.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/824>
2026-05-04 16:56:05 +02:00
Colin Baumgarten
1bd5c2b043 packet: Fix socket data callback return value on rekey failure
Both callers of ssh_packet_socket_callback() assume that it will
always return the number of bytes processed. They don't properly
handle negative return values like SSH_ERROR, even though the
function's doc-comment mentions them.

Handling negative values would not be straightforward because
the return type is unsigned (size_t).

So instead of fixing the callers, adjust the only place where a
negative value is returned right now (rekey failure) and align
it with the handling of all other possible errors in the same
function.

Signed-off-by: Colin Baumgarten <colin.baumgarten@hubersuhner.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/824>
2026-05-04 16:56:04 +02:00
Jakub Jelen
322b456790 dh-gex: Add missing goto error
Originally reported by Saransh Rana.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/825>
2026-05-04 16:40:58 +02:00
Colin Baumgarten
172dfe8d00 ci: Set job-level timeout for long-running jobs
The visualstudio jobs typically take longer than the gitlab
default project-level timeout of 1h.

This can cause build failures when a fork is created as part of
a merge request, because the fork will use the default project-level
timeout.

Set a job-level timeout of 2h which will override the project-level
one according to https://docs.gitlab.com/ci/yaml/#timeout to
eliminate the need to manually adjust the project-level timeout in
forks.

Signed-off-by: Colin Baumgarten <colin.baumgarten@hubersuhner.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/826>
2026-05-04 14:24:46 +02:00
Pavol Žáčik
81a7e92c44 gssapi: fail if the selected OID is not in client-supplied OIDs
This should not happen because the OID is selected
from a subset of client-supplied OID in gss_acquire_cred,
i.e., it would imply a bug in krb5. But better be safe,
it would later cause an out-of-bounds read in
ssh_gssapi_send_response.

Reported and patch provided by Meta (vulns@meta.com).

Signed-off-by: Pavol Žáčik <pzacik@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2026-05-04 12:16:08 +02:00
Nuhiat-Arefin
ad84df197c config: support ChallengeResponseAuthentication as an alias
Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/814>
2026-04-30 17:23:31 +02:00
Nuhiat-Arefin
0670983962 config: make RekeyLimit time argument optional
Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/814>
2026-04-30 17:23:28 +02:00
Nuhiat-Arefin
958e18ba75 options: add OpenSSH PubkeyAuthentication modes
Extend PubkeyAuthentication to support the OpenSSH-compatible modes no, yes/all, unbound, and host-bound.

Preserve the existing enable/disable flag behavior for callers using the legacy API, while also storing the selected mode and keeping the previous integer normalization in ssh_options_set().

Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/814>
2026-04-30 17:23:12 +02:00
Nuhiat-Arefin
6386ea5e81 auth: preserve pending publickey auth state
Set the publickey pending call state before the ssh-userauth service request so nonblocking calls can resume cleanly when the first SSH_AUTH_AGAIN happens before the auth request is sent.

Reset pending_call_state on the affected error paths, and only jump straight to the response handler once the auth state shows that the publickey request was already sent.

Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/814>
2026-04-30 17:23:12 +02:00
Nuhiat-Arefin
e1cb1edddf knownhosts: restrict StrictHostKeyChecking off on key mismatches
Keep the unknown host handling under StrictHostKeyChecking off, including writing accepted keys through to known_hosts.

For changed host keys and different stored key types, do not treat the host as fully trusted. In that path, disable password and keyboard interactive authentication before returning OK.

Apply the same handling in both ssh_is_server_known() and ssh_session_get_known_hosts_entry().

Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/814>
2026-04-30 17:23:12 +02:00
Nuhiat-Arefin
3e7e942b77 options: add OpenSSH StrictHostKeyChecking modes
Extend StrictHostKeyChecking from a boolean-style option to the full OpenSSH-compatible mode set: off, yes, ask and accept-new.

Preserve the legacy integer normalization used by ssh_options_set(), document the supported values in the public API, and switch the default to SSH_STRICT_HOSTKEY_ASK.

Known-host handling now recognizes SSH_STRICT_HOSTKEY_ACCEPT_NEW and stores unknown host keys automatically while still rejecting changes.

Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/814>
2026-04-30 17:23:12 +02:00
Nuhiat-Arefin
f3794da554 knownhosts: persist accepted keys when strict checking is off
When StrictHostKeyChecking is disabled, libssh previously returned SSH_KNOWN_HOSTS_OK from ssh_session_get_known_hosts_entry() without updating the user known_hosts file.

Persist the accepted key in that path and reload it from the user file so a host that was accepted once does not appear unknown again on the next connection.

Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/814>
2026-04-30 17:23:12 +02:00
Nuhiat-Arefin
84bdb7d9e2 config: require exact boolean tokens
Tighten boolean token handling in config parsing.

For auth-related boolean options, reject unknown tokens instead of silently treating them as false. Keep exact yes/no and true/false handling through ssh_config_get_yesno(), but parse Compression through a dedicated exact token map so it remains limited to yes/no.

Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/814>
2026-04-30 17:23:12 +02:00
Nuhiat-Arefin
6cd0e6e52a fix: initialize known_hosts output entry
ssh_session_get_known_hosts_entry() could return SSH_KNOWN_HOSTS_OK without initializing *pentry, leaving callers with an undefined output pointer.

Initialize *pentry to NULL at function entry so every return path leaves the output in a defined state.

Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/814>
2026-04-30 17:23:12 +02:00
Nuhiat-Arefin
854e9823f5 tests: cover %n and HostName handling
Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/811>
2026-04-30 16:45:25 +02:00
Nuhiat-Arefin
fc9963d29e config: add %n expansion and defer HostName normalization
Add %n support to path expansion.

Defer HostName handling so the expanded value is computed even when the final host cannot be applied yet. HostName specific expansion lowercases literal hostname text and %h expansions, while unsupported HostName %X tokens are preserved literally and normal host validation still applies when the result is passed to SSH_OPTIONS_HOST.

This keeps the expansion logic correct now and leaves room for future HostName token support without changing the deferred path again.

Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/811>
2026-04-30 16:45:24 +02:00
Nuhiat-Arefin
77ef6379a5 config: reject too small RekeyLimit values
OpenSSH rejects non zero RekeyLimit data values below 16 bytes. Match that behavior in libssh.

Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/815>
2026-04-30 15:05:56 +02:00
Nuhiat-Arefin
d157f13b27 config: support ConnectTimeout time values
Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/815>
2026-04-30 15:05:56 +02:00
Nuhiat-Arefin
e34704c203 misc: cap finite timeout conversion at INT_MAX
Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/815>
2026-04-30 15:05:55 +02:00
Nuhiat-Arefin
1dd721b26e config_parser: reject trailing garbage in numeric config values
Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/815>
2026-04-30 15:05:54 +02:00
Nuhiat-Arefin
a9b2831f63 options: validate SSH port values in the 1-65535 range
Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/815>
2026-04-30 15:05:53 +02:00
Jakub Jelen
13e1543205 ci: Add check for missing EOL on EOF
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/823>
2026-04-28 15:22:19 +02:00
Jakub Jelen
831ceff091 Add missing newline on eof
MacOS is choking on these:

/Users/gitlab/builds/libssh/libssh-mirror/src/packet_cb.c:508:2: error: no newline at end of file [-Werror,-Wnewline-eof]
}
 ^
1 error generated.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/823>
2026-04-28 15:22:19 +02:00
Jakub Jelen
d0f5747ab7 channels: Avoid remote window overflow
Reported-by: Rinku Das <rinkudaskajal7857@gmail.com>
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
2026-04-28 14:35:31 +02:00
Jakub Jelen
5eb9e6896e sftpserver: Check return value of sftp_client_message_get_filename()
Originally reported by nevv.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
2026-04-28 14:34:17 +02:00
Shreyas Mahajan
76548ce4e2 sftpserver: reformat format string
Signed-off-by: Shreyas Mahajan <shreyasmahajan05@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Eshan Kelkar <eshankelkar@galorithm.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/723>
2026-04-28 09:03:01 +02:00
Shreyas Mahajan
46ae737682 FIX for Typo
Signed-off-by: Shreyas Mahajan <shreyasmahajan05@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Eshan Kelkar <eshankelkar@galorithm.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/723>
2026-04-28 09:02:59 +02:00
Shreyas Mahajan
627001d441 Test Coverage for PING/Pong
Signed-off-by: Shreyas Mahajan <shreyasmahajan05@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Eshan Kelkar <eshankelkar@galorithm.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/723>
2026-04-28 09:02:58 +02:00