417 Commits

Author SHA1 Message Date
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
e3fdb82fb0 upstream: missed a case in previous
OpenBSD-Commit-ID: 271c5602b5e719ee3def19dbd9a33328b4fa7edc
2025-10-16 11:03:09 +11:00
djm@openbsd.org
d926a84d17 upstream: don't try to pledge() the client if a PKCS11Provider is
in use

OpenBSD-Commit-ID: 445b2bf4b1e36e515f4d888f35244fd2dcfbb566
2025-10-16 11:03:08 +11:00
jsg@openbsd.org
6f28a935cc upstream: consistently use NULL for null pointer constants found
with sparse, ok djm@

OpenBSD-Commit-ID: 1067504b63732d809d0d57ad4bc626818d112772
2025-09-25 17:01:40 +10:00
Darren Tucker
c729a83329 Move sys/time.h include to match upstream. 2025-09-05 19:22:37 +10:00
Darren Tucker
ea586edbcb Create replacement sys/stat.h if needed.
Remove #ifdef HAVE_SYS_STAT_H wrapper.  ok djm@
2025-09-05 17:50:18 +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
5f09983d1e Create replacement paths.h if needed.
Remove #ifdef HAVE_PATHS_H wrapper.  ok djm@
2025-09-05 17:24:50 +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
Damien Miller
9184fa3636 check for setsockopt IP_TOS in OpenBSD pledge
OpenBSD has recently relaxed the pledge(2) sandbox to allow some
setsockopt options to be changed without the "inet" promise.

This adds compatibility for OpenBSD that predates this relaxation.
2025-08-18 16:45:15 +10:00
Damien Miller
b7ee13fbbb wrap SIGINFO in ifdef 2025-08-18 14:22:18 +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
f807a598c9 upstream: SIGINFO handler for ssh(1) to dump active
channels/sessions ok deraadt@

OpenBSD-Commit-ID: 12f88a5044bca40ef5f41ff61b1755d0e25df901
2025-08-18 13:50:30 +10:00
djm@openbsd.org
b360f3a675 upstream: whitespace
OpenBSD-Commit-ID: 6e96814bcf70d0edbb0749ec61cc4fd8707f286d
2025-06-24 19:25:17 +10:00
dtucker@openbsd.org
80916d0d37 upstream: Plug mem leak. Patch from afonot via github PR#574, ok djm@
OpenBSD-Commit-ID: 65619f14ef206028ce39bc31f704b832a0609688
2025-06-16 19:12:31 +10:00
jsg@openbsd.org
c0b03c2534 upstream: spelling; ok djm@
OpenBSD-Commit-ID: c8ff3f70020451eef214e598117b7ce1a29853ef
2024-12-05 01:28:54 +11:00
djm@openbsd.org
fe6c6330c1 upstream: don't start the ObscureKeystrokeTiming mitigations if
there has been traffic on a X11 forwarding channel recently.

Should fix X11 forwarding performance problems when this setting is
enabled. Patch from Antonio Larrosa via bz3655

OpenBSD-Commit-ID: 820284a92eb4592fcd3d181a62c1b86b08a4a7ab
2024-10-14 09:21:08 +11:00
djm@openbsd.org
146c420d29 upstream: when sending ObscureKeystrokeTiming chaff packets, we
can't rely on channel_did_enqueue to tell that there is data to send. This
flag indicates that the channels code enqueued a packet on _this_ ppoll()
iteration, not that data was enqueued in _any_ ppoll() iteration in the
timeslice. ok markus@

OpenBSD-Commit-ID: 009b74fd2769b36b5284a0188ade182f00564136
2024-07-01 14:32:45 +10:00
jsg@openbsd.org
dcd79fa141 upstream: remove prototypes with no matching function; ok djm@
OpenBSD-Commit-ID: 6d9065dadea5f14a01bece0dbfe2fba1be31c693
2024-05-22 14:21:13 +10:00
djm@openbsd.org
1c0d813579 upstream: simplify exit message handling, which was more complicated
than it needed to be because of unexpunged ssh1 remnants. ok markus@

OpenBSD-Commit-ID: 8b0cd2c0dee75fb053718f442aa89510b684610b
2024-05-10 18:41:01 +10:00
djm@openbsd.org
66aaa678db upstream: correctly restore sigprocmask around ppoll() reported
by Tõivo Leedjärv; ok deraadt@

OpenBSD-Commit-ID: c0c0f89de5294a166578f071eade2501929c4686
2024-04-30 12:23:10 +10:00
djm@openbsd.org
80fb0eb215 upstream: add explict check for server hostkey type against
HostkeyAlgorithms. Allows HostkeyAlgorithms to disable implicit fallback from
certificate keys to plain keys. ok markus@

