summaryrefslogtreecommitdiff
path: root/src/lib/libssl/s3_lib.c
diff options
context:
space:
mode:
authortb <>2021-03-15 15:59:04 +0000
committertb <>2021-03-15 15:59:04 +0000
commitfc06cdeb11963e348e9787bb95689f9be064a506 (patch)
treeb29d9e1fea7b39c9759db74aee2ef863823a7455 /src/lib/libssl/s3_lib.c
parent70029edfad38276befdaee62f4fe7e084070c0cd (diff)
downloadopenbsd-libressl-v3.2.5.tar.gz
openbsd-libressl-v3.2.5.tar.bz2
openbsd-libressl-v3.2.5.zip
Don't leave stale sequence numbers behind in ssl3_clear()libressl-v3.2.5
A TLS client doing session reuse in a certain way could run into a use-after-free. Set the sequence numbers inside ssl3_clear() to make sure this points at valid memory and do the initialization of the record layer a bit earlier so that this works as desired. Additionally, explicitly clear the sequence numbers in ssl3_free() which would have turned the use-after-free into a NULL dereference. Issue reported by Ilya Chipitsine. Fix from jsing This is errata/6.8/017_libssl.patch.sig
Diffstat (limited to 'src/lib/libssl/s3_lib.c')
-rw-r--r--src/lib/libssl/s3_lib.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c
index 91bfb5f3b6..97dd2005c2 100644
--- a/src/lib/libssl/s3_lib.c
+++ b/src/lib/libssl/s3_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s3_lib.c,v 1.198 2020/09/17 15:42:14 jsing Exp $ */ 1/* $OpenBSD: s3_lib.c,v 1.198.4.1 2021/03/15 15:59:04 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -1577,6 +1577,10 @@ ssl3_free(SSL *s)
1577 1577
1578 free(S3I(s)->alpn_selected); 1578 free(S3I(s)->alpn_selected);
1579 1579
1580 /* Clear reference to sequence numbers. */
1581 tls12_record_layer_clear_read_state(s->internal->rl);
1582 tls12_record_layer_clear_write_state(s->internal->rl);
1583
1580 freezero(S3I(s), sizeof(*S3I(s))); 1584 freezero(S3I(s), sizeof(*S3I(s)));
1581 freezero(s->s3, sizeof(*s->s3)); 1585 freezero(s->s3, sizeof(*s->s3));
1582 1586
@@ -1649,6 +1653,11 @@ ssl3_clear(SSL *s)
1649 s->internal->packet_length = 0; 1653 s->internal->packet_length = 0;
1650 s->version = TLS1_VERSION; 1654 s->version = TLS1_VERSION;
1651 1655
1656 tls12_record_layer_set_read_seq_num(s->internal->rl,
1657 S3I(s)->read_sequence);
1658 tls12_record_layer_set_write_seq_num(s->internal->rl,
1659 S3I(s)->write_sequence);
1660
1652 S3I(s)->hs.state = SSL_ST_BEFORE|((s->server) ? SSL_ST_ACCEPT : SSL_ST_CONNECT); 1661 S3I(s)->hs.state = SSL_ST_BEFORE|((s->server) ? SSL_ST_ACCEPT : SSL_ST_CONNECT);
1653} 1662}
1654 1663