diff options
author | djm@openbsd.org <djm@openbsd.org> | 2024-06-06 19:15:25 +0200 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2024-06-06 19:35:40 +0200 |
commit | 81c1099d22b81ebfd20a334ce986c4f753b0db29 (patch) | |
tree | 5cabf3d270bc3b2a48cef2b631d695d63248fad4 /sshd-session.c | |
parent | whitespace (diff) | |
download | openssh-81c1099d22b81ebfd20a334ce986c4f753b0db29.tar.xz openssh-81c1099d22b81ebfd20a334ce986c4f753b0db29.zip |
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
Diffstat (limited to 'sshd-session.c')
-rw-r--r-- | sshd-session.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sshd-session.c b/sshd-session.c index 53478f004..02e469e05 100644 --- a/sshd-session.c +++ b/sshd-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshd-session.c,v 1.2 2024/05/17 02:39:11 jsg Exp $ */ +/* $OpenBSD: sshd-session.c,v 1.3 2024/06/06 17:15:25 djm Exp $ */ /* * SSH2 implementation: * Privilege Separation: @@ -209,11 +209,7 @@ grace_alarm_handler(int sig) ssh_signal(SIGTERM, SIG_IGN); kill(0, SIGTERM); } - - /* Log error and exit. */ - sigdie("Timeout before authentication for %s port %d", - ssh_remote_ipaddr(the_active_state), - ssh_remote_port(the_active_state)); + _exit(EXIT_LOGIN_GRACE); } /* Destroy the host and server keys. They will no longer be needed. */ @@ -1303,6 +1299,8 @@ main(int ac, char **av) ssh_signal(SIGALRM, SIG_DFL); authctxt->authenticated = 1; if (startup_pipe != -1) { + /* signal listener that authentication completed successfully */ + (void)atomicio(vwrite, startup_pipe, "\001", 1); close(startup_pipe); startup_pipe = -1; } @@ -1451,6 +1449,8 @@ do_ssh2_kex(struct ssh *ssh) void cleanup_exit(int i) { + extern int auth_attempted; /* monitor.c */ + if (the_active_state != NULL && the_authctxt != NULL) { do_cleanup(the_active_state, the_authctxt); if (privsep_is_preauth && @@ -1463,6 +1463,9 @@ cleanup_exit(int i) } } } + /* Override default fatal exit value when auth was attempted */ + if (i == 255 && auth_attempted) + _exit(EXIT_AUTH_ATTEMPTED); #ifdef SSH_AUDIT_EVENTS /* done after do_cleanup so it can cancel the PAM auth 'thread' */ if (the_active_state != NULL && mm_is_monitor()) |