OpenBSD-Commit-ID: 364087e4a395ff9b2f42bf3aefdb2090bb23643a
2024-04-30 12:22:35 +10:00
djm@openbsd.org
9844aa2521 upstream: fix proxy multiplexing mode, broken when keystroke timing
obfuscation was added. GHPR#463 from montag451

OpenBSD-Commit-ID: 4e412d59b3f557d431f1d81c715a3bc0491cc677
2024-02-21 16:58:02 +11:00
dtucker@openbsd.org
3d44a5c565 upstream: Plug mem leak of msg when processing a quit message.
Coverity CID#427852, ok djm@

OpenBSD-Commit-ID: bf85362addbe2134c3d8c4b80f16601fbff823b7
2023-11-24 12:01:34 +11:00
djm@openbsd.org
050c335c8d upstream: when deciding whether to enable keystroke timing
obfuscation, only consider enabling it when a channel with a tty is open.

Avoids turning on the obfucation when X11 forwarding only is in use,
which slows it right down. Reported by Roger Marsh

OpenBSD-Commit-ID: c292f738db410f729190f92de100c39ec931a4f1
2023-11-16 09:53:42 +11:00
djm@openbsd.org
a612b93de5 upstream: mask SIGINT/TERM/QUIT/HUP before checking quit_pending
and use ppoll() to unmask them in the mainloop. Avoids race condition between
signaling ssh to exit and polling. bz3531; ok dtucker

OpenBSD-Commit-ID: 5c14e1aabcddedb95cdf972283d9c0d5083229e7
2023-10-12 13:19:40 +11:00
djm@openbsd.org
a752a6c0e1 upstream: add ChannelTimeout support to the client, mirroring the
same option in the server. ok markus@

OpenBSD-Commit-ID: 55630b26f390ac063980cfe7ad8c54b03284ef02
2023-10-12 10:00:13 +11:00
djm@openbsd.org
21b79af6c8 upstream: typo in comment
OpenBSD-Commit-ID: 69285e0ce962a7c6b0ab5f17a293c60a0a360a18
2023-09-11 09:13:42 +10:00
djm@openbsd.org
90ccc5918e upstream: randomise keystroke obfuscation intervals and average
interval rate. ok dtucker@

OpenBSD-Commit-ID: 05f61d051ab418fcfc4857ff306e420037502382
2023-09-10 13:27:40 +10:00
djm@openbsd.org
694150ad92 upstream: trigger keystroke timing obfucation only if the channels
layer enqueud some data in the last poll() cycle; this avoids triggering the
obfuscatior for non-channels data like ClientAlive probes and also fixes a
related problem were the obfucations would be triggered on fully quiescent
connections.

Based on / tested by naddy@

OpenBSD-Commit-ID: d98f32dc62d7663ff4660e4556e184032a0db123
2023-09-04 10:09:54 +10:00
djm@openbsd.org
b5fd97896b upstream: avoid bogus "obfuscate_keystroke_timing: stopping ..."
debug messages when keystroke timing obfuscation was never started; spotted
by naddy@

OpenBSD-Commit-ID: 5c270d35f7d2974db5c1646e9c64188f9393be31
2023-09-04 10:09:53 +10:00
djm@openbsd.org
3867361ca6 upstream: explicit long long type in timing calculations (doesn't
matter, since the range is pre-clamped)

OpenBSD-Commit-ID: f786ed902d04a5b8ecc581d068fea1a79aa772de
2023-08-28 14:07:56 +10: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
dtucker@openbsd.org
09d8da0849 upstream: Move up null check and simplify process_escapes.
Based on Coverity CID 291863 which points out we check the channel
pointer for NULLness after dereferencing it.  Move this to the start
of the function, and while there simplify initialization of efc a bit.
ok djm@

OpenBSD-Commit-ID: de36e5ad6fde0fe263ca134e986b9095dc59380a
2023-04-03 18:35:04 +10:00
djm@openbsd.org
c6011129ca upstream: remove redundant test
OpenBSD-Commit-ID: 6a0b719f9b1ae9d42ad8c5b144c7962c93792f7c
2023-03-31 15:06:20 +11:00
guenther@openbsd.org
51875897b8 upstream: Delete obsolete /* ARGSUSED */ lint comments.
ok miod@ millert@

OpenBSD-Commit-ID: 7be168a570264d59e96a7d2d22e927d45fee0e4c
2023-03-08 17:26:53 +11:00
dtucker@openbsd.org
e44846a448 upstream: Check for non-NULL before string
comparison. From jjelen at redhat.com via bz#2687.

