summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Grishenko <themiron@users.noreply.github.com>2020-06-15 18:22:18 +0500
committerVladislav Grishenko <themiron@users.noreply.github.com>2020-06-15 18:22:18 +0500
commit55062df703975bbbf2256fd21e49d33ae953edb9 (patch)
treed139d88ae80f2b928f77e71d80218aa21143abc8
parent632776f012f37034f295e2b8da22f77e3724ca38 (diff)
downloaddropbear-55062df703975bbbf2256fd21e49d33ae953edb9.tar.gz
Disallow leading lines before the ident for server (#102)
Per RFC4253 4.2 clients must be able to process other lines of data before the version string, server behavior is not defined neither with MUST/SHOULD nor with MAY. If server process up to 50 lines too - it may cause too long hanging session with invalid/evil client that consume host resources and potentially may lead to DDoS on poor embedded boxes. Let's require first line from client to be version string and fail early if it's not - matches both RFC and real OpenSSH behavior.
-rw-r--r--common-session.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/common-session.c b/common-session.c
index fc0f9a0..7531563 100644
--- a/common-session.c
+++ b/common-session.c
@@ -370,8 +370,11 @@ static void read_session_identification() {
int len = 0;
char done = 0;
int i;
- /* If they send more than 50 lines, something is wrong */
- for (i = 0; i < 50; i++) {
+
+ /* Servers may send other lines of data before sending the
+ * version string, client must be able to process such lines.
+ * If they send more than 50 lines, something is wrong */
+ for (i = IS_DROPBEAR_CLIENT ? 50 : 1; i > 0; i--) {
len = ident_readln(ses.sock_in, linebuf, sizeof(linebuf));
if (len < 0 && errno != EINTR) {