summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2021-06-08 18:05:47 +0000
committertb <>2021-06-08 18:05:47 +0000
commit183dc316a669d210cf5f47b850a5fc7823c6443d (patch)
treebaf0ce8b9a1d2566f342f9d10da1ff3691b0be7d /src/lib
parent720abb9265f274966faea878c7359724d7a08ba6 (diff)
downloadopenbsd-183dc316a669d210cf5f47b850a5fc7823c6443d.tar.gz
openbsd-183dc316a669d210cf5f47b850a5fc7823c6443d.tar.bz2
openbsd-183dc316a669d210cf5f47b850a5fc7823c6443d.zip
Ignore the record version for early alerts
On receiving the first flight from the peer, we do not yet know if we are using TLSv1.3. In particular, we might get an alert record with record version 0x0300 from a pre-TLSv1.2 peer in response to our client hello. Ignore the record version instead of sending a protocol version alert in that situtation. This may also be hit when talking to a LibreSSL 3.3 server with an illegal SNI. Part of an issue reported by danj. ok jsing
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libssl/tls13_record_layer.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lib/libssl/tls13_record_layer.c b/src/lib/libssl/tls13_record_layer.c
index ff2a6884b6..6556547353 100644
--- a/src/lib/libssl/tls13_record_layer.c
+++ b/src/lib/libssl/tls13_record_layer.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_record_layer.c,v 1.61 2021/05/16 14:19:04 jsing Exp $ */ 1/* $OpenBSD: tls13_record_layer.c,v 1.62 2021/06/08 18:05:47 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -826,12 +826,18 @@ tls13_record_layer_read_record(struct tls13_record_layer *rl)
826 return ret; 826 return ret;
827 } 827 }
828 828
829 content_type = tls13_record_content_type(rl->rrec);
830
831 /*
832 * In response to a client hello we may receive an alert in a
833 * record with a legacy version. Otherwise enforce that the
834 * legacy record version is 0x0303 per RFC 8446, section 5.1.
835 */
829 if (rl->legacy_version == TLS1_2_VERSION && 836 if (rl->legacy_version == TLS1_2_VERSION &&
830 tls13_record_version(rl->rrec) != TLS1_2_VERSION) 837 tls13_record_version(rl->rrec) != TLS1_2_VERSION &&
838 (content_type != SSL3_RT_ALERT || !rl->legacy_alerts_allowed))
831 return tls13_send_alert(rl, TLS13_ALERT_PROTOCOL_VERSION); 839 return tls13_send_alert(rl, TLS13_ALERT_PROTOCOL_VERSION);
832 840
833 content_type = tls13_record_content_type(rl->rrec);
834
835 /* 841 /*
836 * Bag of hacks ahead... after the first ClientHello message has been 842 * Bag of hacks ahead... after the first ClientHello message has been
837 * sent or received and before the peer's Finished message has been 843 * sent or received and before the peer's Finished message has been