forked from rapier1/hpn-ssh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upstream: add a "Match invalid-user" predicate to sshd_config Match
options. This allows writing Match conditions that trigger for invalid username. E.g. PerSourcePenalties refuseconnection:90s Match invalid-user RefuseConnection yes Will effectively penalise bots try to guess passwords for bogus accounts, at the cost of implicitly revealing which accounts are invalid. feedback markus@ OpenBSD-Commit-ID: 93d3a46ca04bbd9d84a94d1e1d9d3a21073fbb07
- Loading branch information
Showing
4 changed files
with
25 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: servconf.c,v 1.416 2024/09/15 01:11:26 djm Exp $ */ | ||
/* $OpenBSD: servconf.c,v 1.417 2024/09/15 01:18:26 djm Exp $ */ | ||
/* | ||
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland | ||
* All rights reserved | ||
|
@@ -1038,9 +1038,10 @@ match_cfg_line(const char *full_line, int *acp, char ***avp, | |
if (ci == NULL) | ||
debug3("checking syntax for 'Match %s'", full_line); | ||
else { | ||
debug3("checking match for '%s' user %s host %s addr %s " | ||
debug3("checking match for '%s' user %s%s host %s addr %s " | ||
"laddr %s lport %d", full_line, | ||
ci->user ? ci->user : "(null)", | ||
ci->user_invalid ? " (invalid)" : "", | ||
ci->host ? ci->host : "(null)", | ||
ci->address ? ci->address : "(null)", | ||
ci->laddress ? ci->laddress : "(null)", ci->lport); | ||
|
@@ -1067,6 +1068,16 @@ match_cfg_line(const char *full_line, int *acp, char ***avp, | |
argv_consume(acp); /* consume remaining args */ | ||
return 1; | ||
} | ||
/* Criterion "invalid-user" also has no argument */ | ||
if (strcasecmp(attrib, "invalid-user") == 0) { | ||
if (ci == NULL) | ||
continue; | ||
if (ci->user_invalid == 0) | ||
result = 0; | ||
else | ||
debug("matched invalid-user at line %d", line); | ||
continue; | ||
} | ||
/* All other criteria require an argument */ | ||
if ((arg = argv_next(acp, avp)) == NULL || | ||
*arg == '\0' || *arg == '#') { | ||
|
@@ -2784,6 +2795,8 @@ int parse_server_match_testspec(struct connection_info *ci, char *spec) | |
" specification %s\n", p+6, p); | ||
return -1; | ||
} | ||
} else if (strcmp(p, "invalid-user") == 0) { | ||
ci->user_invalid = 1; | ||
} else { | ||
fprintf(stderr, "Invalid test mode specification %s\n", | ||
p); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: servconf.h,v 1.167 2024/09/15 01:11:26 djm Exp $ */ | ||
/* $OpenBSD: servconf.h,v 1.168 2024/09/15 01:18:26 djm Exp $ */ | ||
|
||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
|
@@ -256,6 +256,7 @@ typedef struct { | |
/* Information about the incoming connection as used by Match */ | ||
struct connection_info { | ||
const char *user; | ||
int user_invalid; | ||
const char *host; /* possibly resolved hostname */ | ||
const char *address; /* remote address */ | ||
const char *laddress; /* local address */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters