<!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 style="color: #777777;">
<a href="https://gitlab.com/ltx2018">lutianxiong</a>
commented:
</p>
<div style="">
<p dir="auto">i found heap-memory address stored in session->key.proto.tls12 was overwrite by read_server_hello(handshake.c,line 1947)</p>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">       if (!vers->tls13_sem) {</span>
<span id="LC2" class="line" lang="plaintext">               gnutls_memset(&session->key.proto.tls13, 0,</span>
<span id="LC3" class="line" lang="plaintext">                             sizeof(session->key.proto.tls13));</span>
<span id="LC4" class="line" lang="plaintext">               reset_binders(session);</span>
<span id="LC5" class="line" lang="plaintext">       }</span>
<span id="LC6" class="line" lang="plaintext"></span></code></pre>
<p dir="auto">following is debuginfo:</p>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">1947           if (!vers->tls13_sem) {</span>
<span id="LC2" class="line" lang="plaintext">(gdb) p session->key.proto.tls12.dh</span>
<span id="LC3" class="line" lang="plaintext">$7 = {params = {params = {0x602000004d10, 0x0, 0x602000004cd0, 0x0 <repeats 13 times>}, params_nr = 3, pkflags = 0, qbits = 0, curve = GNUTLS_ECC_CURVE_INVALID, dh_group = GNUTLS_GROUP_INVALID, gost_params = GNUTLS_GOST_PARAMSET_UNKNOWN, raw_pub = {data = 0x0,</span>
<span id="LC4" class="line" lang="plaintext">      size = 0}, raw_priv = {data = 0x0, size = 0}, seed_size = 0, seed = '\000' <repeats 255 times>, palgo = GNUTLS_DIG_UNKNOWN, spki = {pk = GNUTLS_PK_UNKNOWN, rsa_pss_dig = GNUTLS_DIG_UNKNOWN, salt_size = 0, legacy = 0, dsa_dig = GNUTLS_DIG_UNKNOWN, flags = 0},</span>
<span id="LC5" class="line" lang="plaintext">    algo = GNUTLS_PK_DH}, client_Y = 0x602000004cb0}</span>
<span id="LC6" class="line" lang="plaintext">(gdb) n</span>
<span id="LC7" class="line" lang="plaintext">1948                   gnutls_memset(&session->key.proto.tls13, 0,</span>
<span id="LC8" class="line" lang="plaintext">(gdb) n</span>
<span id="LC9" class="line" lang="plaintext">1950                   reset_binders(session);</span>
<span id="LC10" class="line" lang="plaintext">(gdb) n</span>
<span id="LC11" class="line" lang="plaintext">1956          if (!vers->tls13_sem &&</span>
<span id="LC12" class="line" lang="plaintext">(gdb) p session->key.proto.tls12.dh</span>
<span id="LC13" class="line" lang="plaintext">$8 = {params = {params = {0x602000000000, 0x0, 0x602000004cd0, 0x0 <repeats 13 times>}, params_nr = 3, pkflags = 0, qbits = 0, curve = GNUTLS_ECC_CURVE_INVALID, dh_group = GNUTLS_GROUP_INVALID, gost_params = GNUTLS_GOST_PARAMSET_UNKNOWN, raw_pub = {data = 0x0,</span>
<span id="LC14" class="line" lang="plaintext">      size = 0}, raw_priv = {data = 0x0, size = 0}, seed_size = 0, seed = '\000' <repeats 255 times>, palgo = GNUTLS_DIG_UNKNOWN, spki = {pk = GNUTLS_PK_UNKNOWN, rsa_pss_dig = GNUTLS_DIG_UNKNOWN, salt_size = 0, legacy = 0, dsa_dig = GNUTLS_DIG_UNKNOWN, flags = 0},</span>
<span id="LC15" class="line" lang="plaintext">    algo = GNUTLS_PK_DH}, client_Y = 0x602000004cb0}</span>
<span id="LC16" class="line" lang="plaintext">(gdb)</span></code></pre>
<p dir="auto">later, while gnutls_deinit the session:
gnutls_pk_params_release(&session->key.proto.tls12.dh.params) trigger the read-heap-buffer-overflow</p>
</div>


</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #777;">

<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/-/issues/1071#note_399141602">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/9b25ee6e502105a982c13e712fc511e5/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/1071#note_399141602"}}</script>


</p>
</div>
</body>
</html>