Bug 16115 (CVE-2026-58218) - [SECURITY] CVE-2026-58218: DNS TKEY negotiation stores unauthenticated GSS contexts in a fixed FIFO before authentication completes
Summary: [SECURITY] CVE-2026-58218: DNS TKEY negotiation stores unauthenticated GSS co...
Status: RESOLVED FIXED
Alias: CVE-2026-58218
Product: Samba 4.1 and newer
Classification: Unclassified
Component: DNS server (internal) (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks: 16039
  Show dependency treegraph
 
Reported: 2026-06-14 06:08 UTC by Douglas Bagnall
Modified: 2026-08-13 14:31 UTC (History)
4 users (show)

See Also:


Attachments
Patch (6.18 KB, text/plain)
2026-06-17 12:40 UTC, Volker Lendecke
dbagnall: review+
vl: ci-passed+
Details
advisory v1 (1.85 KB, text/plain)
2026-07-08 23:10 UTC, Douglas Bagnall
metze: review+
Details
advisory v2 (adding Tristan credit) (1.90 KB, text/plain)
2026-07-15 00:12 UTC, Douglas Bagnall
metze: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Douglas Bagnall 2026-06-14 06:08:27 UTC
Tridge writes:

An unauthenticated DNS client can churn unique TKEY GSSAPI names; Samba allocates GENSEC state and stores each key in a 128-entry FIFO before GSS success, leaving failed entries resident and evicting legitimate update keys.

- source4/dns_server/dns_server.c:144-191 parses DNS bytes and dispatches QUERY processing.
- source4/dns_server/dns_server.h:39 and 46-50 define a 128-entry TKEY FIFO store.
- source4/dns_server/dns_query.c:657-748 creates GENSEC state and stores the key in store->tkeys[next_idx] before returning.
- source4/dns_server/dns_query.c:872-909 creates missing keys, calls accept_gss_ticket(), and leaves failed/MORE_PROCESSING_REQUIRED keys in place.
- source4/dns_server/dns_update.c:801-810 requires authenticated state and later dns_find_tkey() success.

Remaining uncertainty: No DNS service proof was attempted. Runtime impact depends on DNS exposure, request-rate controls outside this code, and the cost of GENSEC contexts on the deployment.

#### Dataflow

Attacker role: Unauthenticated remote DNS client able to send TKEY GSSAPI negotiation queries to Samba internal DNS.

Entrypoint: dns_process_send() parses DNS packets and dispatches DNS_OPCODE_QUERY to dns_server_process_query_send(), which reaches handle_tkey() for TKEY queries.

Trust boundary: Unauthenticated DNS request bytes cause GENSEC state allocation and insertion into the DNS server TKEY FIFO before authentication completes.

Controls and counterevidence:
- create_tkey() accepts only gss-tsig or gss.microsoft.com algorithms.
- The TKEY store is globally capped at TKEY_BUFFER_SIZE 128 entries by FIFO replacement.
- No per-client quota, expiry, or failure cleanup is visible in create_tkey()/handle_tkey().
- Runtime impact depends on DNS exposure and external rate controls.

Exploit steps:
1. Send repeated TKEY GSSAPI queries with unique key names and invalid or incomplete GSS tokens.
2. handle_tkey() does not find an existing key and calls create_tkey().
3. create_tkey() allocates dns_server_tkey, starts GENSEC/SPNEGO, frees the next FIFO slot, stores the new key, and advances next_idx before accept_gss_ticket().

Attacker outcome: An unauthenticated DNS client can churn unique TKEY GSSAPI names; Samba allocates GENSEC state and stores each key in a 128-entry FIFO before GSS success, leaving failed entries resident and evicting legitimate update keys.

Counterevidence: Only GSS TKEY algorithms reach allocation, the global FIFO caps retained entries, and runtime impact depends on DNS exposure, rate controls, and GENSEC allocation cost.

Remediation summary: Delay FIFO insertion until authentication succeeds or needs continuation, remove failed negotiations, and add per-client quotas/expiry for in-flight TKEY state.

#### Remediation

Delay FIFO insertion until authentication succeeds or needs continuation, remove failed negotiations, and add per-client quotas/expiry for in-flight TKEY state. Add regression coverage that exercises the attacker-controlled input at the listed entry point and asserts the validation, authorization, containment, or size check occurs before the dangerous sink.


| Severity | medium |
| Confidence | high |
| Confidence rationale | Static source tracing identifies the attacker input, broken control, and sink in repository code. Remaining uncertainty: No DNS service proof was attempted. |
Comment 1 Douglas Bagnall 2026-06-14 06:11:19 UTC
> An unauthenticated DNS client can churn unique TKEY GSSAPI names

I was under the impression that only authenticated clients could register TKEY names. (This affects the severity of bug 16083).
Comment 2 Volker Lendecke 2026-06-17 12:40:00 UTC
Created attachment 19016 [details]
Patch
Comment 3 Douglas Bagnall 2026-06-17 23:46:31 UTC
I guess this is

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L 5.3

anonymous DoS, setting the availability impact to "low" instead of "high".

Although we could argue for a non-security release, we perhaps should release it at the same time as bug 16083.
Comment 4 Douglas Bagnall 2026-07-08 23:10:17 UTC
Created attachment 19075 [details]
advisory v1
Comment 5 Douglas Bagnall 2026-07-08 23:15:01 UTC
master patch applies to 4.22, 4.23, 4.24.

It needs a bit of work for 4.18 and before.
Comment 6 Douglas Bagnall 2026-07-09 01:48:14 UTC
Also reported by Tristan Mandani:

DNS Pre-Auth TKEY Session Flooding and Latent OOB Access
========================================================
CVSS 3.1: 7.5 (AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H)
CWE: CWE-770 (Allocation of Resources Without Limits or Throttling)
Auth: None (pre-auth)
Version: Samba 4.24.3 and prior, master (2026-06-25)

File: source4/dns_server/dns_query.c, lines 740-744, and dns_crypto.c, line 80

Root Cause:

The Samba internal DNS server stores GSSAPI TKEY session keys in a
fixed-size ring buffer of 128 entries (TKEY_BUFFER_SIZE). There is no
rate limiting and no authentication requirement for TKEY creation. An
unauthenticated attacker can send 128 TKEY requests to flush all
legitimate GSS-TSIG session keys. Each request also allocates a full
GENSEC/KRB5 context for resource exhaustion.

    #define TKEY_BUFFER_SIZE 128

    // dns_query.c:740-744 - no auth, no rate limit
    tkey_store->entries[tkey_store->next_idx] = new_tkey;
    tkey_store->next_idx = (tkey_store->next_idx + 1) % TKEY_BUFFER_SIZE;

Additionally, dns_find_tkey() iterates using the hardcoded constant
TKEY_BUFFER_SIZE instead of store->size, creating a latent OOB read
if the store size were ever changed at runtime.

Data Flow:

  Unauthenticated attacker sends 128 GSSAPI TKEY creation requests
  -> each overwrites a ring buffer slot, no auth check
  -> all legitimate GSS-TSIG session keys are flushed
  -> authenticated DNS updates fail for all clients
  -> each GENSEC/KRB5 context allocation also exhausts memory

Impact:

Pre-auth denial of service: any network attacker can break authenticated
DNS for the entire AD domain by flushing the TKEY store. Sustained
flooding exhausts memory via GENSEC/KRB5 context allocations.

Lab verified: code trace confirmed pre-auth path and ring buffer eviction.
Comment 7 Douglas Bagnall 2026-07-09 01:52:46 UTC
Tristan suggests "AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H" (7.5) while we have settled on ".../A:L" (5.3) because availability recovers once the attack stops (for new TKEY registrations).  But whatever.

He also emphasises the memory leak that I think we fix but which wasn't in the original report.
Comment 8 Douglas Bagnall 2026-07-15 00:12:44 UTC
Created attachment 19096 [details]
advisory v2 (adding Tristan credit)
Comment 9 Björn Jacke 2026-07-17 13:43:36 UTC
adding vendors here.

scheduled release 2026-07-28 10:00 UTC.
Comment 10 Samba QA Contact 2026-07-28 10:24:50 UTC
This bug was referenced in samba v4-23-stable (Release samba-4.23.10):

51a7e0731ff4be22b47f3d885909d0fe11ae83fb
9f9981bf09150884d617fd4e19ea7dc5da785f92
Comment 11 Samba QA Contact 2026-07-28 10:25:48 UTC
This bug was referenced in samba v4-24-stable (Release samba-4.24.5):

3d933500625e97b94831ff3378fdf83359e9b49f
5d09d812f2dd86ac94ca4185bd72dc03f82ef251
Comment 12 Samba QA Contact 2026-07-28 10:26:13 UTC
This bug was referenced in samba v4-22-stable (Release samba-4.22.11):

77657a84ba3e29f6cdd490df80496862de5c8368
6e89df6cfd804b042ebcd693a025b522c997995b
Comment 13 Samba QA Contact 2026-07-28 10:50:01 UTC
This bug was referenced in samba v4-22-test:

77657a84ba3e29f6cdd490df80496862de5c8368
6e89df6cfd804b042ebcd693a025b522c997995b
Comment 14 Samba QA Contact 2026-07-28 12:15:37 UTC
This bug was referenced in samba v4-24-test:

17f202d039c2ae584d8175e5e9d9b29fb8d5ec9d
0d9ca2c5fcb799d0c8252bcad6c66e78cd4facc3
Comment 15 Samba QA Contact 2026-07-28 12:27:36 UTC
This bug was referenced in samba v4-23-test:

3f26fb6935774386df6e4d36fe93cda8cd7fb988
c83f5f8aff89f2ce1ab10dcbabc539c7551d9bce
Comment 16 Samba QA Contact 2026-07-28 14:41:34 UTC
This bug was referenced in samba v4-24-test:

3d933500625e97b94831ff3378fdf83359e9b49f
5d09d812f2dd86ac94ca4185bd72dc03f82ef251
Comment 17 Samba QA Contact 2026-07-28 14:44:17 UTC
This bug was referenced in samba v4-23-test:

51a7e0731ff4be22b47f3d885909d0fe11ae83fb
9f9981bf09150884d617fd4e19ea7dc5da785f92
Comment 18 Samba QA Contact 2026-07-28 17:03:28 UTC
This bug was referenced in samba master:

45cd1e5c9e92232e8d49a4b9429f0b184eb01299
9221601c43318414c5725a0845d888335e5b8197
Comment 19 Samba QA Contact 2026-08-03 19:36:46 UTC
This bug was referenced in samba v4-23-stable (Release samba-4.23.11):

3f26fb6935774386df6e4d36fe93cda8cd7fb988
c83f5f8aff89f2ce1ab10dcbabc539c7551d9bce
Comment 20 Samba QA Contact 2026-08-13 14:31:44 UTC
This bug was referenced in samba v4-24-stable (Release samba-4.24.6):

17f202d039c2ae584d8175e5e9d9b29fb8d5ec9d
0d9ca2c5fcb799d0c8252bcad6c66e78cd4facc3