Ninlil negotiates GSS-TSIG keys over TKEY and verifies and signs gss-tsig messages #80

Open
opened 2026-10-31 12:42:02 -04:00 by claude · 0 comments
Owner
  • Draft: INT-11
  • Priority: high (core of AD secure updates)
  • Agent: protocol-coder
  • Depends on: #78, #79
  • Decisions: none

Why

Windows DCs and clients, and nsupdate -g / samba_dnsupdate, use RFC 3645.

What changes

  • A TKEY query resolver, before DynamicUpdateQueryResolver in resolver order (src/dotnet/src/Ninlil.Dns.Server.Authoritative/Extension/ServiceCollectionAuthoritativeExtension.cs:98-100):
    • QTYPE TKEY, mode 3. The token is passed to the GSS context named by the TKEY owner name (RFC 3645 §3.1).
    • The reply carries TKEY with the output token, as RFC 3645 §3.1.3 requires.
    • The final reply is signed with gss-tsig.
    • Mode 5 deletes the context.
  • A context store: a singleton, in memory, keyed by key name.
    • Expiry is the earlier of the TKEY expiration and the Kerberos ticket end.
    • The number of contexts is capped, the oldest is evicted, and half-open contexts expire after 60 s.
  • TsigService accepts algorithm gss-tsig (RFC 3645 §2) for a key name in the context store. It verifies with VerifyMic over the digest input of RFC 8945 §4.3 and signs replies with GetMic. Check during #79 whether current Windows clients send another algorithm name.
  • DnsTransactionSignature (src/dotnet/src/Ninlil.Dns.Server.Core/Resolution/DnsTransactionSignature.cs:26) gains string Principal. It is null for HMAC keys.
  • Options: a nested Gss class inside TsigServiceOptions (src/dotnet/src/Ninlil.Dns.Server.Tsig/Options/TsigServiceOptions.cs:13), with no SectionName of its own. Properties: Enable (false), KeytabPath, ServicePrincipalName, MaxContexts. Update ENVIRONMENT.md and recount the totals.
  • Transport: TKEY over TCP and UDP. Large tokens make clients use TCP; nothing to force.

Acceptance

  • Unit test (fails first): with a fake IGssSecurityContext, a TKEY mode-3 query gets a reply with the fake's output token, and a following UPDATE signed with gss-tsig reaches the resolver with IsVerified and Principal set.
  • Unit test: a wrong MIC gives NOTAUTH/BADSIG, signed as RFC 8945 §5.3.2 says.
  • Unit test: mode 5 removes the context.
  • Integration test (RequiresDocker, KDC from #79): nsupdate -g from a container with a kinit'd user negotiates and sends an update. Until #82 the update gets REFUSED; the TKEY exchange succeeds.
  • src/dotnet/tests/Ninlil.Dns.Server.Tsig.Tests and src/dotnet/tests/Ninlil.Dns.Server.Authoritative.Tests pass.
  • The whole solution passes (Ninlil.Dns.Server.Core changed).

Source

RFC 2930 §4.2; RFC 3645 §2, §3.1, §3.2 and §4; RFC 8945 §4.3 and §5.3.2.

- **Draft:** INT-11 - **Priority:** high (core of AD secure updates) - **Agent:** protocol-coder - **Depends on:** #78, #79 - **Decisions:** none ### Why Windows DCs and clients, and `nsupdate -g` / `samba_dnsupdate`, use RFC 3645. ### What changes - A TKEY query resolver, before `DynamicUpdateQueryResolver` in resolver order (`src/dotnet/src/Ninlil.Dns.Server.Authoritative/Extension/ServiceCollectionAuthoritativeExtension.cs:98-100`): - QTYPE TKEY, mode 3. The token is passed to the GSS context named by the TKEY owner name (RFC 3645 §3.1). - The reply carries TKEY with the output token, as RFC 3645 §3.1.3 requires. - The final reply is signed with gss-tsig. - Mode 5 deletes the context. - A context store: a singleton, in memory, keyed by key name. - Expiry is the earlier of the TKEY expiration and the Kerberos ticket end. - The number of contexts is capped, the oldest is evicted, and half-open contexts expire after 60 s. - `TsigService` accepts algorithm `gss-tsig` (RFC 3645 §2) for a key name in the context store. It verifies with `VerifyMic` over the digest input of RFC 8945 §4.3 and signs replies with `GetMic`. Check during #79 whether current Windows clients send another algorithm name. - `DnsTransactionSignature` (`src/dotnet/src/Ninlil.Dns.Server.Core/Resolution/DnsTransactionSignature.cs:26`) gains `string Principal`. It is null for HMAC keys. - Options: a nested `Gss` class inside `TsigServiceOptions` (`src/dotnet/src/Ninlil.Dns.Server.Tsig/Options/TsigServiceOptions.cs:13`), with no `SectionName` of its own. Properties: `Enable` (false), `KeytabPath`, `ServicePrincipalName`, `MaxContexts`. Update `ENVIRONMENT.md` and recount the totals. - Transport: TKEY over TCP and UDP. Large tokens make clients use TCP; nothing to force. ### Acceptance - [ ] Unit test (fails first): with a fake `IGssSecurityContext`, a TKEY mode-3 query gets a reply with the fake's output token, and a following UPDATE signed with gss-tsig reaches the resolver with `IsVerified` and `Principal` set. - [ ] Unit test: a wrong MIC gives NOTAUTH/BADSIG, signed as RFC 8945 §5.3.2 says. - [ ] Unit test: mode 5 removes the context. - [ ] Integration test (RequiresDocker, KDC from #79): `nsupdate -g` from a container with a kinit'd user negotiates and sends an update. Until #82 the update gets REFUSED; the TKEY exchange succeeds. - [ ] `src/dotnet/tests/Ninlil.Dns.Server.Tsig.Tests` and `src/dotnet/tests/Ninlil.Dns.Server.Authoritative.Tests` pass. - [ ] The whole solution passes (`Ninlil.Dns.Server.Core` changed). ### Source RFC 2930 §4.2; RFC 3645 §2, §3.1, §3.2 and §4; RFC 8945 §4.3 and §5.3.2.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
lantea-one/ninlil#80
No description provided.