Skip to content

[Bug]: ServerHello Extension Whitelist Runtime Recheck #10321

@LiD0209

Description

@LiD0209

Contact Details

lxd_dong@bupt.edu.cn

Version

V5.9.1

Description

ServerHello Extension Whitelist Runtime Recheck



Summary


The recheck result is that wolfSSL, in the tested build, does not strictly
reject an extra unknown extension in TLS 1.3 ServerHello.

The test injected a ServerHello containing an unknown extension type
0xFAFA. wolfSSL did not immediately fail and did not send a fatal alert;
instead, the client remained in WOLFSSL_ERROR_WANT_READ.



Scope


This note concerns the rule that a TLS 1.3 ServerHello must only include the
extensions required to establish the cryptographic context and negotiate the
protocol version.


RFC 8446 Text



ServerHello Whitelist Requirement


RFC 8446 Section 4.1.3, "Server Hello":
https://www.rfc-editor.org/rfc/rfc8446.html#section-4.1.3


extensions: A list of extensions. The ServerHello MUST only include
extensions which are required to establish the cryptographic
context and negotiate the protocol version. All TLS 1.3
ServerHello messages MUST contain the "supported_versions"
extension. Current ServerHello messages additionally contain
either the "pre_shared_key" extension or the "key_share"
extension, or both (when using a PSK with (EC)DHE key
establishment). Other extensions (see Section 4.2) are sent
separately in the EncryptedExtensions message.



Extension Response Rule


RFC 8446 Section 4.2, "Extensions":
https://www.rfc-editor.org/rfc/rfc8446.html#section-4.2


Implementations MUST NOT send extension responses if the remote
endpoint did not send the corresponding extension requests, with the
exception of the "cookie" extension in the HelloRetryRequest. Upon
receiving such an extension, an endpoint MUST abort the handshake
with an "unsupported_extension" alert.



Alert Definition


RFC 8446 Section 6.2, "Error Alerts":
https://www.rfc-editor.org/rfc/rfc8446.html#section-6.2


unsupported_extension: Sent by endpoints receiving any handshake
message containing an extension known to be prohibited for
inclusion in the given handshake message, or including any
extensions in a ServerHello or Certificate not first offered in
the corresponding ClientHello or CertificateRequest.



wolfSSL Source Evidence



Parse Entry


TLS 1.3 ServerHello extensions eventually enter TLSX_Parse() from
tls13.c:


if (args->totalExtSz > 0 && IsAtLeastTLSv1_3(ssl->version)) {
ret = TLSX_Parse(ssl, input + args->idx, args->totalExtSz,
*extMsgType, NULL);



Known Extension Message Constraints


For known extensions such as pre_shared_key, wolfSSL does perform
message-type constraints; see tls.c:


if (msgType != client_hello &&
msgType != server_hello) {
WOLFSSL_ERROR_VERBOSE(EXT_NOT_ALLOWED);
return EXT_NOT_ALLOWED;
}



Unknown Extension Handling


The key generic branch is in tls.c:


default:
WOLFSSL_MSG("Unknown TLS extension type");


This branch does not return an error or send an alert. It only logs the
unknown extension and continues parsing.


Alert Mapping Note


Even when wolfSSL reaches EXT_NOT_ALLOWED, the error is generally translated
to illegal_parameter, not unsupported_extension; see
internal.c. However, the issue in
this runtime test occurs earlier: the unknown extension does not enter a
rejection path at all.


Runtime Reproduction


Test program: test_tls13_ext_whitelist_269_271.c
Runtime log: runtime_269_271_whitelist_check.log

Constructed input:


static const unsigned char shUnknownExt[] = {
...
0xfa, 0xfa, 0x00, 0x02, 0x03, 0x04
};


The test injects unknown extension type 0xFAFA into a TLS 1.3
ServerHello, while keeping the key-share setup controlled to avoid confusing
the result with a key-share mismatch.

Key result:


=== ServerHello-like: ServerHello + unknown extension ===
wolfSSL_UseKeyShare(secp256r1)=1
result: pending (want io), lastErr=2
alert.last_tx: level=-1 code=-1
alert.last_rx: level=-1 code=-1


Meaning:


  • no immediate fatal error,
  • no fatal alert,
  • the client remains in WOLFSSL_ERROR_WANT_READ.
    

Conclusion


When an extra unknown extension is added to TLS 1.3 ServerHello, wolfSSL does
not immediately reject it in the tested build. This is inconsistent with the
strict ServerHello extension whitelist semantics in RFC 8446.

Reproduction steps

No response

Relevant log output

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions