30th Jul 2002
COMANDO
OpenSSL multiples vulnerabilidades remotas
SISTEMAS AFECTADOS
OpenSSL 0.9.6d o anterior
OpenSSL 0.9.7-beta2 o anterior
PROBLEMA
En el OpenSSL Aviso de Seguridad, Ben Laurie expone 5
vulnerabilidades remotas. Pekeño recordatorio: ssl es usado en
servidores de html, servidores de correo TLS, SSH, etc...
esto consiste en 2 avisos independientes
Aviso 1
==========
A.L. Digital Ltd y The Bunker (http://www.thebunker.net/) conducen
a una revision de seguridad de OpenSSL, bajo el DARPA program CHATS.
Vulnerabilidades
---------------
los 4 de estsos son potencial y remotamente exploitables.
1. La llave del cliente maestro en SSL2 podria ser de gran tamaño
y sobrar un almacenador. Esta vulnerabilidad fue descubierta
independientemente por los consultores Neohapsis (http://www.neohapsis.com/)
quienes han demostrado que la vulnerabilidad es exploitable. El codigo NO esta
disponible en este momento.
2. La identificacion de la sesion provista a un cliente en SSL3 podria
ser de gran tamañoo y sobrar un almacenador.
3. La llave del cliente maestro en SSL2 podria ser de gran tamaño
sobre un almacenador. Este problema solo afecta OpenSSL
0.9.7 anterior 0.9.7-beta3 con Kerberos habilitado.
4. Varios almacenadores para representaciones ASCII de numeros
enteron estaban demasiado pekeños en plataformas de 64 bit.
varios desbordamientos potenciales del almacenador no conocidos
para ser exploitables, han tenido aserciones agregadas pa defenderse
contra ellas
kien es afectado?
----------------
todos los que usen OpenSSL 0.9.6d o anterior, o 0.9.7-beta2 o anterior o
snapshots actuales del desarrollo de 0.9.7 pa proveer SSL o TLS es
vulnerable, cualkiera sea cliente o servidor. 0.9.6d servidores en sistemas
32-bit con SSL 2.0 desabilitado no son vulnerables.
SSLeay probablemente tambien es afectado.
Exploits conocidos
--------------
no hay exploits conocidos pa esta vulnerabilidad. Como visto arriba,
Neohapsis ha demostrado que un exploit es posible, pero no hecho.
Aviso 2
==========
Vulnerabilidades
---------------
el programa de analisis ASN1 puede ser confundido distribyendolo
de cierta codificacion invalida.
kien es afectado?
----------------
Cualkier programa OpenSSL que use libreria ASN1 pa analizar
datos inseguros. Incluye tidas las aplicaciones SSL o TLS, esos
usando S/MIME (PKCS#7) o turinias de generacion de certificado
SOLUCION
Av 1
=====
Recomendaciones
---------------
Aplika el parche a OpenSSL 0.9.6d, o mejor al OpenSSL
0.9.6e. recompila todas las aplikaciones OpenSSL pa proveer SSL o TLS.
Un parche pa 0.9.7 esta disponible desde la pagina de OpenSSL
(http://www.openssl.org/).
servidores pueden deshabilitar SSL2, alternativamente deshabilita todas
las aplicaciones en SSL o TLS hasta que los parches sean aplikados.
Usiarios de 0.9.7 pre-realizado con Kerberos habilitados, tendran que
deshabilitarlos.
cliente deberia ser deshabilitado hasta ke los parches sean aplicados.
Av 2
=====
Recomendaciones
---------------
Aplika el parche a OpenSSL, o mejor al OpenSSL 0.9.6e. recompila
todas las aplikaciones usando OpenSSL.
Usuarios del 0.9.7 pre-realizado deberian aplicar el parche a
0.9.7-beta3 o a una version mas + reciente. recompila todo usando
OpenSSL
Parches
=======
Index: CHANGES
===================================================================
archivo RCS: /e/openssl/cvs/openssl/CHANGES,v
retrieving revision 1.618.2.158
diff -u -r1.618.2.158 CHANGES
--- CHANGES 2002/05/09 22:40:31 1.618.2.158
+++ CHANGES 2002/07/30 09:14:15
@@ -2,6 +2,35 @@
OpenSSL CHANGES
_______________
+ Cambios en el parche de seguridad
+
+ *) agrega varios disponibles a asn1_get_length() pa rechazar
+ la longitud de bytes ASN1 si es ke excede sizeof(long), aparecera
+ negativo, o el contenido de longitus excede la longitus del almacenador
+ provisto. (CAN-2002-0659)
*) arregla crypto/asn1/a_sign.c asi ke estos 'parametros' son omitidos (no
el Index: crypto/cryptlib.c
===================================================================
archivo RCS: /e/openssl/cvs/openssl/crypto/cryptlib.c,v
recuperacion de la revision 1.20.2.4
diff -u -r1.20.2.4 cryptlib.c
--- crypto/cryptlib.c 2001/11/23 20:57:59 1.20.2.4
+++ crypto/cryptlib.c 2002/07/30 09:14:15
@@ -491,3 +491,11 @@
#endif
#endif
+
+void OpenSSLDie(const char *file,int line,const char *assertion)
+ {
+ fprintf(stderr,"%s(%d): OpenSSL internal error, assertion failed: %sn",
+ file,line,assertion);
+ abort();
+ }
+
Index: crypto/cryptlib.h
===================================================================
archivo RCS: /e/openssl/cvs/openssl/crypto/cryptlib.h,v
recuperacion de revision 1.8
diff -u -r1.8 cryptlib.h
--- crypto/cryptlib.h 2000/05/02 12:35:04 1.8
+++ crypto/cryptlib.h 2002/07/30 09:14:16
@@ -89,6 +89,14 @@
#define X509_CERT_DIR_EVP "SSL_CERT_DIR"
#define X509_CERT_FILE_EVP "SSL_CERT_FILE"
+/* tamaño de la representacion de secuencias */
+#define DECIMAL_SIZE(type) ((sizeof(type)*8+2)/3+1)
+#define HEX_SIZE(type) ((sizeof(type)*2)
+
+/* die if we have to */
+void OpenSSLDie(const char *file,int line,const char *assertion);
+#define die(e) ((e) ? (void)0 : OpenSSLDie(__FILE__, __LINE__, #e))
+
#ifdef __cplusplus
}
#endif
Index: crypto/asn1/asn1_lib.c
===================================================================
archivo RCS: /e/openssl/cvs/openssl/crypto/asn1/asn1_lib.c,v
recuperacion de revision 1.19.2.1
diff -u -r1.19.2.1 asn1_lib.c
--- crypto/asn1/asn1_lib.c 2001/03/30 13:42:32 1.19.2.1
+++ crypto/asn1/asn1_lib.c 2002/07/30 09:14:17
@@ -124,15 +124,13 @@
(int)(omax+ *pp));
#endif
-#if 0
- if ((p+ *plength) > (omax+ *pp))
+ if (*plength > (omax - (*pp - p)))
{
ASN1err(ASN1_F_ASN1_GET_OBJECT,ASN1_R_TOO_LONG);
/* Setea esto si las cosas no son suficientemente largas
* los valores se fijan correctamente */
ret|=0x80;
}
-#endif
*pp=p;
return(ret|inf);
err:
@@ -159,6 +157,8 @@
i= *p&0x7f;
if (*(p++) & 0x80)
{
+ if (i > sizeof(long))
+ return 0;
if (max-- == 0) return(0);
while (i-- > 0)
{
@@ -170,6 +170,8 @@
else
ret=i;
}
+ if (ret < 0)
+ return 0;
*pp=p;
*rl=ret;
return(1);
@@ -407,7 +409,7 @@
void asn1_add_error(unsigned char *address, int offset)
{
- char buf1[16],buf2[16];
+ char buf1[DECIMAL_SIZE(address)+1],buf2[DECIMAL_SIZE(offset)+1];
sprintf(buf1,"%lu",(unsigned long)address);
sprintf(buf2,"%d",offset);
Index: crypto/conf/conf_def.c
===================================================================
archivo RCS: /e/openssl/cvs/openssl/crypto/conf/conf_def.c,v
recuperacion de revision 1.3
diff -u -r1.3 conf_def.c
--- crypto/conf/conf_def.c 2000/06/06 15:21:12 1.3
+++ crypto/conf/conf_def.c 2002/07/30 09:14:18
@@ -67,6 +67,7 @@
#include "conf_def.h"
#include <openssl/buffer.h>
#include <openssl/err.h>
+#include "cryptlib.h"
static char *eat_ws(CONF *conf, char *p);
static char *eat_alpha_numeric(CONF *conf, char *p);
@@ -180,12 +181,12 @@
static int def_load(CONF *conf, BIO *in, long *line)
{
#define BUFSIZE 512
- char btmp[16];
int bufnum=0,i,ii;
BUF_MEM *buff=NULL;
char *s,*p,*end;
int again,n;
long eline=0;
+ char btmp[DECIMAL_SIZE(eline)+1];
CONF_VALUE *v=NULL,*tv;
CONF_VALUE *sv=NULL;
char *section=NULL,*buf;
Index: crypto/objects/obj_dat.c
===================================================================
archivo RCS: /e/openssl/cvs/openssl/crypto/objects/obj_dat.c,v
recuperacion de revision 1.16.2.2
diff -u -r1.16.2.2 obj_dat.c
--- crypto/objects/obj_dat.c 2002/04/18 11:52:28 1.16.2.2
+++ crypto/objects/obj_dat.c 2002/07/30 09:14:19
@@ -428,7 +428,7 @@
unsigned long l;
unsigned char *p;
const char *s;
- char tbuf[32];
+ char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
if (buf_len <= 0) return(0);
Index: ssl/s2_clnt.c
===================================================================
archivo RCS: /e/openssl/cvs/openssl/ssl/s2_clnt.c,v
recuperacion de revision 1.27.2.4
diff -u -r1.27.2.4 s2_clnt.c
--- ssl/s2_clnt.c 2001/11/10 10:43:51 1.27.2.4
+++ ssl/s2_clnt.c 2002/07/30 09:14:25
@@ -116,6 +116,7 @@
#include <openssl/buffer.h>
#include <openssl/objects.h>
#include <openssl/evp.h>
+#include "cryptlib.h"
static SSL_METHOD *ssl2_get_client_method(int ver);
static int get_server_finished(SSL *s);
@@ -517,6 +518,7 @@
}
s->s2->conn_id_length=s->s2->tmp.conn_id_length;
+ die(s->s2->conn_id_length <= sizeof s->s2->conn_id);
memcpy(s->s2->conn_id,p,s->s2->tmp.conn_id_length);
return(1);
}
@@ -618,6 +620,7 @@
/* make key_arg data */
i=EVP_CIPHER_iv_length(c);
sess->key_arg_length=i;
+ die(i <= SSL_MAX_KEY_ARG_LENGTH);
if (i > 0) RAND_pseudo_bytes(sess->key_arg,i);
/* make a master key */
@@ -625,6 +628,7 @@
sess->master_key_length=i;
if (i > 0)
{
+ die(i <= sizeof sess->master_key);
if (RAND_bytes(sess->master_key,i) <= 0)
{
ssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR);
@@ -668,6 +672,7 @@
d+=enc;
karg=sess->key_arg_length;
s2n(karg,p); /* key arg size */
+ die(karg <= sizeof sess->key_arg);
memcpy(d,sess->key_arg,(unsigned int)karg);
d+=karg;
@@ -688,6 +693,7 @@
{
p=(unsigned char *)s->init_buf->data;
*(p++)=SSL2_MT_CLIENT_FINISHED;
+ die(s->s2->conn_id_length <= sizeof s->s2->conn_id);
memcpy(p,s->s2->conn_id,(unsigned int)s->s2->conn_id_length);
s->state=SSL2_ST_SEND_CLIENT_FINISHED_B;
@@ -944,6 +950,8 @@
{
if (!(s->options & SSL_OP_MICROSOFT_SESS_ID_BUG))
{
+ die(s->session->session_id_length
+ <= sizeof s->session->session_id);
if (memcmp(buf,s->session->session_id,
(unsigned int)s->session->session_id_length) != 0)
{
Index: ssl/s2_lib.c
===================================================================
archivo RCS: /e/openssl/cvs/openssl/ssl/s2_lib.c,v
recuperacion de revision 1.29.2.2
diff -u -r1.29.2.2 s2_lib.c
--- ssl/s2_lib.c 2000/12/26 12:06:47 1.29.2.2
+++ ssl/s2_lib.c 2002/07/30 09:14:25
@@ -62,6 +62,7 @@
#include <openssl/rsa.h>
#include <openssl/objects.h>
#include <openssl/md5.h>
+#include "cryptlib.h"
static long ssl2_default_timeout(void );
const char *ssl2_version_str="SSLv2" OPENSSL_VERSION_PTEXT;
@@ -425,10 +426,14 @@
#endif
km=s->s2->key_material;
+ die(s->s2->key_material_length <= sizeof s->s2->key_material);
for (i=0; i<s->s2->key_material_length; i+=MD5_DIGEST_LENGTH)
{
MD5_Init(&ctx);
+ die(s->session->master_key_length >= 0
+ && s->session->master_key_length
+ < sizeof s->session->master_key);
MD5_Update(&ctx,s->session->master_key,s->session->master_key_length);
MD5_Update(&ctx,&c,1);
c++;
@@ -463,6 +468,7 @@
/* state=s->rwstate;*/
error=s->error;
s->error=0;
+ die(error >= 0 && error <= 3);
i=ssl2_write(s,&(buf[3-error]),error);
/* if (i == error) s->rwstate=state; */
Index: ssl/s2_srvr.c
===================================================================
archivo RCS: /e/openssl/cvs/openssl/ssl/s2_srvr.c,v
recuperacion de revision 1.25.2.5
diff -u -r1.25.2.5 s2_srvr.c
--- ssl/s2_srvr.c 2001/11/14 21:19:47 1.25.2.5
+++ ssl/s2_srvr.c 2002/07/30 09:14:26
@@ -116,6 +116,7 @@
#include <openssl/rand.h>
#include <openssl/objects.h>
#include <openssl/evp.h>
+#include "cryptlib.h"
static SSL_METHOD *ssl2_get_server_method(int ver);
static int get_client_master_key(SSL *s);
@@ -417,11 +418,18 @@
n2s(p,i); s->s2->tmp.clear=i;
n2s(p,i); s->s2->tmp.enc=i;
n2s(p,i); s->session->key_arg_length=i;
+ if(s->session->key_arg_length > SSL_MAX_KEY_ARG_LENGTH)
+ {
+ SSLerr(SSL_F_GET_CLIENT_MASTER_KEY,
+ SSL_R_KEY_ARG_TOO_LONG);
+ return -1;
+ }
s->state=SSL2_ST_GET_CLIENT_MASTER_KEY_B;
}
/* SSL2_ST_GET_CLIENT_MASTER_KEY_B */
p=(unsigned char *)s->init_buf->data;
+ die(s->init_buf->length >= SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER);
keya=s->session->key_arg_length;
len = 10 + (unsigned long)s->s2->tmp.clear + (unsigned long)s->s2->tmp.enc + (unsigned long)keya;
if (len > SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER)
@@ -502,6 +510,7 @@
#endif
if (is_export) i+=s->s2->tmp.clear;
+ die(i <= SSL_MAX_MASTER_KEY_LENGTH);
s->session->master_key_length=i;
memcpy(s->session->master_key,p,(unsigned int)i);
return(1);
@@ -649,6 +658,7 @@
p+=s->s2->tmp.session_id_length;
/* challenge */
+ die(s->s2->challenge_length <= sizeof s->s2->challenge);
memcpy(s->s2->challenge,p,(unsigned int)s->s2->challenge_length);
return(1);
mem_err:
@@ -800,6 +810,7 @@
}
/* SSL2_ST_GET_CLIENT_FINISHED_B */
+ die(s->s2->conn_id_length <= sizeof s->s2->conn_id);
len = 1 + (unsigned long)s->s2->conn_id_length;
n = (int)len - s->init_num;
i = ssl2_read(s,(char *)&(p[s->init_num]),n);
@@ -825,6 +836,7 @@
{
p=(unsigned char *)s->init_buf->data;
*(p++)=SSL2_MT_SERVER_VERIFY;
+ die(s->s2->challenge_length <= sizeof s->s2->challenge);
memcpy(p,s->s2->challenge,(unsigned int)s->s2->challenge_length);
/* p+=s->s2->challenge_length; */
@@ -844,6 +856,8 @@
p=(unsigned char *)s->init_buf->data;
*(p++)=SSL2_MT_SERVER_FINISHED;
+ die(s->session->session_id_length
+ <= sizeof s->session->session_id);
memcpy(p,s->session->session_id,
(unsigned int)s->session->session_id_length);
/* p+=s->session->session_id_length; */
Index: ssl/s3_clnt.c
===================================================================
archivo RCS: /e/openssl/cvs/openssl/ssl/s3_clnt.c,v
recuperacion de revision 1.31.2.6
diff -u -r1.31.2.6 s3_clnt.c
--- ssl/s3_clnt.c 2002/01/14 23:42:35 1.31.2.6
+++ ssl/s3_clnt.c 2002/07/30 09:14:27
@@ -117,6 +117,7 @@
#include <openssl/sha.h>
#include <openssl/evp.h>
#include "ssl_locl.h"
+#include "cryptlib.h"
static SSL_METHOD *ssl3_get_client_method(int ver);
static int ssl3_client_hello(SSL *s);
@@ -545,6 +546,7 @@
*(p++)=i;
if (i != 0)
{
+ die(i <= sizeof s->session->session_id);
memcpy(p,s->session->session_id,i);
p+=i;
}
@@ -625,6 +627,14 @@
/* get the session-id */
j= *(p++);
+
+ if(j > sizeof s->session->session_id)
+ {
+ al=SSL_AD_ILLEGAL_PARAMETER;
+ SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,
+ SSL_R_SSL3_SESSION_ID_TOO_LONG);
+ goto f_err;
+ }
if ((j != 0) && (j != SSL3_SESSION_ID_SIZE))
{
Index: ssl/s3_srvr.c
===================================================================
archivo RCS: /e/openssl/cvs/openssl/ssl/s3_srvr.c,v
recuperacion revision 1.49.2.14
diff -u -r1.49.2.14 s3_srvr.c
--- ssl/s3_srvr.c 2002/04/13 22:49:26 1.49.2.14
+++ ssl/s3_srvr.c 2002/07/30 09:14:28
@@ -122,6 +122,7 @@
#include <openssl/evp.h>
#include <openssl/x509.h>
#include "ssl_locl.h"
+#include "cryptlib.h"
static SSL_METHOD *ssl3_get_server_method(int ver);
static int ssl3_get_client_hello(SSL *s);
@@ -948,6 +949,7 @@
s->session->session_id_length=0;
sl=s->session->session_id_length;
+ die(sl <= sizeof s->session->session_id);
*(p++)=sl;
memcpy(p,s->session->session_id,sl);
p+=sl;
Index: ssl/ssl.h
===================================================================
archivo RCS: /e/openssl/cvs/openssl/ssl/ssl.h,v
retrieving revision 1.85.2.12
diff -u -r1.85.2.12 ssl.h
--- ssl/ssl.h 2002/01/14 23:42:42 1.85.2.12
+++ ssl/ssl.h 2002/07/30 09:14:29
@@ -1478,6 +1478,7 @@
#define SSL_R_INVALID_COMMAND 280
#define SSL_R_INVALID_PURPOSE 278
#define SSL_R_INVALID_TRUST 279
+#define SSL_R_KEY_ARG_TOO_LONG 1112
#define SSL_R_LENGTH_MISMATCH 159
#define SSL_R_LENGTH_TOO_SHORT 160
#define SSL_R_LIBRARY_BUG 274
@@ -1546,6 +1547,7 @@
#define SSL_R_SHORT_READ 219
#define SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE 220
#define SSL_R_SSL23_DOING_SESSION_ID_REUSE 221
+#define SSL_R_SSL3_SESSION_ID_TOO_LONG 1113
#define SSL_R_SSL3_SESSION_ID_TOO_SHORT 222
#define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE 1042
#define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020
Index: ssl/ssl_asn1.c
===================================================================
archivo RCS: /e/openssl/cvs/openssl/ssl/ssl_asn1.c,v
recuperacion de revision 1.8
diff -u -r1.8 ssl_asn1.c
--- ssl/ssl_asn1.c 2000/06/01 22:19:19 1.8
+++ ssl/ssl_asn1.c 2002/07/30 09:14:29
@@ -62,6 +62,7 @@
#include <openssl/objects.h>
#include <openssl/x509.h>
#include "ssl_locl.h"
+#include "cryptlib.h"
typedef struct ssl_session_asn1_st
{
@@ -275,6 +276,7 @@
os.length=i;
ret->session_id_length=os.length;
+ die(os.length <= sizeof ret->session_id);
memcpy(ret->session_id,os.data,os.length);
M_ASN1_D2I_get(osp,d2i_ASN1_OCTET_STRING);
Index: ssl/ssl_err.c
===================================================================
archivo RCS: /e/openssl/cvs/openssl/ssl/ssl_err.c,v
recuperacion de revision 1.28.2.6
diff -u -r1.28.2.6 ssl_err.c
--- ssl/ssl_err.c 2001/11/10 01:15:29 1.28.2.6
+++ ssl/ssl_err.c 2002/07/30 09:14:30
@@ -1,6 +1,6 @@
/* ssl/ssl_err.c */
/* ====================================================================
@@ -275,6 +275,7 @@
{SSL_R_INVALID_COMMAND ,"invalid command"},
{SSL_R_INVALID_PURPOSE ,"invalid purpose"},
{SSL_R_INVALID_TRUST ,"invalid trust"},
+{SSL_R_KEY_ARG_TOO_LONG ,"key arg too long"},
{SSL_R_LENGTH_MISMATCH ,"length mismatch"},
{SSL_R_LENGTH_TOO_SHORT ,"length too short"},
{SSL_R_LIBRARY_BUG ,"library bug"},
@@ -343,6 +344,7 @@
{SSL_R_SHORT_READ ,"short read"},
{SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE,"signature for non signing certificate"},
{SSL_R_SSL23_DOING_SESSION_ID_REUSE ,"ssl23 doing session id reuse"},
+{SSL_R_SSL3_SESSION_ID_TOO_LONG ,"ssl3 session id too long"},
{SSL_R_SSL3_SESSION_ID_TOO_SHORT ,"ssl3 session id too short"},
{SSL_R_SSLV3_ALERT_BAD_CERTIFICATE ,"sslv3 alert bad certificate"},
{SSL_R_SSLV3_ALERT_BAD_RECORD_MAC ,"sslv3 alert bad record mac"},
Index: ssl/ssl_sess.c
===================================================================
archivo RCS: /e/openssl/cvs/openssl/ssl/ssl_sess.c,v
recuperacion de revision 1.30.2.2
diff -u -r1.30.2.2 ssl_sess.c
--- ssl/ssl_sess.c 2002/02/10 12:52:57 1.30.2.2
+++ ssl/ssl_sess.c 2002/07/30 09:14:30
@@ -60,6 +60,7 @@
#include <openssl/lhash.h>
#include <openssl/rand.h>
#include "ssl_locl.h"
+#include "cryptlib.h"
static void SSL_SESSION_list_remove(SSL_CTX *ctx, SSL_SESSION *s);
static void SSL_SESSION_list_add(SSL_CTX *ctx,SSL_SESSION *s);
@@ -199,6 +200,7 @@
ss->session_id_length=0;
}
+ die(s->sid_ctx_length <= sizeof ss->sid_ctx);
memcpy(ss->sid_ctx,s->sid_ctx,s->sid_ctx_length);
ss->sid_ctx_length=s->sid_ctx_length;
s->session=ss;
hax0rs lab 2002© - f0ul - USDL - syslogd - p0rt - Oday - billy