Hi Martin,

On Tue, Nov 17, 2026 at 07:34:02PM -0800, Martin Mirchev wrote:
> Hi,
> 
> Here is a small hardening fix for the resolvers, against current master
> (f16798587). The patch is attached (git format-patch).
> 
> resolv_validate_dns_response() checks the query ID, the RCODE, the question
> and the records, but not the QR bit, so a DNS message with QR=0 (a query)
> is 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 (an echo or a forwarding loop), is processed as a
> response without any answer. The sender still has to match the nameserver
> address (the socket is connected), the query ID and the question, so this
> does not make spoofing easier; it is only about not treating a query as a
> response.
> 
> The patch adds DNS_FLAG_RESPONSE and treats such messages as invalid. It
> adds reg-tests/resolvers/response_flag.vtc with a small Python DNS fixture
> (in the style of tcp_fallback.py) that sends the same A answer with and
> without the QR bit. The test fails on master (resp.status (200) == "503")
> and passes with the patch; tcp_fallback.vtc still passes. It may be
> backported to the stable branches.

Interesting, because I was pretty sure we had that test because I worked
on a similar thing a few years ago and went there to check if it was OK.
But the let's be honest, the code isn't the cleanest example out there so
it's very likely that I was confused by something else (like the REPLY
flags) and thought the check was done.

Applied now, thank you!
willy


Reply via email to