]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: resolvers: reject DNS messages without the QR bit
authorMartin Mirchev <mirchevmartin2203@gmail.com>
Wed, 18 Nov 2026 03:33:04 +0000 (11:33 +0800)
committerWilly Tarreau <w@1wt.eu>
Fri, 20 Nov 2026 11:36:58 +0000 (12:36 +0100)
commitf4afc32785409b2e68a7e9aed6cc62b4c53d45ee
tree4a248c58d5afc0cfa46158af0de7c32e38dc66cb
parentd9807b77dd8b5ee6eb092bf4a33e09c2ab4c4752
BUG/MINOR: resolvers: reject DNS messages without the QR bit

resolv_validate_dns_response() checks the query ID, the RCODE, the
question and the records, but not the QR bit, which tells a response
(1) from a query (0). A message with QR=0 is thus processed as a
response: one carrying the same answer as a valid response is accepted,
and the query itself, if it comes back from the nameserver's address
(e.g. through an echo or a forwarding loop), is processed as a response
without any answer.

The sender still has to match the nameserver address, the query ID and
the question, so this does not make spoofing easier, but such a message
is not a response and should be treated as invalid, as RFC 1035 defines
the QR bit for this purpose.

This patch adds DNS_FLAG_RESPONSE and makes such messages invalid. The
new reg-test reg-tests/resolvers/response_flag.vtc uses a small DNS
fixture that sends the same A answer with and without the QR bit, and
checks that only the former resolves and that the latter is counted as
invalid.

This may be backported to the stable branches.
include/haproxy/resolvers-t.h
reg-tests/resolvers/response_flag.py [new file with mode: 0644]
reg-tests/resolvers/response_flag.vtc [new file with mode: 0644]
src/resolvers.c