<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<meta content="text/html; charset=US-ASCII" http-equiv="Content-Type">
<title>
GitLab
</title>
<style>img {
max-width: 100%; height: auto;
}
</style>
</head>
<body>
<div class="content">
<p class="details" style="font-style: italic; color: #666;">
<a href="https://gitlab.com/mmaehren">Marcel Maehren</a> created an issue: <a href="https://gitlab.com/gnutls/gnutls/-/issues/1247">#1247</a>
</p>
<div></div>
<p dir="auto">Hi,
we (<a href="https://gitlab.com/jurajsomorovsky" data-user="3512363" data-reference-type="user" data-container="body" data-placement="top" class="gfm gfm-project_member js-user-link" title="juraj somorovsky">@jurajsomorovsky</a> <a href="https://gitlab.com/ic0ns" data-user="2280671" data-reference-type="user" data-container="body" data-placement="top" class="gfm gfm-project_member js-user-link" title="Robert Merget">@ic0ns</a> <a href="https://gitlab.com/mmaehren" data-user="9031781" data-reference-type="user" data-container="body" data-placement="top" class="gfm gfm-project_member js-user-link" title="Marcel Maehren">@mmaehren</a> <a href="https://gitlab.com/xomex" data-user="2519285" data-reference-type="user" data-container="body" data-placement="top" class="gfm gfm-project_member js-user-link" title="xomex">@xomex</a> <a href="https://gitlab.com/Kavakuo" data-user="1082644" data-reference-type="user" data-container="body" data-placement="top" class="gfm gfm-project_member js-user-link" title="Philipp N.">@Kavakuo</a>) are performing an analysis of the RFC-compliance of open-source TLS implementations. Below we list our findings for this implementation. We admit that some are rather nit-picky, but we added them for the sake of completeness. We tried to keep the descriptions brief and didn’t want to spam the issues section so feel free to split up the list into individual issues as you see fit.
If you disagree with our interpretation of certain RFC statements, please leave feedback as we’re interested in your view.</p>
<p dir="auto">Our results apply to the default configuration of version <em><strong>3.7.0</strong></em>. We used the example implementations for client and server.</p>
<p dir="auto">[S] = Applies to server
[C] = Applies to client
[C+S] = Applies to both</p>
<h2 dir="auto">
<a id="user-content-misc" class="anchor" href="#misc" aria-hidden="true"></a>Misc</h2>
<ul dir="auto">
<li>
<p>[S] GnuTLS accepts session resumption via session IDs even if the previous session has been terminated by a fatal alert</p>
<ul>
<li>RFC 5246 - 7.2.2 Error Alerts
<blockquote>
<p>Thus, any connection terminated with a fatal alert MUST NOT be resumed.</p>
</blockquote>
</li>
</ul>
</li>
<li>
<p>[S] GnuTLS server enforces that a TLS 1.3 client sends a key share for the first mutually supported group within the supported groups extension. As an example if a client offers secp521r1 and secp256r1 (in this order) but sends a key share for secp256r1, GnuTLS sends a HelloRetryRequest demanding a secp521r1 key share.</p>
</li>
<li>
<p>[C] GnuTLS seems to struggle with very small records, i.e records with a fragment length of 1, when a HelloRetryRequest is sent.</p>
<ul>
<li>These records yield a 'decode error' and GnuTLS prints "Fatal error: Error decoding the received TLS packet."</li>
</ul>
</li>
<li>
<p>[C] GnuTLS does not ignore the legacy version field in a ServerHello that negotiates TLS 1.3 and aborts the handshake for invalid values like 0x0304 or 0x0505</p>
<ul>
<li>RFC 8446 - 4.2.1 Supported Versions
<blockquote>
<p>If this extension is present, clients MUST ignore the ServerHello.legacy_version value and MUST use only the "supported_versions" extension to determine the selected version.</p>
</blockquote>
</li>
<li>Note that the RFC also defines that a server MUST use 0x0303 as the legacy version but specifically says that the client MUST ignore the field when SupportedVersions has been received</li>
</ul>
</li>
<li>
<p>[C+S] When encrypt-then-MAC is negotiated, GnuTLS does not validate the padding bytes</p>
</li>
</ul>
<h2 dir="auto">
<a id="user-content-session-not-aborted" class="anchor" href="#session-not-aborted" aria-hidden="true"></a>Session not aborted</h2>
<ul dir="auto">
<li>
<p>[S] upon receiving a ClientHello with an unsolicited Cookie extension</p>
<ul>
<li>RFC 8446 - 4.2.2 Cookie
<blockquote>
<p>Clients MUST NOT use cookies in their initial ClientHello in subsequent connections.</p>
</blockquote>
</li>
</ul>
</li>
<li>
<p>[S] upon receiving a ClientHello proposing TLS 1.3 which does not use 0x0303 for the legacy version field</p>
<ul>
<li>RFC 8446 - 4.1.2 Client Hello
<blockquote>
<p>In TLS 1.3, the client indicates its version preferences in the "supported_versions" extension (Section 4.2.1) and the legacy_version field MUST be set to 0x0303, which is the version number for TLS 1.2.</p>
</blockquote>
</li>
</ul>
</li>
<li>
<p>[C] upon receiving a ClientHello message interleaved with a warning alert</p>
<ul>
<li>Note that this only applies if no HelloRetryRequest has been sent by the server. If a server sends an HRR and interleaves the subsequent ServerHello, GnuTLS closes the connection without an alert.</li>
<li>RFC 8446 - 5.1. Record Layer
<blockquote>
<p>Handshake messages MUST NOT be interleaved with other record types. That is, if a handshake message is split over two or more records, there MUST NOT be any other records between them.</p>
</blockquote>
</li>
</ul>
</li>
<li>
<p>[C] upon receiving a TLS 1.3 HelloRetryRequest that does not result in any changes for the subsequent ClientHello</p>
<ul>
<li>RFC 8446 - 4.1.4 Hello Retry Request
<blockquote>
<p>Clients MUST abort the handshake with an "illegal_parameter" alert if the HelloRetryRequest would not result in any change in the ClientHello.</p>
</blockquote>
</li>
</ul>
</li>
<li>
<p>[C] upon receiving a TLS 1.3 HelloRetryRequest that selects an unproposed or TLS 1.2 cipher suite</p>
<ul>
<li>Note that it is not possible to actually negotiate this cipher suite with a subsequent ServerHello</li>
<li>RFC 8446 - 4.1.4. Hello Retry Request
<blockquote>
<p>Upon receipt of a HelloRetryRequest, the client MUST check the legacy_version, legacy_session_id_echo, cipher_suite, and legacy_compression_method as specified in Section 4.1.3</p>
</blockquote>
</li>
</ul>
</li>
<li>
<p>[C+S] upon receiving a ChangeCipherSpec message with an invalid content (such as 0x7D) as long as this content consists of one byte</p>
<ul>
<li>RFC 5246 - 7.1 Change Cipher Spec Protocol
<blockquote>
<p>The message consists of a single byte of value 1.</p>
</blockquote>
</li>
</ul>
</li>
<li>
<p>[C] when a server chooses a non-CBC cipher suite but negotiates encrypt-then-MAC</p>
<ul>
<li>RFC 7366 - 3. Applying Encrypt-then-MAC
<blockquote>
<p>If a server receives an encrypt-then-MAC request extension from a client and then selects a stream or Authenticated Encryption with Associated Data (AEAD) ciphersuite, it MUST NOT send an encrypt-then-MAC response extension back to the client.</p>
</blockquote>
</li>
</ul>
</li>
<li>
<p>[C] upon receiving a GREASE extension as part of a ServerHello, HelloRetryRequest, or EncryptedExtensions message</p>
<ul>
<li>Note that this is likely caused by an unknown extension type, not a specific GREASE value</li>
<li>RFC 9701 - 3.1. Client Behavior
<blockquote>
<p>In particular, the client MUST fail the connection if a GREASE value appears in any of the following: [...] Any ServerHello extension, [...] Any EncryptedExtensions extension</p>
</blockquote>
</li>
<li>In general a client MUST reject such an extension if it wasn't proposed</li>
</ul>
</li>
<li>
<p>[C] upon receiving a forbidden extension in the EncryptedExtensions message (specifically tested with Padding extension)</p>
<ul>
<li>RFC 8446 - 4.3.1 Encrypted Extensions
<blockquote>
<p>The client MUST check EncryptedExtensions for the presence of any forbidden extensions and if any are found MUST abort the handshake with an "illegal_parameter" alert.</p>
</blockquote>
</li>
</ul>
</li>
<li>
<p>[C] upon receiving a ServerHello negotiating TLS 1.3 that does not echo the empty session ID sent by GnuTLS</p>
<ul>
<li>RFC 8446 - 4.1.3 Server Hello
<blockquote>
<p>A client which receives a legacy_session_id_echo field that does not match what it sent in the ClientHello MUST abort the handshake with an "illegal_parameter" alert.</p>
</blockquote>
</li>
</ul>
</li>
<li>
<p>[S] upon receiving a Padding extension that contains bytes other than 0x00</p>
<ul>
<li>Please leave a comment if your implementation does not support this extension and hence ignores the content</li>
<li>RFC 7685 - 3. Padding Extension
<blockquote>
<p>The client MUST fill the padding extension completely with zero bytes, although the padding extension_data field may be empty.</p>
</blockquote>
</li>
</ul>
</li>
<li>
<p>[S] upon receiving a SupportedPointFormat extension
that only accepts compressed points or an invalid format</p>
<ul>
<li>8422 - 5.1. Client Hello Extensions
<blockquote>
<p>If the client sends the extension and the extension does not contain the uncompressed point format, and the client has used the Supported Groups extension to indicate support for any of the curves defined in this specification, then the server MUST abort the handshake and return an illegal_parameter alert.</p>
</blockquote>
</li>
</ul>
</li>
</ul>
<h2 dir="auto">
<a id="user-content-only-session-closed-but-no-alert-sent" class="anchor" href="#only-session-closed-but-no-alert-sent" aria-hidden="true"></a>Only session closed but no alert sent</h2>
<ul dir="auto">
<li>
<p>[C] upon receiving a record with an invalid MAC / AEAD tag or with an invalid padding (for CBC cipher suites)</p>
</li>
<li>
<p>[C] upon receiving a record without any content</p>
</li>
<li>
<p>[C] upon receiving a record that exceeds the maximum ciphertext or plaintext fragment length</p>
</li>
<li>
<p>[C] upon receiving an encrypted legacy ChangeCipherSpec message or an unprotected ChangeCipherSpec after a completed handshake in a TLS 1.3 session</p>
</li>
</ul>
<h2 dir="auto">
<a id="user-content-different-alert-sent-than-defined-by-the-rfc" class="anchor" href="#different-alert-sent-than-defined-by-the-rfc" aria-hidden="true"></a>Different alert sent than defined by the RFC</h2>
<ul dir="auto">
<li>
<p>[S] upon receiving a ClientHello proposing TLS 1.3 without a SignatureAlgorithms extension. GnuTLS sends a 'handshake failure' alert.</p>
<ul>
<li>RFC 8446 - 4.2.3 Signature Algorithms
<blockquote>
<p>If a server is authenticating via a certificate and the client has not sent a "signature_algorithms" extension, then the server MUST abort the handshake with a "missing_extension" alert (see Section 9.2).</p>
</blockquote>
</li>
</ul>
</li>
<li>
<p>[C] upon receiving a ServerHello that negotiates TLS 1.3 and selects an unproposed cipher suite. GnuTLS sends a 'handshake failure' alert.</p>
<ul>
<li>RFC 8446 - 4.1.3 Server Hello
<blockquote>
<p>A client which receives a cipher suite that was not offered MUST abort the handshake with an "illegal_parameter" alert.</p>
</blockquote>
</li>
</ul>
</li>
<li>
<p>[C] upon receiving an EncryptedExtensions message that contains a SupportedVersions extension. GnuTLS sends an 'unsupported extension' alert.</p>
<ul>
<li>RFC 8446 - 4.3.1 Encrypted Extensions
<blockquote>
<p>The client MUST check EncryptedExtensions for the presence of any forbidden extensions and if any are found MUST abort the handshake with an "illegal_parameter" alert.</p>
</blockquote>
</li>
</ul>
</li>
<li>
<p>[C+S] upon receiving a 'close notify' alert during the handshake. GnuTLS sends an 'internal error'</p>
<ul>
<li>This may be a corner case due to the uncompleted handshake</li>
<li>RFC 5246 7.2.1 Closure Alerts
<blockquote>
<p>The other party MUST respond with a close_notify alert of its own and close down the connection immediately, discarding any pending writes.</p>
</blockquote>
</li>
</ul>
</li>
<li>
<p>[S] upon receiving a record with the undefined record content type 0xff at the beginning of the handshake, GnuTLS responds with a 'record overflow' alert</p>
<ul>
<li>Note that this may be related to legacy SSL2 parsing code</li>
<li>RFC 8446 - 5. Record Protocol
<blockquote>
<p>If a TLS implementation receives an unexpected record type, it MUST terminate the connection with an "unexpected_message" alert.</p>
</blockquote>
</li>
</ul>
</li>
</ul>
</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #666;">
—
<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/-/issues/1247">view it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can
<a href="https://gitlab.com/-/sent_notifications/58585734448ae582288fbd7195577aee/unsubscribe">unsubscribe</a>
from this thread or
adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Issue","url":"https://gitlab.com/gnutls/gnutls/-/issues/1247"}}</script>
</p>
</div>
</body>
</html>