OpenBSD-Commit-ID: 0d9b2e0cac88a311b5766b1aef737082583c285f
2023-03-04 14:42:56 +11:00
dtucker@openbsd.org
e37261dff3 upstream: Use time_t for x11_refuse_time timeout. We need
SSH_TIME_T_MAX for this, so move from misc.c to misc.h so it's available.
Fixes a Coverity warning for 64bit time_t safety, ok djm@

OpenBSD-Commit-ID: c69c4c3152cdaab953706db4ccf4d5fd682f7d8d
2023-03-03 14:16:42 +11:00
djm@openbsd.org
c60438158a upstream: Add channel_force_close()
This will forcibly close an open channel by simulating read/write errors,
draining the IO buffers and calling the detach function.

Previously the detach function was only ever called during channel garbage
collection, but there was no way to signal the user of a channel (e.g.
session.c) that its channel was being closed deliberately (vs. by the
usual state-machine logic). So this adds an extra "force" argument to the
channel cleanup callback to indicate this condition.

ok markus dtucker

OpenBSD-Commit-ID: 23052707a42bdc62fda2508636e624afd466324b
2023-01-06 16:21:39 +11:00
djm@openbsd.org
d478cdc7ad upstream: replace manual poll/ppoll timeout math with ptimeout API
feedback markus / ok markus dtucker

OpenBSD-Commit-ID: c5ec4f2d52684cdb788cd9cbc1bcf89464014be2
2023-01-06 16:21:39 +11:00
dtucker@openbsd.org
4a1805d532 upstream: Add void to client_repledge args to fix compiler warning. ok djm@
OpenBSD-Commit-ID: 7e964a641ce4a0a0a11f047953b29929d7a4b866
2022-11-30 12:16:14 +11:00
djm@openbsd.org
815c470493 upstream: tighten pledge(2) after session establishment
feedback, ok & testing in snaps deraadt@

OpenBSD-Commit-ID: aecf4d49d28586dfbcc74328d9333398fef9eb58
2022-11-30 12:16:10 +11:00
djm@openbsd.org
f7cebbbf40 upstream: New EnableEscapeCommandline ssh_config(5) option
This option (default "no") controls whether the ~C escape is available.
Turning it off by default means we will soon be able to use a stricter
default pledge(2) in the client.

feedback deraadt@ dtucker@; tested in snaps for a while

OpenBSD-Commit-ID: 7e277595d60acb8263118dcb66554472257b387a
2022-11-30 12:16:08 +11:00
dtucker@openbsd.org
650de7ecd3 upstream: Handle dynamic remote port forwarding in escape commandline's
-R processing. bz#3499, ok djm@

OpenBSD-Commit-ID: 194ee4cfe7ed0e2b8ad0727f493c798a50454208
2022-11-11 11:24:46 +11:00
djm@openbsd.org
db2027a687 upstream: rename client_global_hostkeys_private_confirm() to
client_global_hostkeys_prove_confirm(), as it handles the
"hostkeys-prove00@openssh.com" message; no functional change

OpenBSD-Commit-ID: 31e09bd3cca6eed26855b88fb8beed18e9bd026d
2022-11-09 20:43:16 +11:00
djm@openbsd.org
22e1a3a71a upstream: Make SetEnv directives first-match-wins in both
sshd_config and sshd_config; previously if the same name was reused then the
last would win (which is the opposite to how the config is supposed to work).

While there, make the ssh_config parsing more like sshd_config.

bz3438, ok dtucker

OpenBSD-Commit-ID: 797909c1e0262c0d00e09280459d7ab00f18273b
2022-06-03 14:33:18 +10:00
djm@openbsd.org
fec014785d upstream: Try to continue running local I/O for channels in state
OPEN during SSH transport rekeying. The most visible benefit is that it
should make ~-escapes work in the client (e.g. to exit) if the connection
happened to have stalled during a rekey event. Based work by and ok dtucker@

OpenBSD-Commit-ID: a66e8f254e92edd4ce09c9f750883ec8f1ea5f45
2022-04-20 15:08:54 +10:00
Darren Tucker
9fa63a19f6 Put poll.h inside ifdef. 2022-02-10 23:51:02 +11: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
c7964fb982 upstream: add a helper for writing an error message to the
stderr_buf and setting quit_pending; no functional change but saves a bunch
of boilerplate

OpenBSD-Commit-ID: 0747657cad6b9eabd514a6732adad537568e232d
2022-01-25 10:45:39 +11:00