mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-06 06:40:49 +02:00
F-5629: reject ServerHello ALPN response with multiple protocols
A response ProtocolNameList was passed whole to ALPN_find_match, which accepts the first configured match, so a server could return more than one protocol. Per RFC 7301 Section 3.1 the ServerHello list must contain exactly one name; enforce that the single name spans the whole list and reject otherwise with a fatal illegal_parameter alert.
This commit is contained in:
@@ -2065,6 +2065,15 @@ static int TLSX_ALPN_ParseAndSet(WOLFSSL *ssl, const byte *input, word16 length,
|
||||
byte sel_len = 0;
|
||||
TLSX *extension = NULL;
|
||||
|
||||
/* RFC 7301 Section 3.1: a ServerHello ALPN extension MUST contain
|
||||
* exactly one protocol name. The first name's length byte plus its
|
||||
* payload must therefore span the whole list. */
|
||||
if ((word16)(input[offset] + OPAQUE8_LEN) != size) {
|
||||
SendAlert(ssl, alert_fatal, illegal_parameter);
|
||||
WOLFSSL_ERROR_VERBOSE(BUFFER_ERROR);
|
||||
return BUFFER_ERROR;
|
||||
}
|
||||
|
||||
r = ALPN_find_match(ssl, &extension, &sel, &sel_len, input + offset, size);
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
Reference in New Issue
Block a user