682 Commits

Author SHA1 Message Date
dtucker@openbsd.org
49480f1934 upstream: Add 'invaliduser' penalty to PerSourcePenalties, which is
applied to login attempts for usernames that do not match real accounts.
Defaults to 5s to match 'authfail' but allows administrators to block such
sources for longer if desired.  with & ok djm@

OpenBSD-Commit-ID: bb62797bcf2adceb96f608ce86d0bb042aff5834
2025-12-16 20:40:59 +11:00
dtucker@openbsd.org
d9955e4571 upstream: Remove calls to OpenSSL_add_all_algorithms()
and ERR_load_crypto_strings(). These are no-ops in LibreSSL, and in
Portable have been mostly replaced by a call to OPENSSL_init_crypto()
in the compat layer.  ok tb@

OpenBSD-Commit-ID: 4c3e0af10fe276766054eda34428a37a5606d3ea
2025-11-13 22:08:28 +11: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
23a2bb7505 replace remaining manual logging of __func__
Use the appropriate log macro that prepends the function name
(e.g. logit_f/debug2_f/etc).
2025-09-02 19:30:07 +10:00
djm@openbsd.org
a9a3f025d7 upstream: remove experimental support for XMSS keys;
ok deraadt markus

OpenBSD-Commit-ID: 38eaf4df6189acad9e46eddf7cf32d7f6d07df35
2025-08-29 13:58:40 +10:00
djm@openbsd.org
eddd1d2daa upstream: Fix mistracking of MaxStartups process exits in some
situations. At worst, this can cause all MaxStartups slots to fill and sshd
to refuse new connections.

Diagnosis by xnor; ok dtucker@

OpenBSD-Commit-ID: 10273033055552557196730f898ed6308b36a78d
2025-07-10 06:19:05 +10:00
Darren Tucker
c971f3d93e Add include for gssapi definitions.
Patch from dbelyavs at redhat.com via bz#3846.
2025-07-05 20:52:02 +10:00
djm@openbsd.org
0cf38d7446 upstream: the messaging layer between sshd-session and sshd-auth had a
maximum message size of 256KB. Some people apparently have configurations
larger than this and would hit this limit.

Worse, there was no good logging that could help diagnose what was
going wrong.

So this bumps the maximum message size to 4MB and implements an early
check (usable via the sshd -t test mode) that will report it to the
user where it is hopefully more visible.

bz3808, reported by Dmitry Belyavskiy, ok dtucker@

OpenBSD-Commit-ID: 69c303fb68cbd1a4735936835d67a71e7b57f63b
2025-07-04 17:50:09 +10:00
dtucker@openbsd.org
3de011ef7a upstream: Plug leak of startup_pollfd in debug and child paths.
Coverity CID 405024, ok djm@

OpenBSD-Commit-ID: db46047229253e9c4470c8bbf5f82706ac021377
2025-05-24 17:23:16 +10:00
djm@openbsd.org
a32d28d792 upstream: finally remove DSA signature support from OpenSSH.
feedback/ok tb@, ok deraadt@

OpenBSD-Commit-ID: bfe6ee73c1b676c81a2901030c791f8ec888228f
2025-05-07 14:20:14 +10:00
dtucker@openbsd.org
000c3d14e9 upstream: Include time.h for time().
Fixes warning on some platforms when building without openssl.

OpenBSD-Commit-ID: 04ca29b8eaae1860c7adde3e770baa1866e30a54
2025-04-07 21:12:21 +10:00
djm@openbsd.org
d47ef958b8 upstream: remove assumption that the sshd_config and any configs
included from it can fit in a (possibly enlarged) socket buffer, by having
the sshd listener mainloop actively manage sending the configuration to the
sshd-session subprocess.

work by markus@ w/ a little feedback from me;
ok me and committing on his behalf

OpenBSD-Commit-ID: 8f54451483f64951853074adb76bc4f838eaf3ae
2025-03-13 10:40:29 +11:00
djm@openbsd.org
aa1409e7a0 upstream: include arguments the command was invoked with, and
operating system name, version and architecture in startup debugging output;
ok dtucker

OpenBSD-Commit-ID: 2a509d319aaf31a6bf9998e1842832883fbc3edd
2025-02-11 10:30:30 +11:00
djm@openbsd.org
bbc9c18e84 upstream: replace bespoke logging of MaxSessions enforcement with
new ratelimited logging infrastructure.

Add ratelimits to logging of connections dropped by PerSourcePenalties

ok dtucker

OpenBSD-Commit-ID: f22fe7c39607e4361aadf95e33773ffd68c59489
2024-12-07 21:23:54 +11:00
djm@openbsd.org
6072e4c938 upstream: Split per-connection sshd-session binary
This splits the user authentication code from the sshd-session
binary into a separate sshd-auth binary. This will be executed by
sshd-session to complete the user authentication phase of the
protocol only.

Splitting this code into a separate binary ensures that the crucial
pre-authentication attack surface has an entirely disjoint address
space from the code used for the rest of the connection. It also
yields a small runtime memory saving as the authentication code will
be unloaded after thhe authentication phase completes.

Joint work with markus@ feedback deraadt@

Tested in snaps since last week

OpenBSD-Commit-ID: 9c3b2087ae08626ec31b4177b023db600e986d9c
2024-10-14 14:01:37 +11:00
djm@openbsd.org
7875975136 upstream: Add a "refuseconnection" penalty class to sshd_config
PerSourcePenalties

This allows penalising connection sources that have had connections
dropped by the RefuseConnection option. ok markus@

OpenBSD-Commit-ID: 3c8443c427470bb3eac1880aa075cb4864463cb6
2024-09-15 11:23:10 +10:00
djm@openbsd.org
c21c3a2419 upstream: Relax absolute path requirement back to what it was prior to
OpenSSH 9.8, which incorrectly required that sshd was started with an
absolute path in inetd mode. bz3717, patch from Colin Wilson

OpenBSD-Commit-ID: 25c57f22764897242d942853f8cccc5e991ea058
2024-09-12 10:37:34 +10:00
djm@openbsd.org
171427261d upstream: fix swapping of source and destination addresses in some sshd
log messages

OpenBSD-Commit-ID: 24d4cbb86325275df1f037545aa3b91456e52d25
2024-08-17 18:16:53 +10:00
djm@openbsd.org
c8cfe258ce upstream: delete obsolete comment
OpenBSD-Commit-ID: 5fb04f298ed155053f3fbfdf0c6fe7cdf84bbfa2
2024-06-28 09:07:27 +10:00
djm@openbsd.org
12b6cc09ce upstream: move child process waitpid() loop out of SIGCHLD handler;
ok deraadt

OpenBSD-Commit-ID: 65815a39564e431414aed7c5ace8076f4e9ca741
2024-06-28 08:36:15 +10:00
djm@openbsd.org
c0cb3b8c83 upstream: disable stderr redirection before closing fds
OpenBSD-Commit-ID: d42cb895ee4542098050367fc35321c9303f003a
2024-06-07 05:52:50 +10:00
djm@openbsd.org
81c1099d22 upstream: Add a facility to sshd(8) to penalise particular
problematic client behaviours, controlled by two new sshd_config(5) options:
PerSourcePenalties and PerSourcePenaltyExemptList.

When PerSourcePenalties are enabled, sshd(8) will monitor the exit
status of its child pre-auth session processes. Through the exit
status, it can observe situations where the session did not
authenticate as expected. These conditions include when the client
repeatedly attempted authentication unsucessfully (possibly indicating
an attack against one or more accounts, e.g. password guessing), or
when client behaviour caused sshd to crash (possibly indicating
attempts to exploit sshd).

When such a condition is observed, sshd will record a penalty of some
duration (e.g. 30 seconds) against the client's address. If this time
is above a minimum threshold specified by the PerSourcePenalties, then
connections from the client address will be refused (along with any
others in the same PerSourceNetBlockSize CIDR range).

Repeated offenses by the same client address will accrue greater
penalties, up to a configurable maximum. A PerSourcePenaltyExemptList
option allows certain address ranges to be exempt from all penalties.

We hope these options will make it significantly more difficult for
attackers to find accounts with weak/guessable passwords or exploit
bugs in sshd(8) itself.

PerSourcePenalties is off by default, but we expect to enable it
automatically in the near future.

much feedback markus@ and others, ok markus@

OpenBSD-Commit-ID: 89ded70eccb2b4926ef0366a4d58a693de366cca
2024-06-07 03:35:40 +10:00
Damien Miller
916b0b6174 whitespace 2024-06-07 03:31:02 +10:00
djm@openbsd.org
8785491123 upstream: be really strict with fds reserved for communication with the
separate sshd-session process - reserve them early and fatal if we can't
dup2(2) them later. The pre-split fallback to re-reading the configuration
files is not possible, so sshd-session absolutely requires the fd the
configuration is passed over to be in order.

ok deraadt@

OpenBSD-Commit-ID: 308a98ef3c8a6665ebf92c7c9a0fc9600ccd7065
2024-06-01 17:05:09 +10:00
Damien Miller
94b4866cb1 rename need_privsep to need_chroot
privsep is mandatory, chroot is optional (disabled when running
sshd as non-root)
2024-05-31 19:11:14 +10:00
djm@openbsd.org
b21d271f65 upstream: warn when -r (deprecated option to disable re-exec) is
passed

OpenBSD-Commit-ID: 73145ef5150edbe3ce7889f0844ed8fa6155f551
2024-05-31 19:04:12 +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
Damien Miller
08f579231c notify systemd on listen and reload
Standalone implementation that does not depend on libsystemd.
With assistance from Luca Boccassi, and feedback/testing from Colin
Watson. bz2641
2024-04-03 14:40:32 +11:00
djm@openbsd.org
a72833d007 upstream: remove ext-info-* in the kex.c code, not in callers;
with/ok markus@

OpenBSD-Commit-ID: c06fe2d3a0605c517ff7d65e38ec7b2d1b0b2799
2024-01-08 13:26:43 +11:00
djm@openbsd.org
a7ed931cae upstream: add "ext-info-in-auth@openssh.com" extension
This adds another transport protocol extension to allow a sshd to send
SSH2_MSG_EXT_INFO during user authentication, after the server has
learned the username that is being logged in to.

This lets sshd to update the acceptable signature algoritms for public
key authentication, and allows these to be varied via sshd_config(5)
"Match" directives, which are evaluated after the server learns the
username being authenticated.

Full details in the PROTOCOL file

OpenBSD-Commit-ID: 1de7da7f2b6c32a46043d75fcd49b0cbb7db7779
2023-12-19 01:51:46 +11:00
Darren Tucker
3c6ab63b38 Include Portable version in sshd version string.
bz#3608, ok djm@
2023-08-25 14:48:02 +10: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
9641753e0f upstream: Refactor creation of KEX proposal.
This adds kex_proposal_populate_entries (and corresponding free) which
populates the KEX proposal array with dynamically allocated strings.
This replaces the previous mix of static and dynamic that has been the
source of previous leaks and bugs.  Remove unused compat functions.
With & ok djm@.

OpenBSD-Commit-ID: f2f99da4aae2233cb18bf9c749320c5e040a9c7b
2023-03-06 23:31:52 +11:00
dtucker@openbsd.org
93291bd723 upstream: Check return values of dup2. Spotted by Coverity, ok djm@
OpenBSD-Commit-ID: 19fb1b53072826d00c67df677731d2f6c1dd602b
2023-03-03 14:49:14 +11:00
djm@openbsd.org
18938d11a9 upstream: add a sshd -G option that parses and prints the
effective configuration without attempting to load private keys and perform
other checks. This allows usage of the option before keys have been
generated.

bz3460 feedback/ok dtucker@

OpenBSD-Commit-ID: 774504f629023fc25a559ab1d95401adb3a7fb29
2023-02-10 16:12:42 +11:00
millert@openbsd.org
7d17ea151c upstream: Add a -V (version) option to sshd like the ssh client
has. OK markus@ deraadt@

OpenBSD-Commit-ID: abe990ec3e636fb040132aab8cbbede98f0c413e
2023-01-18 13:21:00 +11:00
djm@openbsd.org
2d1ff2b943 upstream: Implement channel inactivity timeouts
This adds a sshd_config ChannelTimeouts directive that allows channels that
have not seen traffic in a configurable interval to be automatically closed.
Different timeouts may be applied to session, X11, agent and TCP forwarding
channels.

Note: this only affects channels over an opened SSH connection and not
the connection itself. Most clients close the connection when their channels
go away, with a notable exception being ssh(1) in multiplexing mode.

ok markus dtucker

OpenBSD-Commit-ID: ae8bba3ed9d9f95ff2e2dc8dcadfa36b48e6c0b8
2023-01-06 16:23:16 +11:00
djm@openbsd.org
93f2ce8c05 upstream: Clear signal mask early in main(); sshd may have been
started with one or more signals masked (sigprocmask(2) is not cleared
on fork/exec) and this could interfere with various things, e.g. the
login grace timer.

Execution environments that fail to clear the signal mask before running
sshd are clearly broken, but apparently they do exist.

Reported by Sreedhar Balasubramanian; ok dtucker@

OpenBSD-Commit-ID: 77078c0b1c53c780269fc0c416f121d05e3010ae
2023-01-03 17:53:05 +11:00
cheloha@openbsd.org
b85c3581c1 upstream: remove '?' from getopt(3) loops
userspace: remove vestigial '?' cases from top-level getopt(3) loops

getopt(3) returns '?' when it encounters a flag not present in the in
the optstring or if a flag is missing its option argument.  We can
handle this case with the "default" failure case with no loss of
legibility.  Hence, remove all the redundant "case '?':" lines.

Prompted by dlg@.  With help from dlg@ and millert@.

Link: https://marc.info/?l=openbsd-tech&m=167011979726449&w=2

ok naddy@ millert@ dlg@

OpenBSD-Commit-ID: b2f89346538ce4f5b33ab8011a23e0626a67e66e
2022-12-09 11:36:12 +11:00
Darren Tucker
5372db7e79 Remove seed passing over reexec.
This was added for the benefit of platforms using ssh-rand-helper to
prevent a delay on each connection as sshd reseeded itself.

ssh-random-helper is long gone, and since the re-exec happens before the
chroot the re-execed sshd can reseed itself normally. ok djm@
2022-11-10 12:44:51 +11:00
Darren Tucker
cf1a9852d7 Defer seed_rng until after closefrom call.
seed_rng will initialize OpenSSL, and some engine providers (eg Intel's
QAT) will open descriptors for their own use.  bz#3483, patch from
joel.d.schuetze at intel.com, ok djm@
2022-11-09 09:23:47 +11:00
djm@openbsd.org
2519a7077a upstream: refactor sshkey_private_serialize_opt()
feedback/ok markus@

OpenBSD-Commit-ID: 61e0fe989897901294efe7c3b6d670cefaf44cbd
2022-10-28 12:47:01 +11:00
djm@openbsd.org
1875042c52 upstream: Add RequiredRSASize for sshd(8); RSA keys that fall
beneath this limit will be ignored for user and host-based authentication.

Feedback deraadt@ ok markus@

OpenBSD-Commit-ID: 187931dfc19d51873df5930a04f2d972adf1f7f1
2022-09-17 20:39:02 +10:00
dtucker@openbsd.org
322964f8f2 upstream: Remove leftover line.
Remove extra line leftover from merge conflict. ok djm@

OpenBSD-Commit-ID: 460e2290875d7ae64971a7e669c244b1d1c0ae2e
2022-07-01 16:00:17 +10:00
dtucker@openbsd.org
6c31ba10e9 upstream: Don't leak the strings allocated by order_hostkeyalgs()
and list_hostkey_types() that are passed to compat_pkalg_proposal(). Part of
github PR#324 from ZoltanFridrich, ok djm@

This is a roll-forward of the previous rollback now that the required
changes in compat.c have been done.

OpenBSD-Commit-ID: c7cd93730b3b9f53cdad3ae32462922834ef73eb
2022-07-01 13:41:16 +10:00
dtucker@openbsd.org
2369a28101 upstream: Roll back previous KEX changes as they aren't safe until
compat_pkalg_proposal and friends always allocate their returned strings.
Reported by Qualys.

OpenBSD-Commit-ID: 1c7a88a0d5033f42f88ab9bec58ef1cf72c81ad0
2022-06-28 07:43:15 +10:00
dtucker@openbsd.org
646686136c upstream: Don't leak the strings allocated by order_hostkeyalgs()
and list_hostkey_types() that are passed to compat_pkalg_proposal(). Part of
github PR#324 from ZoltanFridrich, ok djm@

OpenBSD-Commit-ID: b2f6e5f60f2bba293b831654328a8a0035ef4a1b
2022-06-28 07:43:15 +10:00