Skip to content

[Bug]: HelloRetryRequest Extension Whitelist Runtime Recheck #10320

@LiD0209

Description

@LiD0209

Contact Details

lxd_dong@bupt.edu.cn

Version

V5.9.1

Description

HelloRetryRequest Extension Whitelist Runtime Recheck



Summary


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

The test injected a TLS 1.3 HelloRetryRequest 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 HelloRetryRequest must not contain
extensions that were not first offered by the client, except for cookie.


RFC 8446 Text



HelloRetryRequest Extension Constraint


RFC 8446 Section 4.1.4, "Hello Retry Request":
https://www.rfc-editor.org/rfc/rfc8446.html#section-4.1.4


The server's extensions MUST contain "supported_versions".
Additionally, it SHOULD contain the minimal set of extensions
necessary for the client to generate a correct ClientHello pair. As
with the ServerHello, a HelloRetryRequest MUST NOT contain any
extensions that were not first offered by the client in its
ClientHello, with the exception of optionally the "cookie" (see
Section 4.2.2) extension.



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.



wolfSSL Source Evidence



Parse Entry


HelloRetryRequest 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 cookie, wolfSSL does perform message-type
constraints; see tls.c:


if (msgType != client_hello &&
msgType != hello_retry_request) {
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.


Additional HRR Consistency Check


wolfSSL also checks whether HRR causes a meaningful ClientHello change; see
tls13.c:


if (!ssl->options.hrrSentKeyShare
#ifdef WOLFSSL_SEND_HRR_COOKIE
&& !ssl->options.hrrSentCookie
#endif
) {
SendAlert(ssl, alert_fatal, illegal_parameter);
return EXT_MISSING;
}


This check is useful, but it does not replace the strict requirement to reject
extra unknown HRR extensions.


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 hrrUnknownExt[] = {
...
0xfa, 0xfa, 0x00, 0x00
};


The HRR keeps valid supported_versions and key_share, then adds an unknown
extension type 0xFAFA.

Key result:


=== HRR-like: HRR + unknown extension ===
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 HelloRetryRequest, wolfSSL does
not immediately reject it in the tested build. This is inconsistent with the
strict HRR extension whitelist rule in RFC 8446.

Reproduction steps

No response

Relevant log output

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions