<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en" style='--code-editor-font: var(--default-mono-font, "GitLab Mono"), JetBrains Mono, Menlo, DejaVu Sans Mono, Liberation Mono, Consolas, Ubuntu Mono, Courier New, andale mono, lucida console, monospace;'>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>
GitLab
</title>
<style data-premailer="ignore" type="text/css">
a { color: #1068bf; }
</style>
<style>img {
max-width: 100%; height: auto;
}
body {
font-size: .875rem;
}
body {
-webkit-text-shadow: hsla(0,0%,100%,.01) 0 0 1px;
}
body {
font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"; font-size: inherit;
}
</style>
</head>
<body style='font-size: inherit; -webkit-text-shadow: hsla(0,0%,100%,.01) 0 0 1px; font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";'>
<div class="content">
<p class="details" style="font-style: italic; color: #626168;">
<a href="https://gitlab.com/liyue-cs">liyue</a> created an issue: <a href="https://gitlab.com/gnutls/gnutls/-/work_items/1841">#1841</a>
</p>
<div class="md" style="position: relative; z-index: 1; color: #3a383f; word-wrap: break-word;">
<h2 id="user-content-description-of-problem-gnutls-security-disclosure-non-zeroizing-free-of-shared-secret-buffers-in-hybrid-key-exchange" dir="auto" style="margin-top: 0px; margin-bottom: 10px;" align="initial">Description of problem: GnuTLS Security Disclosure: Non-Zeroizing Free of Shared Secret Buffers in Hybrid Key Exchange<a href="#description-of-problem-gnutls-security-disclosure-non-zeroizing-free-of-shared-secret-buffers-in-hybrid-key-exchange" aria-label="Link to heading 'Description of problem: GnuTLS Security Disclosure: Non-Zeroizing Free of Shared Secret Buffers in Hybrid Key Exchange'" data-heading-content="Description of problem: GnuTLS Security Disclosure: Non-Zeroizing Free of Shared Secret Buffers in Hybrid Key Exchange" class="anchor" style="margin-top: 0px;"></a>
</h2>
<h2 id="user-content-affected-branch-master" dir="auto" style="margin-top: 20px; margin-bottom: 10px;" align="initial">Affected branch: master<a href="#affected-branch-master" aria-label="Link to heading 'Affected branch: master'" data-heading-content="Affected branch: master" class="anchor" style="margin-top: 0px;"></a>
</h2>
<p dir="auto" style="color: #3a383f; margin: 0px 0px 1rem;" align="initial">We are researchers conducting a systematic security study of hybrid post-quantum KEM implementations across open-source projects. During our analysis of GnuTLS's hybrid key share extension, we identified that shared secret buffers are freed using <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0px; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>_gnutls_free_datum()</code> instead of the secure <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>_gnutls_free_key_datum()</code> in two functions in <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>lib/ext/key_share.c</code>.</p>
<h2 id="user-content-summary" dir="auto" style="margin-top: 20px; margin-bottom: 10px;" align="initial">Summary<a href="#summary" aria-label="Link to heading 'Summary'" data-heading-content="Summary" class="anchor" style="margin-top: 0px;"></a>
</h2>
<p dir="auto" style="color: #3a383f; margin: 0px 0px 1rem;" align="initial">In <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0px; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>server_use_key_share_single()</code> and <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>client_use_key_share_single()</code>, KEM/ECDH shared secrets are stored in a local <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>gnutls_datum_t key</code> variable. After the shared secret is copied to <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>session->key.key</code> via <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>append_key_datum()</code>, the original buffer is freed with <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>_gnutls_free_datum(&key)</code>, which calls <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>gnutls_free()</code> without first clearing the buffer contents. The secure alternative <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>_gnutls_free_key_datum(&key)</code> calls <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>zeroize_key()</code> before <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>gnutls_free()</code>.</p>
<h2 id="user-content-affected-code" dir="auto" style="margin-top: 20px; margin-bottom: 10px;" align="initial">Affected Code<a href="#affected-code" aria-label="Link to heading 'Affected Code'" data-heading-content="Affected Code" class="anchor" style="margin-top: 0px;"></a>
</h2>
<p dir="auto" style="color: #3a383f; margin: 0px 0px 1rem;" align="initial"><strong style="font-weight: 600; margin-top: 0px;">Function <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0px; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; white-space: pre-wrap; overflow-wrap: break-word; word-break: keep-all; padding: 0.125rem 0.25rem;'>server_use_key_share_single()</code></strong> — 3 locations:</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre data-canonical-lang="c" class="code highlight js-syntax-highlight language-c" v-pre="true" style='display: block; font-size: 14px; color: #3a383f; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0px 0 1rem; padding: 12px; border: 1px solid #dcdcde;'><code style='font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0px; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; overflow-wrap: normal; padding: unset;'><span id="LC1" class="line" lang="c" style="margin-top: 0px;"><span class="c1" style="margin-top: 0px;">// Line 464-465 (ECDH P-256/P-384 shared secret)</span></span>
<span id="LC2" class="line" lang="c"></span>
<span id="LC3" class="line" lang="c"></span>
<span id="LC4" class="line" lang="c"><span class="n" style="margin-top: 0px;">ret</span> <span class="o">=</span> <span class="n">append_key_datum</span><span class="p">(</span><span class="o">&</span><span class="n">session</span><span class="o">-></span><span class="n">key</span><span class="p">.</span><span class="n">key</span><span class="p">,</span> <span class="o">&</span><span class="n">key</span><span class="p">);</span></span>
<span id="LC5" class="line" lang="c"><span class="n" style="margin-top: 0px;">_gnutls_free_datum</span><span class="p">(</span><span class="o">&</span><span class="n">key</span><span class="p">);</span> <span class="c1">// should be _gnutls_free_key_datum(&key)</span></span>
<span id="LC6" class="line" lang="c"></span>
<span id="LC7" class="line" lang="c"><span class="c1" style="margin-top: 0px;">// Line 508-509 (X25519/X448 shared secret)</span></span>
<span id="LC8" class="line" lang="c"></span>
<span id="LC9" class="line" lang="c"></span>
<span id="LC10" class="line" lang="c"><span class="n" style="margin-top: 0px;">ret</span> <span class="o">=</span> <span class="n">append_key_datum</span><span class="p">(</span><span class="o">&</span><span class="n">session</span><span class="o">-></span><span class="n">key</span><span class="p">.</span><span class="n">key</span><span class="p">,</span> <span class="o">&</span><span class="n">key</span><span class="p">);</span></span>
<span id="LC11" class="line" lang="c"><span class="n" style="margin-top: 0px;">_gnutls_free_datum</span><span class="p">(</span><span class="o">&</span><span class="n">key</span><span class="p">);</span> <span class="c1">// should be _gnutls_free_key_datum(&key)</span></span>
<span id="LC12" class="line" lang="c"></span>
<span id="LC13" class="line" lang="c"><span class="c1" style="margin-top: 0px;">// Line 605-606 (ML-KEM/Kyber shared secret from _gnutls_pk_encaps)</span></span>
<span id="LC14" class="line" lang="c"></span>
<span id="LC15" class="line" lang="c"></span>
<span id="LC16" class="line" lang="c"><span class="n" style="margin-top: 0px;">ret</span> <span class="o">=</span> <span class="n">append_key_datum</span><span class="p">(</span><span class="o">&</span><span class="n">session</span><span class="o">-></span><span class="n">key</span><span class="p">.</span><span class="n">key</span><span class="p">,</span> <span class="o">&</span><span class="n">key</span><span class="p">);</span></span>
<span id="LC17" class="line" lang="c"><span class="n" style="margin-top: 0px;">_gnutls_free_datum</span><span class="p">(</span><span class="o">&</span><span class="n">key</span><span class="p">);</span> <span class="c1">// should be _gnutls_free_key_datum(&key)</span></span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<p dir="auto" style="color: #3a383f; margin: 0px 0px 1rem;" align="initial"><strong style="font-weight: 600; margin-top: 0px;">Function <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0px; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; white-space: pre-wrap; overflow-wrap: break-word; word-break: keep-all; padding: 0.125rem 0.25rem;'>client_use_key_share_single()</code></strong> — 4 locations:</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre data-canonical-lang="c" class="code highlight js-syntax-highlight language-c" v-pre="true" style='display: block; font-size: 14px; color: #3a383f; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0px 0 1rem; padding: 12px; border: 1px solid #dcdcde;'><code style='font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0px; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; overflow-wrap: normal; padding: unset;'><span id="LC1" class="line" lang="c" style="margin-top: 0px;"><span class="c1" style="margin-top: 0px;">// Lines 703, 742, 779, 800 — same pattern for ECDH, X25519, DH, ML-KEM</span></span>
<span id="LC2" class="line" lang="c"></span>
<span id="LC3" class="line" lang="c"></span>
<span id="LC4" class="line" lang="c"><span class="n" style="margin-top: 0px;">ret</span> <span class="o">=</span> <span class="n">append_key_datum</span><span class="p">(</span><span class="o">&</span><span class="n">session</span><span class="o">-></span><span class="n">key</span><span class="p">.</span><span class="n">key</span><span class="p">,</span> <span class="o">&</span><span class="n">key</span><span class="p">);</span></span>
<span id="LC5" class="line" lang="c"><span class="n" style="margin-top: 0px;">_gnutls_free_datum</span><span class="p">(</span><span class="o">&</span><span class="n">key</span><span class="p">);</span> <span class="c1">// should be _gnutls_free_key_datum(&key)</span></span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<h2 id="user-content-the-difference" dir="auto" style="margin-top: 20px; margin-bottom: 10px;" align="initial">The Difference<a href="#the-difference" aria-label="Link to heading 'The Difference'" data-heading-content="The Difference" class="anchor" style="margin-top: 0px;"></a>
</h2>
<p dir="auto" style="color: #3a383f; margin: 0px 0px 1rem;" align="initial">From <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0px; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>lib/datum.h</code>:</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre data-canonical-lang="c" class="code highlight js-syntax-highlight language-c" v-pre="true" style='display: block; font-size: 14px; color: #3a383f; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0px 0 1rem; padding: 12px; border: 1px solid #dcdcde;'><code style='font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0px; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; overflow-wrap: normal; padding: unset;'><span id="LC1" class="line" lang="c" style="margin-top: 0px;"><span class="c1" style="margin-top: 0px;">// _gnutls_free_datum: does NOT clear buffer contents</span></span>
<span id="LC2" class="line" lang="c"></span>
<span id="LC3" class="line" lang="c"></span>
<span id="LC4" class="line" lang="c"><span class="kr" style="margin-top: 0px;">inline</span> <span class="k">static</span> <span class="kt">void</span> <span class="nf">_gnutls_free_datum</span><span class="p">(</span><span class="n">gnutls_datum_t</span> <span class="o">*</span><span class="n">dat</span><span class="p">)</span> <span class="p">{</span></span>
<span id="LC5" class="line" lang="c"> <span class="n" style="margin-top: 0px;">gnutls_free</span><span class="p">(</span><span class="n">dat</span><span class="o">-></span><span class="n">data</span><span class="p">);</span> <span class="c1">// free only</span></span>
<span id="LC6" class="line" lang="c"> <span class="n" style="margin-top: 0px;">dat</span><span class="o">-></span><span class="n">size</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span></span>
<span id="LC7" class="line" lang="c"><span class="p" style="margin-top: 0px;">}</span></span>
<span id="LC8" class="line" lang="c"></span>
<span id="LC9" class="line" lang="c"><span class="c1" style="margin-top: 0px;">// _gnutls_free_key_datum: clears buffer BEFORE freeing</span></span>
<span id="LC10" class="line" lang="c"></span>
<span id="LC11" class="line" lang="c"></span>
<span id="LC12" class="line" lang="c"><span class="kr" style="margin-top: 0px;">inline</span> <span class="k">static</span> <span class="kt">void</span> <span class="nf">_gnutls_free_key_datum</span><span class="p">(</span><span class="n">gnutls_datum_t</span> <span class="o">*</span><span class="n">dat</span><span class="p">)</span> <span class="p">{</span></span>
<span id="LC13" class="line" lang="c"> <span class="n" style="margin-top: 0px;">zeroize_key</span><span class="p">(</span><span class="n">dat</span><span class="o">-></span><span class="n">data</span><span class="p">,</span> <span class="n">dat</span><span class="o">-></span><span class="n">size</span><span class="p">);</span> <span class="c1">// zero first</span></span>
<span id="LC14" class="line" lang="c"> <span class="n" style="margin-top: 0px;">gnutls_free</span><span class="p">(</span><span class="n">dat</span><span class="o">-></span><span class="n">data</span><span class="p">);</span> <span class="c1">// then free</span></span>
<span id="LC15" class="line" lang="c"> <span class="n" style="margin-top: 0px;">dat</span><span class="o">-></span><span class="n">size</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span></span>
<span id="LC16" class="line" lang="c"><span class="p" style="margin-top: 0px;">}</span></span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<h2 id="user-content-impact" dir="auto" style="margin-top: 20px; margin-bottom: 10px;" align="initial">Impact<a href="#impact" aria-label="Link to heading 'Impact'" data-heading-content="Impact" class="anchor" style="margin-top: 0px;"></a>
</h2>
<p dir="auto" style="color: #3a383f; margin: 0px 0px 1rem;" align="initial">After <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0px; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>_gnutls_free_datum(&key)</code>, the shared secret bytes remain in freed heap memory until overwritten by a future allocation. In a hybrid key exchange (e.g., <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>mlkem768nistp256</code>), both the ECDH and ML-KEM shared secrets are affected. An attacker with memory read access (e.g., via a separate memory disclosure vulnerability, cold boot attack, or core dump) could recover the shared secret from freed heap pages.</p>
<p dir="auto" style="color: #3a383f; margin: 0px 0px 1rem;" align="initial">We note that this issue also affects non-hybrid key exchanges (pure ECDH, X25519, FFDHE) in the same functions, since the same <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0px; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>_gnutls_free_datum(&key)</code> pattern is used for all key agreement types.</p>
<h2 id="user-content-suggested-fix" dir="auto" style="margin-top: 20px; margin-bottom: 10px;" align="initial">Suggested Fix<a href="#suggested-fix" aria-label="Link to heading 'Suggested Fix'" data-heading-content="Suggested Fix" class="anchor" style="margin-top: 0px;"></a>
</h2>
<p dir="auto" style="color: #3a383f; margin: 0px 0px 1rem;" align="initial">Replace <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0px; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>_gnutls_free_datum(&key)</code> with <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>_gnutls_free_key_datum(&key)</code> at the 7 identified locations. The secure variant is already available in GnuTLS and is used elsewhere in the codebase for handling sensitive key material.</p>
<h2 id="user-content-standard-reference" dir="auto" style="margin-top: 20px; margin-bottom: 10px;" align="initial">Standard Reference<a href="#standard-reference" aria-label="Link to heading 'Standard Reference'" data-heading-content="Standard Reference" class="anchor" style="margin-top: 0px;"></a>
</h2>
<ul dir="auto" style="text-align: initial; list-style-type: disc; margin: 0px; padding: 0;">
<li style="margin-top: 0px; line-height: 1.6em; margin-left: 25px; padding-left: 3px;">NIST SP 800-227: "Intermediate values used in any given KEM algorithm SHALL be destroyed before the algorithm terminates"</li>
</ul>
</div>
</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #626168;">
—
<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/-/work_items/1841">view it on GitLab</a>.
<br>
You're receiving this email because of your account on <a target="_blank" rel="noopener noreferrer" href="https://gitlab.com">gitlab.com</a>. <a href="https://gitlab.com/-/sent_notifications/4-bmyu10f248po2yhf3bwnzfcpv-a84t7/unsubscribe" target="_blank" rel="noopener noreferrer">Unsubscribe</a> from this thread · <a href="https://gitlab.com/-/profile/notifications" target="_blank" rel="noopener noreferrer" class="mng-notif-link">Manage all notifications</a> · <a href="https://gitlab.com/help" target="_blank" rel="noopener noreferrer" class="help-link">Help</a>
<span style="color: transparent; font-size: 0; display: none; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0;">
Notification message regarding https://gitlab.com/gnutls/gnutls/-/work_items/1841 at 1776064570
</span>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Work item","url":"https://gitlab.com/gnutls/gnutls/-/work_items/1841"}}</script>
</p>
</div>
</body>
</html>