346 Commits

Author SHA1 Message Date
djm@openbsd.org
ea367b4bbc upstream: test the right thing, doofus
OpenBSD-Commit-ID: 31b2ec6e0b3dbd08c60ba2d969dd687cd80c25fd
2025-12-30 15:29:06 +11:00
djm@openbsd.org
5f2bc9cb86 upstream: avoid possible NULL deref if
ssh_packet_check_rekey_blocklimit() called before the encrypted transport is
brought up.

OpenBSD-Commit-ID: fb998ccbe59865e33a8ab6a6577f254d39bdc72f
2025-12-30 15:24:23 +11:00
djm@openbsd.org
dd49a87bf4 upstream: Remove bug compatibility for implementations that don't
support rekeying. AFAIK this is only an ancient Sun SSH version.

If such an implementation tries to interoperate with OpenSSH, it
will eventually fail when the transport needs rekeying.

This is probably long enough to use it to download a modern SSH
implementation that lacks this problem :)

ok markus@ deraadt@

OpenBSD-Commit-ID: 228a502fee808cf8b7caee23169eb6a1ab1c331a
2025-12-30 11:37:13 +11:00
djm@openbsd.org
ca313fef2d upstream: Enforce maximum packet/block limit during
pre-authentication phase

OpenSSH doesn't support rekeying before authentication completes to
minimise pre-auth attack surface.

Given LoginGraceTime, MaxAuthTries and strict KEX, it would be
difficult to send enough data or packets before authentication
completes to reach a point where rekeying is required, but we'd
prefer it to be completely impossible.

So this applies the default volume/packet rekeying limits to the
pre-auth phase. If these limits are exceeded the connection will
simply be closed.

ok dtucker markus

OpenBSD-Commit-ID: 70415098db739058006e4ebd1630b6bae8cc8bf6
2025-12-30 11:36:51 +11:00
dtucker@openbsd.org
eb97fc2b5e upstream: Add an ssh -Oconninfo command
that shows connection information, similar to the ~I escapechar.
This is the first use of the mux extension mechanism, so it should be
both forward and backward compatible: a new client talking to an old
server will not allow the "conninfo" request to be sent, but everything
else should work seamlessly.  feedback and ok djm@

OpenBSD-Commit-ID: 50f047a85da277360558cabdfed59cb66f754341
2025-12-05 18:05:44 +11:00
dtucker@openbsd.org
8fce5520a1 upstream: Add local hostname and pid to ~I escape connection info,
only display peer information for TCP connections including source address
and port This provides enough information to uniquely identify a connection
on the host or network.

OpenBSD-Commit-ID: aa18a4af2de41c298d1195d2566808585f8ce964
2025-11-29 19:00:57 +11:00
dtucker@openbsd.org
2e8b5de4a7 upstream: Add compression stats to ~I connection info escape
option.

OpenBSD-Commit-ID: 83424b71fc226ea6b3dc8dda39f993475fdbd775
2025-11-29 19:00:56 +11:00
dtucker@openbsd.org
52037ed910 upstream: Add Escape option ~I that shows information about the current
SSH connection. ok djm@, "I like/want" sthen@ florian@

OpenBSD-Commit-ID: 0483fc0188ec899077e4bc8e1e353f7dfa9f5c1d
2025-11-27 19:48:04 +11:00
djm@openbsd.org
4fddebe7f5 upstream: add some functions to free various structs, including
channels data and packet state; ok dtucker@ tb@

OpenBSD-Commit-ID: a8b3705309d632cdae370d4147a03e703087b0d1
2025-09-25 17:01:56 +10:00
Darren Tucker
59b80707c6 Create replacement sys/time.h if needed.
Remove #ifdef HAVE_SYS_TIME_H wrapper.  ok djm@
2025-09-05 17:48:22 +10:00
Darren Tucker
d45b17dc5a Create replacement poll.h if needed.
Remove #ifdef HAVE_POLL_H wrapper.  ok djm@
2025-09-05 17:17:52 +10:00
job@openbsd.org
ceca966bde upstream: Delete unused accessor function
OK dtucker@

OpenBSD-Commit-ID: 93b59ac088fb254e1189729ece5bb9656d6e810b
2025-08-29 13:51:46 +10:00
djm@openbsd.org
ae44cd74f3 upstream: cast
OpenBSD-Commit-ID: d69bd2328513c2dcd99f4f346b77e2bd90cf1964
2025-08-18 14:51:02 +10:00
djm@openbsd.org
289239046b upstream: Make ssh(1) and sshd(8) set IP QoS (aka IP_TOS, IPV6_TCLASS)
continually at runtime based on what sessions/channels are open.

Previously, ssh(1) and sshd(8) would pick a QoS value when they
were started and use it for the whole connection. This could
produce suboptimal choices for the QoS value, e.g. for multiplexed
sessions that started interactive but picked up a sftp client,
or sessions that moved large amounts of data via port forwarding.

Now the QoS value will change to the non-interactive IPQoS whenever
a "non-interactive" channel is open; basically any channel that lacks
a tty other than agent forwarding.

This is important now that the default interactive IPQoS is EF
(Expedited Forwarding), as many networks are configured to allow
only relatively small amounts of traffic of this class and they will
aggressively deprioritise the entire connection if this is exceeded.

NB. because ssh(1) and sshd(8) now change IP_TOS/IPV6_TCLASS
continually via setsockopt(), this commit requires a recent pledge(2)
change that landed recently in the OpenBSD kernel. Please ensure
you have updated to a kernel from within the last two weeks before
updating OpenSSH.

with job@ deraadt@

OpenBSD-Commit-ID: 325fc41717eecdf5e4b534bfa8d66817425b840f
2025-08-18 13:57:44 +10:00
djm@openbsd.org
2ebc638425 upstream: all state related to the ssh connection should live in
struct ssh or struct packet_state; one static int escaped this rule, so move
it to struct packet_state now.

ok millert tb

OpenBSD-Commit-ID: bd6737168bf61a836ffbdc99ee4803468db90a53
2025-08-07 09:45:02 +10:00
djm@openbsd.org
6ce00f0c2e upstream: Don't reply to PING in preauth phase or during KEX
Reported by the Qualys Security Advisory team. ok markus@

OpenBSD-Commit-ID: c656ac4abd1504389d1733d85152044b15830217
2025-02-18 19:03:28 +11:00
deraadt@openbsd.org
10ccf611ab upstream: As defined in the RFC, the SSH protocol has negotiable
compression support (which is requested as the name "zlib"). Compression
starts very early in the session. Relative early in OpenSSH lifetime, privsep
was added to sshd, and this required a shared-memory hack so the two
processes could see what was going on in the dataflow.  This shared-memory
hack was soon recognized as a tremendous complexity risk, because it put libz
(which very much trusts it's memory) in a dangerous place, and a new option
("zlib@openssh.com") was added begins compression after authentication (aka
delayed-compression).  That change also permitted removal of the
shared-memory hack. Despite removal from the server, the old "zlib" support
remained in the client, to allow negotiation with non-OpenSSH daemons which
lack the delayed-compression option. This commit deletes support for the
older "zlib" option in the client. It reduces our featureset in a small way,
and encourages other servers to move to a better design. The SSH protocol is
different enough that compressed-key-material attacks like BEAST are
unlikely, but who wants to take the chance? We encourage other ssh servers
who care about optional compression support to add delayed-zlib support.
(Some already do "zlib@openssh.com") ok djm markus

OpenBSD-Commit-ID: 6df986f38e4ab389f795a6e39e7c6857a763ba72
2024-08-27 09:05:43 +10:00
Damien Miller
60c2cf22e8 remove gratuitious difference from OpenBSD 2024-08-15 12:43:47 +10:00
djm@openbsd.org
7bdfc20516 upstream: Convert RSA and ECDSA key to the libcrypto EVP_PKEY API.
DSA remains unconverted as it will be removed within six months.

Based on patches originally from Dmitry Belyavskiy, but significantly
reworked based on feedback from Bob Beck, Joel Sing and especially
Theo Buehler (apologies to anyone I've missed).

ok tb@

OpenBSD-Commit-ID: d098744e89f1dc7e5952a6817bef234eced648b5
2024-08-15 12:07:59 +10:00
djm@openbsd.org
a4b5bc246c upstream: typos
OpenBSD-Commit-ID: edfa72eb06bfa65da30fabf7d2fe76d2d33f77bf
2024-05-31 19:04:11 +10:00
djm@openbsd.org
03e3de416e upstream: Start the process of splitting sshd into separate
binaries. This step splits sshd into a listener and a session binary. More
splits are planned.

After this changes, the listener binary will validate the configuration,
load the hostkeys, listen on port 22 and manage MaxStartups only. All
session handling will be performed by a new sshd-session binary that the
listener fork+execs.

This reduces the listener process to the minimum necessary and sets us
up for future work on the sshd-session binary.

feedback/ok markus@ deraadt@

NB. if you're updating via source, please restart sshd after installing,
otherwise you run the risk of locking yourself out.

OpenBSD-Commit-ID: 43c04a1ab96cdbdeb53d2df0125a6d42c5f19934
2024-05-17 14:41:35 +10:00
djm@openbsd.org
1edb00c58f upstream: implement "strict key exchange" in ssh and sshd
This adds a protocol extension to improve the integrity of the SSH
transport protocol, particular in and around the initial key exchange
(KEX) phase.

Full details of the extension are in the PROTOCOL file.

with markus@

OpenBSD-Commit-ID: 2a66ac962f0a630d7945fee54004ed9e9c439f14
2023-12-19 01:51:11 +11:00
djm@openbsd.org
7603ba7126 upstream: Add keystroke timing obfuscation to the client.
This attempts to hide inter-keystroke timings by sending interactive
traffic at fixed intervals (default: every 20ms) when there is only a
small amount of data being sent. It also sends fake "chaff" keystrokes
for a random interval after the last real keystroke. These are
controlled by a new ssh_config ObscureKeystrokeTiming keyword/

feedback/ok markus@

OpenBSD-Commit-ID: 02231ddd4f442212820976068c34a36e3c1b15be
2023-08-28 13:34:10 +10:00
djm@openbsd.org
dce6d80d2e upstream: Introduce a transport-level ping facility
This adds a pair of SSH transport protocol messages SSH2_MSG_PING/PONG
to implement a ping capability. These messages use numbers in the "local
extensions" number space and are advertised using a "ping@openssh.com"
ext-info message with a string version number of "0".

ok markus@

OpenBSD-Commit-ID: b6b3c4cb2084c62f85a8dc67cf74954015eb547f
2023-08-28 13:34:01 +10:00
djm@openbsd.org
3a7b110fbc upstream: remove redundant ssh!=NULL check; we'd already
dereferenced it

OpenBSD-Commit-ID: 852bf12591ec5a9fb12dcbde9b1fd3945ad0df3c
2023-04-06 13:27:17 +10:00
dtucker@openbsd.org
4a3918f51b upstream: Ensure ms_remain is always initialized
similar to what we do in ssh_packet_write_wait.  bz#2687, from jjelen
at redhat.com.

OpenBSD-Commit-ID: a50e0541cf823f8d1c72f71ccde925d3dbe6dfac
2023-03-04 14:43:10 +11:00
djm@openbsd.org
fcf5365da6 upstream: whitespace
OpenBSD-Commit-ID: c2bcbf93610d3d62ed206cdf9bf9ff98c6aaf232
2022-08-31 12:57:42 +10:00
djm@openbsd.org
b30d32159d upstream: add a ssh_packet_process_read() function that reads from
a fd directly into the transport input buffer.

Use this in the client and server mainloops to avoid unnecessary
copying. It also lets us use a more greedy read size without penalty.

Yields a 2-3% performance gain on cipher-speed.sh (in a fairly
unscientific test tbf)

feedback dtucker@ ok markus@

OpenBSD-Commit-ID: df4112125bf79d8e38e79a77113e1b373078e632
2022-01-25 12:18:35 +11:00
djm@openbsd.org
d23b4f7fdb upstream: correct comment and use local variable instead of long
indirection; spotted by dtucker@

OpenBSD-Commit-ID: 5f65f5f69db2b7d80a0a81b08f390a63f8845965
2022-01-25 10:33:03 +11:00
djm@openbsd.org
d1051c0f11 upstream: when decompressing zlib compressed packets, use
Z_SYNC_FLUSH instead of Z_PARTIAL_FLUSH as the latter is not actually
specified as a valid mode for inflate(). There should be no practical change
in behaviour as the compression side ensures a flush that should make all
data available to the receiver in all cases.

repoted by lamm AT ibm.com via bz3372; ok markus

OpenBSD-Commit-ID: 67cfc1fa8261feae6d2cc0c554711c97867cc81b
2022-01-18 11:15:23 +11:00
jsg@openbsd.org
cb885178f3 upstream: spelling ok dtucker@
OpenBSD-Commit-ID: bfc7ba74c22c928de2e257328b3f1274a3dfdf19
2022-01-01 15:19:48 +11:00
djm@openbsd.org
15db86611b upstream: debug("func: ...") -> debug_f("...")
OpenBSD-Commit-ID: d58494dc05c985326a895adfbe16fbd5bcc54347
2021-11-27 18:22:41 +11:00
deraadt@openbsd.org
6582a31c38 upstream: replace select() with ppoll(), including converting
timeval's to timespec's to make things easier. back and forth and ok; djm

OpenBSD-Commit-ID: 89d3b23c60875da919e7820f9de6213286ffbec9
2021-11-18 09:09:59 +11:00
djm@openbsd.org
073f45c236 upstream: Explicitly check for and start time-based rekeying in the
client and server mainloops.

Previously the rekey timeout could expire but rekeying would not start
until a packet was sent or received. This could cause us to spin in
select() on the rekey timeout if the connection was quiet.

ok markus@

OpenBSD-Commit-ID: 4356cf50d7900f3df0a8f2117d9e07c91b9ff987
2021-07-16 19:21:04 +10:00
djm@openbsd.org
31d8d231eb upstream: highly polished whitespace, mostly fixing spaces-for-tab
and bad indentation on continuation lines. Prompted by GHPR#185

OpenBSD-Commit-ID: e5c81f0cbdcc6144df1ce468ec1bac366d8ad6e9
2021-04-03 17:23:02 +11:00
djm@openbsd.org
39be3dc209 upstream: make ssh->kex->session_id a sshbuf instead of u_char*/size_t
and use that instead of global variables containing copies of it. feedback/ok
markus@

OpenBSD-Commit-ID: a4b1b1ca4afd2e37cb9f64f737b30a6a7f96af68
2021-01-27 21:10:57 +11:00
djm@openbsd.org
33313ebc1c upstream: Set the specified TOS/DSCP for interactive use prior to
TCP connect. The connection phase of the SSH session is time-sensitive (due
to server side login grace periods) and is frequently interactive (e.g.
entering passwords). The ultimate interactive/bulk TOS/DSCP will be set after
authentication completes.

ok dtucker@

OpenBSD-Commit-ID: f31ab10d9233363a6d2c9996007083ba43a093f1
2020-11-27 13:21:16 +11:00
djm@openbsd.org
816036f142 upstream: use the new variant log macros instead of prepending
__func__ and appending ssh_err(r) manually; ok markus@

OpenBSD-Commit-ID: 1f14b80bcfa85414b2a1a6ff714fb5362687ace8
2020-10-18 23:46:29 +11:00
djm@openbsd.org
6d755706a0 upstream: some language improvements; ok markus
OpenBSD-Commit-ID: 939d787d571b4d5da50b3b721fd0b2ac236acaa8
2020-07-15 15:07:42 +10:00
markus@openbsd.org
55ef3e9cbd upstream: free kex in ssh_packet_close; ok djm semarie
OpenBSD-Commit-ID: dbc181e90d3d32fd97b10d75e68e374270e070a2
2020-07-03 15:12:31 +10:00
semarie@openbsd.org
14beca57ac upstream: backout 1.293 fix kex mem-leak in ssh_packet_close at markus
request

the change introduced a NULL deref in sshpkt_vfatal() (uses of ssh->kex after
calling ssh_packet_clear_keys())

OpenBSD-Commit-ID: 9c9a6721411461b0b1c28dc00930d7251a798484
2020-06-27 20:23:27 +10:00
markus@openbsd.org
07f5f369a2 upstream: fix kex mem-leak in ssh_packet_close; ok djm
OpenBSD-Commit-ID: e2e9533f393620383afd0b68ef435de8d5e8abe4
2020-06-26 15:18:44 +10:00
markus@openbsd.org
e35995088c upstream: fix ssh -O proxy w/mux which got broken by no longer
making ssh->kex optional in packet.c revision 1.278 ok djm@

OpenBSD-Commit-ID: 2b65df04a064c2c6277359921d2320c90ab7d917
2020-06-26 15:18:44 +10:00
markus@openbsd.org
1ddf5682f3 upstream: consistently check packet_timeout_ms against 0; ok djm
OpenBSD-Commit-ID: e8fb8cb2c96c980f075069302534eaf830929928
2020-03-13 13:18:09 +11:00
djm@openbsd.org
dce74eab0c upstream: have sshpkt_fatal() save/restore errno before we
potentially call strerror() (via ssh_err()); ok dtucker

OpenBSD-Commit-ID: 5590df31d21405498c848245b85c24acb84ad787
2020-01-30 18:22:34 +11:00
dtucker@openbsd.org
fbce7c1a89 upstream: Fix typo in comment.
OpenBSD-Commit-ID: d1d7a6553208bf439378fd1cf686a828aceb353a
2020-01-23 22:33:18 +11:00
dtucker@openbsd.org
7f8e66fea8 upstream: Make zlib optional. This adds a "ZLIB" build time option
that allows building without zlib compression and associated options.  With
feedback from markus@, ok djm@

OpenBSD-Commit-ID: 44c6e1133a90fd15a3aa865bdedc53bab28b7910
2020-01-23 21:53:54 +11:00
tobhe@openbsd.org
f65cf1163f upstream: strdup may return NULL if memory allocation fails. Use
the safer xstrdup which fatals on allocation failures.

ok markus@

OpenBSD-Commit-ID: 8b608d387120630753cbcb8110e0b019c0c9a0d0
2019-12-20 14:25:08 +11:00
Darren Tucker
6fc7e1c6fe Wrap poll.h includes in HAVE_POLL_H. 2019-10-28 16:27:53 +11:00
deraadt@openbsd.org
4d28fa78ab upstream: When system calls indicate an error they return -1, not
some arbitrary value < 0.  errno is only updated in this case.  Change all
(most?) callers of syscalls to follow this better, and let's see if this
strictness helps us in the future.

OpenBSD-Commit-ID: 48081f00db7518e3b712a49dca06efc2a5428075
2019-07-05 11:10:39 +10:00