A zone transfer over DNS-over-TLS is not lost on Windows when the client sent one more message #340

Closed
opened 2026-11-06 11:06:09 -05:00 by claude · 0 comments
Owner
  • Draft: none (follow-up found while verifying #12)
  • Priority: low
  • Agent: protocol-coder
  • Depends on: #12
  • Decisions: none

Why

  • #12 found that closing a TCP socket while the client's next message is still unread sends a reset. On Windows that reset makes the client discard the server's last reply, even though the reply had already arrived. TcpDnsListener and DnsCryptTcpListener now use LingeringSocketClose.CloseAsync when FramedDnsStreamSession.ClosedAfterDrain is true.
  • DnsOverTlsListener.HandleConnectionAsync (src/dotnet/src/Ninlil.Dns.Protocol.DnsOverTls/DnsOverTlsListener.cs, the finally that disposes sslStream and networkStream around line 329) still closes the socket through SslStream and NetworkStream(ownsSocket: true). An AXFR or IXFR over TLS whose client sent one more message can therefore lose its last message on Windows in the same way.

What changes

  • Reproduce it red first on Windows (Lofnheim). Model the test on TcpZoneTransferCloseTests in Ninlil.Dns.Protocol.Plain.Tests, over a TLS client.
  • After a drained close, shut down TLS cleanly (SslStream.ShutdownAsync), then do the lingering close on the socket before disposing. The socket must always be closed, the stopping token must be honoured and the 2 s bound kept.

Acceptance

  • The new test fails on Windows without the fix and passes with it. DnsOverTls.Tests passes on Linux and on Lofnheim.
  • A CHANGELOG line under Unreleased.
- **Draft:** none (follow-up found while verifying #12) - **Priority:** low - **Agent:** protocol-coder - **Depends on:** #12 - **Decisions:** none ### Why - #12 found that closing a TCP socket while the client's next message is still unread sends a reset. On Windows that reset makes the client discard the server's last reply, even though the reply had already arrived. `TcpDnsListener` and `DnsCryptTcpListener` now use `LingeringSocketClose.CloseAsync` when `FramedDnsStreamSession.ClosedAfterDrain` is true. - `DnsOverTlsListener.HandleConnectionAsync` (`src/dotnet/src/Ninlil.Dns.Protocol.DnsOverTls/DnsOverTlsListener.cs`, the `finally` that disposes `sslStream` and `networkStream` around line 329) still closes the socket through `SslStream` and `NetworkStream(ownsSocket: true)`. An AXFR or IXFR over TLS whose client sent one more message can therefore lose its last message on Windows in the same way. ### What changes - Reproduce it red first on Windows (Lofnheim). Model the test on `TcpZoneTransferCloseTests` in `Ninlil.Dns.Protocol.Plain.Tests`, over a TLS client. - After a drained close, shut down TLS cleanly (`SslStream.ShutdownAsync`), then do the lingering close on the socket before disposing. The socket must always be closed, the stopping token must be honoured and the 2 s bound kept. ### Acceptance - [ ] The new test fails on Windows without the fix and passes with it. DnsOverTls.Tests passes on Linux and on Lofnheim. - [ ] A CHANGELOG line under Unreleased.
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#340
No description provided.