]> git.ipfire.org Git - thirdparty/bind9.git/commit
Switch UDP fetches to TCP on the first response with a wrong query id 12023/head
authorOndřej Surý <ondrej@isc.org>
Thu, 14 May 2026 10:20:19 +0000 (12:20 +0200)
committerOndřej Surý <ondrej@isc.org>
Thu, 14 May 2026 13:56:18 +0000 (15:56 +0200)
commit11bca1051f6ef6658b3602c8d72a2f35abdbdd93
tree72ff24cc7b79979c021c1533488edff035fa5010
parent29f0b07e8ca1929df7fa3719bce68b59eef7e433
Switch UDP fetches to TCP on the first response with a wrong query id

Until now, the dispatcher silently dropped UDP responses from the
expected peer that carried the wrong DNS message id and kept listening
for the correct id to arrive within the read timeout.  An off-path
attacker who knows the destination address and source port of an
outgoing fetch could exploit that quiet retry window to flood the
resolver with guessed responses; with a gigabit link the per-query
success probability grows linearly with the number of guesses that
arrive before the legitimate answer or the timeout.

Treat any such mismatch as a possible spoofing attempt and let the
resolver immediately retry the same query over TCP, the same control
path the truncation handler already uses.

Add a resolver statistics counter - exposed as 'queries retried over TCP
after a response with mismatched query id' in rndc stats and
'MismatchTCP' in the statistics channel

Assisted-by: Claude:claude-opus-4-7
12 files changed:
bin/named/statschannel.c
bin/tests/system/mismatchtcp/ans2/ans.py [new file with mode: 0644]
bin/tests/system/mismatchtcp/ans2/example.db [new file with mode: 0644]
bin/tests/system/mismatchtcp/ns1/named.conf.j2 [new file with mode: 0644]
bin/tests/system/mismatchtcp/ns1/root.db [new file with mode: 0644]
bin/tests/system/mismatchtcp/tests_mismatchtcp.py [new file with mode: 0644]
lib/dns/dispatch.c
lib/dns/include/dns/stats.h
lib/dns/resolver.c
lib/isc/include/isc/result.h
lib/isc/result.c
tests/dns/dispatch_test.c