diff options
author | Matt Caswell <matt@openssl.org> | 2016-07-22 14:58:19 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-07-29 12:42:40 +0100 |
commit | 0647719d809abdfe6b871949f4f75ce82da6616a (patch) | |
tree | 829a059b3d0b327c7e250c74059c6fd24753ec54 /ssl | |
parent | 1a627771634adba9d4f3b5cf7be74d6bab428a5f (diff) |
Make the checks for an SSLv2 style record stricter
SSLv2 is no longer supported in 1.1.0, however we *do* still accept an SSLv2
style ClientHello, as long as we then subsequently negotiate a protocol
version >= SSLv3. The record format for SSLv2 style ClientHellos is quite
different to SSLv3+. We only accept this format in the first record of an
initial ClientHello. Previously we checked this by confirming
s->first_packet is set and s->server is true. However, this really only
tells us that we are dealing with an initial ClientHello, not that it is
the first record (s->first_packet is badly named...it really means this is
the first message). To check this is the first record of the initial
ClientHello we should also check that we've not received any data yet
(s->init_num == 0), and that we've not had any empty records.
GitHub Issue #1298
Reviewed-by: Emilia Käsper <emilia@openssl.org>
Diffstat (limited to 'ssl')
-rw-r--r-- | ssl/record/ssl3_record.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/ssl/record/ssl3_record.c b/ssl/record/ssl3_record.c index b4d89811fe..ad240bc52d 100644 --- a/ssl/record/ssl3_record.c +++ b/ssl/record/ssl3_record.c @@ -160,12 +160,18 @@ int ssl3_get_record(SSL *s) /* * Check whether this is a regular record or an SSLv2 style record. - * The latter is only used in an initial ClientHello for old - * clients. We check s->read_hash and s->enc_read_ctx to ensure this - * does not apply during renegotiation + * The latter can only be used in the first record of an initial + * ClientHello for old clients. Initial ClientHello means + * s->first_packet is set and s->server is true. The first record + * means we've not received any data so far (s->init_num == 0) and + * have had no empty records. We check s->read_hash and + * s->enc_read_ctx to ensure this does not apply during + * renegotiation. */ - if (s->first_packet && s->server && !s->read_hash - && !s->enc_read_ctx + if (s->first_packet && s->server + && s->init_num == 0 + && RECORD_LAYER_get_empty_record_count(&s->rlayer) == 0 + && s->read_hash == NULL && s->enc_read_ctx == NULL && (p[0] & 0x80) && (p[2] == SSL2_MT_CLIENT_HELLO)) { /* * SSLv2 style record |