On Mon, Nov 22 2021, Florian Obser <[email protected]> wrote:
> On 2021-11-21 21:34 +01, Jeremie Courreges-Anglas <[email protected]> wrote:
>> On Sat, Nov 20 2021, Florian Obser <[email protected]> wrote:
>>> On 2021-11-20 17:05 +01, Jeremie Courreges-Anglas <[email protected]> wrote:
>
>>> do you remember why you check for !RES_USE_DNSSEC?
>>> I'd like to leave it out.
>>
>> First, here's my understanding of RES_USE_DNSSEC: it's supposed to
>> activate EDNS and set the DO bit.  The server is then supposed to reply
>> with AD set only if the data has been validated (with or without
>> DNSSEC), and possibly append add DNSSEC data if available.
>
> I didn't go throught the 3000+ pages of DNS RFC but I don't see a way
> an RFC says AD MUST be set withouth performing DNSSEC validation. That
> just doesn't make sense.

Reading 4035 I think there's provision for setting the AD bit on replies
if the client asked with AD=1 and the server considers the data
authentic for reasons other than DNSSEC (the server being also
authoritative for the zone, or trusting the authoritative servers and
the network path between them).

https://datatracker.ietf.org/doc/html/rfc4035#section-3.1.6

Anyway, this is a detail that is not very relevant for the current
discussion.

> So DO requests that the resolver performes DNSSEC validation **AND**
> informs us about the outcome by setting the AD flag and giving us DNSSEC
> data (i.e. RRSIGs most of the time). Now, that data is not actually
> helping the stub (asr) because it can't build a chain of trust without
> querying for a bunch of more data, and well, having a trust anchor configured.
>
> So this is why setting AD in queries was introduced in 6840, I want to
> know that DNSSEC validation was performed, but I don't want all the
> (for me) useless junk.

That's https://datatracker.ietf.org/doc/html/rfc6840#section-5.7

>> Since I didn't know the semantics of both setting AD and DO in a query
>> (I would expect such semantics to be sane) I wrote those more
>> conservative checks instead.  Does this make sense?  If so, maybe
>> a comment would help?

https://datatracker.ietf.org/doc/html/rfc6840#section-5.8 says

  [...] validating resolvers SHOULD only set the AD bit when a response
  both meets the conditions listed in Section 3.2.3 of [RFC4035], and
  the request contained either a set DO bit or a set AD bit.

"Either".  This kinda points to a conservative approach, but...

> Everything half way decent handles AD + DO set at the same time
> correctly. All the quad-x public resolvers do, as well as bind, knot,
> powerdns-recursor and unbound.
>
> The result is the same as if only DO was set, you get AD set in the
> answer and the junk DNSSEC data. Btw. dig(1) sets AD per default on
> queries and does so when running with +dnssec, too.

... thanks for checking.

> RFC 8906 says that there are servers out there that choke on AD=1 in
> queries. We shouldn't care:
> 1) we enable trust-ad per default for localhost. If someone runs
> something this broken on localhost they need to fix their system
> 2) If the operator of the system sets options trust-ad in resolv.conf
> they hopefully know what they are doing. If their nameserver(s) are this
> broken they shouldn't (and wouldn't) set trust-ad in the first place.
> So this is a non-issue and just complicates the code.
>
>>
>>      /* Set the AD flag unless we already plan to set the DNSSEC DO bit. */
>>      if ((ac->ac_options & RES_TRUSTAD) &&
>>          !(ac->ac_options & RES_USE_DNSSEC))
>>
>
> With that said, I'd really prefer to leave !RES_USE_DNSSEC out, it is
> only a complication. But if you insist, I'll accept it.

You convinced me, I will simplify the checks.

> [...]
>
>>> +Authentic Data (AD) flag in the answer can only be trusted if the
>>> +nameserver itself is trusted and the network path is trusted.
>>> +Generally this is not the case and the AD flag is cleared in the answer.
>>> +The
>>> +.Cm trust-ad
>>> +flag lets the system administrator indicate that the nameserver and the
>>> +network path are trusted.
>>> +Nameservers on localhost can be trusted and
>>> +.Cm trust-ad is enabled per default.
>>
>> Already mentioned above, this last sentence doesn't really describe the
>> precise behavior you proposa.  We *could* have a mix of localhost and
>> non-localhost servers in resolv.conf, and use/trust AD=1 only for
>> localhost servers. But the automatic detection code you wrote enables
>
> [For the archives, in case someone wants to implement this:
>
> yeah, you kinda can't. On the one hand we don't have per-nameserver
> options, they are global. So if you do options trust-ad this applies to
> all nameservers listed. No way around that.
>
> Now, about localhost. If we have a mix of nameserver lines in
> /etc/resolv.conf, some localhost, some not we run into the problem that
> query packets are not rebuild per-server. So if the first one -
> localhost - doesn't respond, we are sending the same query to the 2nd
> one. Again with AD=1.
> So instead of clearing AD depending on
> RES_TRUSTAD being set we could clear AD if the answer is not comming
> from localhost. But, we are sending an AD=1 query to a server that might
> choke on it (see RFC 89060) and nobody said we can do this by setting
> options trust-ad. I wouldn't want that behaviour on may laptop that
> roams to crappy networks all the time.]

Indeed if we wanted to set AD=1 only for specific name server, we would
have to teach asr to rebuild the query depending on the NS.  I don't
consider this undoable for someone motivated enough.

>> trust-ad if resolv.conf(5) *only lists localhost entries*.  Which is
>> perfectly fine as far as I'm concerned, and lead to my first proposal:
>>
>
> Indeed.
>
>>   +It is enabled by default if
>>   +.Nm resolv.conf
>>   +only lists nameservers on localhost.
>>
>> Here's an updated diff with the proposals mentioned.
>
> OK florian@, I also got a testing & OK phessler off-list.

Thanks, let's put this in.

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to