summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--deattack.c26
-rw-r--r--deattack.h3
-rw-r--r--packet.c15
4 files changed, 45 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index c61fd9343..3c00fec48 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
120060916
2 - OpenBSD CVS Sync
3 - djm@cvs.openbsd.org 2006/09/16 19:53:37
4 [deattack.c deattack.h packet.c]
5 limit maximum work performed by the CRC compensation attack detector,
6 problem reported by Tavis Ormandy, Google Security Team;
7 ok markus@ deraadt@
8
120060912 920060912
2 - (djm) [Makefile.in buildpkg.sh.in configure.ac openssh.xml.in] 10 - (djm) [Makefile.in buildpkg.sh.in configure.ac openssh.xml.in]
3 Support SMF in Solaris Packages if enabled by configure. Patch from 11 Support SMF in Solaris Packages if enabled by configure. Patch from
@@ -5433,4 +5441,4 @@
5433 - (djm) Trim deprecated options from INSTALL. Mention UsePAM 5441 - (djm) Trim deprecated options from INSTALL. Mention UsePAM
5434 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu 5442 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
5435 5443
5436$Id: ChangeLog,v 1.4544 2006/09/12 11:54:10 djm Exp $ 5444$Id: ChangeLog,v 1.4545 2006/09/16 20:08:53 djm Exp $
diff --git a/deattack.c b/deattack.c
index b4fed7f85..1b37e4dab 100644
--- a/deattack.c
+++ b/deattack.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: deattack.c,v 1.29 2006/08/03 03:34:42 deraadt Exp $ */ 1/* $OpenBSD: deattack.c,v 1.30 2006/09/16 19:53:37 djm Exp $ */
2/* 2/*
3 * Cryptographic attack detector for ssh - source code 3 * Cryptographic attack detector for ssh - source code
4 * 4 *
@@ -32,6 +32,24 @@
32#include "crc32.h" 32#include "crc32.h"
33#include "misc.h" 33#include "misc.h"
34 34
35/*
36 * CRC attack detection has a worst-case behaviour that is O(N^3) over
37 * the number of identical blocks in a packet. This behaviour can be
38 * exploited to create a limited denial of service attack.
39 *
40 * However, because we are dealing with encrypted data, identical
41 * blocks should only occur every 2^35 maximally-sized packets or so.
42 * Consequently, we can detect this DoS by looking for identical blocks
43 * in a packet.
44 *
45 * The parameter below determines how many identical blocks we will
46 * accept in a single packet, trading off between attack detection and
47 * likelihood of terminating a legitimate connection. A value of 32
48 * corresponds to an average of 2^40 messages before an attack is
49 * misdetected
50 */
51#define MAX_IDENTICAL 32
52
35/* SSH Constants */ 53/* SSH Constants */
36#define SSH_MAXBLOCKS (32 * 1024) 54#define SSH_MAXBLOCKS (32 * 1024)
37#define SSH_BLOCKSIZE (8) 55#define SSH_BLOCKSIZE (8)
@@ -87,7 +105,7 @@ detect_attack(u_char *buf, u_int32_t len)
87 static u_int16_t *h = (u_int16_t *) NULL; 105 static u_int16_t *h = (u_int16_t *) NULL;
88 static u_int32_t n = HASH_MINSIZE / HASH_ENTRYSIZE; 106 static u_int32_t n = HASH_MINSIZE / HASH_ENTRYSIZE;
89 u_int32_t i, j; 107 u_int32_t i, j;
90 u_int32_t l; 108 u_int32_t l, same;
91 u_char *c; 109 u_char *c;
92 u_char *d; 110 u_char *d;
93 111
@@ -124,10 +142,12 @@ detect_attack(u_char *buf, u_int32_t len)
124 } 142 }
125 memset(h, HASH_UNUSEDCHAR, n * HASH_ENTRYSIZE); 143 memset(h, HASH_UNUSEDCHAR, n * HASH_ENTRYSIZE);
126 144
127 for (c = buf, j = 0; c < (buf + len); c += SSH_BLOCKSIZE, j++) { 145 for (c = buf, same = j = 0; c < (buf + len); c += SSH_BLOCKSIZE, j++) {
128 for (i = HASH(c) & (n - 1); h[i] != HASH_UNUSED; 146 for (i = HASH(c) & (n - 1); h[i] != HASH_UNUSED;
129 i = (i + 1) & (n - 1)) { 147 i = (i + 1) & (n - 1)) {
130 if (!CMP(c, buf + h[i] * SSH_BLOCKSIZE)) { 148 if (!CMP(c, buf + h[i] * SSH_BLOCKSIZE)) {
149 if (++same > MAX_IDENTICAL)
150 return (DEATTACK_DOS_DETECTED);
131 if (check_crc(c, buf, len)) 151 if (check_crc(c, buf, len))
132 return (DEATTACK_DETECTED); 152 return (DEATTACK_DETECTED);
133 else 153 else
diff --git a/deattack.h b/deattack.h
index 627598104..0316fb285 100644
--- a/deattack.h
+++ b/deattack.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: deattack.h,v 1.9 2006/03/25 22:22:43 djm Exp $ */ 1/* $OpenBSD: deattack.h,v 1.10 2006/09/16 19:53:37 djm Exp $ */
2 2
3/* 3/*
4 * Cryptographic attack detector for ssh - Header file 4 * Cryptographic attack detector for ssh - Header file
@@ -25,6 +25,7 @@
25/* Return codes */ 25/* Return codes */
26#define DEATTACK_OK 0 26#define DEATTACK_OK 0
27#define DEATTACK_DETECTED 1 27#define DEATTACK_DETECTED 1
28#define DEATTACK_DOS_DETECTED 2
28 29
29int detect_attack(u_char *, u_int32_t); 30int detect_attack(u_char *, u_int32_t);
30#endif 31#endif
diff --git a/packet.c b/packet.c
index a4cb3324e..da843b2c2 100644
--- a/packet.c
+++ b/packet.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: packet.c,v 1.143 2006/08/05 08:34:04 dtucker Exp $ */ 1/* $OpenBSD: packet.c,v 1.144 2006/09/16 19:53:37 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1000,9 +1000,16 @@ packet_read_poll1(void)
1000 * (C)1998 CORE-SDI, Buenos Aires Argentina 1000 * (C)1998 CORE-SDI, Buenos Aires Argentina
1001 * Ariel Futoransky(futo@core-sdi.com) 1001 * Ariel Futoransky(futo@core-sdi.com)
1002 */ 1002 */
1003 if (!receive_context.plaintext && 1003 if (!receive_context.plaintext) {
1004 detect_attack(buffer_ptr(&input), padded_len) == DEATTACK_DETECTED) 1004 switch (detect_attack(buffer_ptr(&input), padded_len)) {
1005 packet_disconnect("crc32 compensation attack: network attack detected"); 1005 case DEATTACK_DETECTED:
1006 packet_disconnect("crc32 compensation attack: "
1007 "network attack detected");
1008 case DEATTACK_DOS_DETECTED:
1009 packet_disconnect("deattack denial of "
1010 "service detected");
1011 }
1012 }
1006 1013
1007 /* Decrypt data to incoming_packet. */ 1014 /* Decrypt data to incoming_packet. */
1008 buffer_clear(&incoming_packet); 1015 buffer_clear(&incoming_packet);