summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordtucker <dtucker@openbsd.org>2016-07-21 01:39:35 +0000
committerdtucker <dtucker@openbsd.org>2016-07-21 01:39:35 +0000
commit66ea199ae4ce8e8b637f464d8bfcce1915f4ac24 (patch)
tree21c7c2fc9fc9f45cedd3b533bd1a7f0918b7f804
parentfix typos in comments (diff)
downloadwireguard-openbsd-66ea199ae4ce8e8b637f464d8bfcce1915f4ac24.tar.xz
wireguard-openbsd-66ea199ae4ce8e8b637f464d8bfcce1915f4ac24.zip
Skip passwords longer than 1k in length so clients can't easily DoS sshd
by sending very long passwords, causing it to spend CPU hashing them. feedback djm@, ok markus@. Brought to our attention by tomas.kuthan at oracle.com, shilei-c at 360.cn and coredump at autistici.org
-rw-r--r--usr.bin/ssh/auth-passwd.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/usr.bin/ssh/auth-passwd.c b/usr.bin/ssh/auth-passwd.c
index 1346f8cdfee..69f49bf2648 100644
--- a/usr.bin/ssh/auth-passwd.c
+++ b/usr.bin/ssh/auth-passwd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auth-passwd.c,v 1.44 2014/07/15 15:54:14 millert Exp $ */
+/* $OpenBSD: auth-passwd.c,v 1.45 2016/07/21 01:39:35 dtucker Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -63,6 +63,8 @@ extern login_cap_t *lc;
#define DAY (24L * 60 * 60) /* 1 day in seconds */
#define TWO_WEEKS (2L * 7 * DAY) /* 2 weeks in seconds */
+#define MAX_PASSWORD_LEN 1024
+
static void
disable_forwarding(void)
{
@@ -81,6 +83,9 @@ auth_password(Authctxt *authctxt, const char *password)
struct passwd * pw = authctxt->pw;
int ok = authctxt->valid;
+ if (strlen(password) > MAX_PASSWORD_LEN)
+ return 0;
+
if (pw->pw_uid == 0 && options.permit_root_login != PERMIT_YES)
ok = 0;
if (*password == '\0' && options.permit_empty_passwd == 0)