You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The above if statement shouldn't be changed, but I think there's an easy way to fix the failure that prompted this issue being raised by MiniDNS relying on the DNS resolver server to perform DNSSEC-validated CNAME-chasing.
This verification if statement fails when TLSA records are provisioned with CNAME or DNAME aliases.
Such a DNS response could return records where:
for the record.name.equals(req) the record.type is Record.TYPE.CNAME
for all Record.TYPE.TLSA records, the record.name would not equal req.
Verification seems to be missing:
DNSSEC-secure CNAME-chasing of the TLSA records, and
DNSSEC-secure CNAME-expansion of the TLS server name (TLSA base domain).
This spec was further updated and explained by changing the original DANE definition of the TLSA base domain, and by requiring its CNAME-expansion in the DANE Update RFC: https://datatracker.ietf.org/doc/html/rfc7671#section-7
These gaps were flagged by @vdukhovni as the second bullet point in issue #105.
1. Easy fix by relying on DNS resolver to do CNAME-chasing of the TLSA records
If MiniDNS can't do it's own CNAME-chasing, you can typically rely on DNS resolvers to do it, and to return responses that contain both CNAME records as well as target records, and I think CNAME-chase records typically come first in the list.
In this code section, all records in this particular response have already been DNSSEC-validated, so woulc contain a DNSSEC-secure CNAME chain.
Some initial improvement for CNAME-chasing of TLSA records probably can be easily implemented by adding else ifafter the above if statement inside the loop, along the lines of (apologies, I'm not a developer so my syntax is probably completely wrong):
If MiniDNS can't do it's own CNAME-chasing, you can typically rely on DNS resolvers to do it, and to return responses that contain both CNAME records as well as target records, and I think CNAME-chase records typically come first in the list.
The ordering of RRs within a DNS response section (answer, authority or additional) has no significance, and one cannot (must not) rely on the records appearing in any particular order, even the records in a single RRset (same owner, class, type and covered type if RRSIG) need not be consecutive.
The simplest way to know whether a CNAME chain leading to a final answer is secure is to obtain the answer from a local validating resolver, which will only set the AD bit if the entire chain is correctly signed. This includes possible DNAME expansion, where the synthesised CNAMEs are not directly signed, but the DNSSEC signatures on the relevant DNAME RRs are sufficient to validate the associated CNAME.
which will only set the AD bit if the entire chain is correctly signed.
AD or AA bit.
I'm not quite clear on how MiniDNS currently implements the isAuthenticData() function. There seems to be a TODO: comment mentioning checking for AD bit in there.
Does isAuthenticData() actually ensure DNSSEC validation, or is it just a placeholder for a future implementation?
I'm really interested in being able to plug MiniDNS into a trusted and secure DNS resolver that does all the DNSSEC verification as per @vdukhovni's advice, and then MiniDNS just checks for AD or AA query response flags, like it says in the TODO comment.
Though I'm not sure if there's an API that can tell MiniDNS that the resolver is secure, or if it's a responsibility of the calling application to manage the secure resolvers that appear and disappear when a mobile system moves between networks (e.g. Android Private DNS).
An RFC-compliant validating resolver only sets the AD bit when all the data in the answer section (if non-empty) and/or authority section (for NODATA, NXDOMAIN or YXDOMAIN responses) is DNSSEC-validated. If there's a chain of CNAMEs leading to an answer all the CNAMEs must be validated (or be synthesised from a signed DNAME).
There is not presently a standard API or protocol for determining whether the stub resolver library is talking to a "local" resolver. The only step in that direction I am aware of is that non-ancient glibc versions by default ignore the AD bit unless the system administrator added "options trust-ad" to the resolv.conf file, which they should only do when the network path to the configured full-service resolver(s) is trusted (loopback or internal LAN where risk of packet injection is believed to be low, but ideally only loopback).
Just for the record: quite some people contacted me about this problem, so this should be addressed in one or another way, and not left hanging. Basically, DANE is often not usable without this being resolved.
Check whether the response is validated (if not already done), ignore responses with AD==0.
De-alias the DNS response (separate prior loop over the response RRs)
Look for any CNAME RRs that match the current owner name (initially the req value set at the top).
If one found set "req" to its target and restart the loop at the beginning of the response RR list.
If no matching CNAME RR is found the latest "req" is the one for which TLSA records are needed.
Now perform a second loop over the records to find all the relevant TLSA RRs (the ones with owner == req)
Then instead of validating the cert chain one TLSA RR at a time, pass all the RRs to the verification code.
Sort them, putting all DANE-EE(3) records first and all other records after these.
In the verification logic, first check all DANE-EE(3) records against just the leaf cert.
If the leaf (a.k.a. end-entity or EE) cert matches one of the DANE-EE(3) RRs and (depending on settings) the hostname optionally also matches.
Success
Otherwise, validation needs to be based on a trust-anchor match, so a chain needs to be constructed.
Reject the cert if the hostname does not match, it is only optional with DANE-EE(3) in some applications (e.g. SMTP, but not HTTP, so not optional unless the caller says it is by passing a suitable flag, ...).
If the EE cert matches a PKIX-EE(1) record, note this fact.
Check signatures, dates, ... while building the chain.
If while constructing the chain, one of the issuer certs (perhaps just the enclosed public key) matches a DANE-TA(2) record
Success
If one of the issuer certs (non-EE) matches a PKIX-TA(2) record, note the match
If any of the TLSA records are PKIX-EE(1) or PKIX-TA(0), and a WebPKI trust-anchor is reached (root CA from the local trust store or equivalent).
The chain is complete, but only valid if a match for PKIX-EE(1) or PKIX-TA(0) was noted along the way.
Check whether the response is validated (if not already done), ignore responses with AD==0 and AA==0.
Yes, if the iterative resolver returns returns (some authoritative answers) it may be appropriate to trust those, especially if that iterative resolver is a mixed-mode nameserver that is also authoritative for various relevant zones.
Activity
Delicates commentedon Jun 20, 2024
The above
ifstatement shouldn't be changed, but I think there's an easy way to fix the failure that prompted this issue being raised by MiniDNS relying on the DNS resolver server to perform DNSSEC-validated CNAME-chasing.This verification
ifstatement fails whenTLSArecords are provisioned withCNAMEorDNAMEaliases.Such a DNS response could return records where:
record.name.equals(req)the record.type isRecord.TYPE.CNAMERecord.TYPE.TLSArecords, therecord.namewould not equalreq.Verification seems to be missing:
TLSArecords, andThe TLSA CNAME-chasing is defined in the original DANE RFC:
https://datatracker.ietf.org/doc/html/rfc6698#appendix-A.2
This spec was further updated and explained by changing the original DANE definition of the TLSA base domain, and by requiring its CNAME-expansion in the DANE Update RFC:
https://datatracker.ietf.org/doc/html/rfc7671#section-7
These gaps were flagged by @vdukhovni as the second bullet point in issue #105.
1. Easy fix by relying on DNS resolver to do CNAME-chasing of the
TLSArecordsIf MiniDNS can't do it's own CNAME-chasing, you can typically rely on DNS resolvers to do it, and to return responses that contain both
CNAMErecords as well as target records, and I think CNAME-chase records typically come first in the list.In this code section, all records in this particular response have already been DNSSEC-validated, so woulc contain a DNSSEC-secure CNAME chain.
Some initial improvement for CNAME-chasing of TLSA records probably can be easily implemented by adding
else ifafter the aboveifstatement inside the loop, along the lines of (apologies, I'm not a developer so my syntax is probably completely wrong):It wouldn't be perfect, but it would be a step in the right direction for addressing the second point raised by Victor in issue #105.
2. Further improvement by relying on DNS resolver to do CNAME-expansion of the TLS server name (TLSA base domain)
Implementing CNAME-expansion would be a bit more complicated, but doable with one or two additional DNS queries.
hostNameArecord to check for existence of aCNAMECNAMEexists, perform CNAME-chase to determine the new CNAME-expanded base domainbaseNameforTLSA.CNAMErecord doesn't exist,baseName=hostNamebaseNameTLSAis not found, re-run DNSSEC-verified TLSA query under the originalhostNamevdukhovni commentedon Jun 20, 2024
The ordering of RRs within a DNS response section (answer, authority or additional) has no significance, and one cannot (must not) rely on the records appearing in any particular order, even the records in a single RRset (same owner, class, type and covered type if RRSIG) need not be consecutive.
The simplest way to know whether a CNAME chain leading to a final answer is
secureis to obtain the answer from a local validating resolver, which will only set the AD bit if the entire chain is correctly signed. This includes possible DNAME expansion, where the synthesised CNAMEs are not directly signed, but the DNSSEC signatures on the relevant DNAME RRs are sufficient to validate the associated CNAME.Delicates commentedon Jun 20, 2024
ADorAAbit.I'm not quite clear on how MiniDNS currently implements the isAuthenticData() function. There seems to be a TODO: comment mentioning checking for AD bit in there.
Does
isAuthenticData()actually ensure DNSSEC validation, or is it just a placeholder for a future implementation?I'm really interested in being able to plug MiniDNS into a trusted and secure DNS resolver that does all the DNSSEC verification as per @vdukhovni's advice, and then MiniDNS just checks for
ADorAAquery response flags, like it says in the TODO comment.Though I'm not sure if there's an API that can tell MiniDNS that the resolver is secure, or if it's a responsibility of the calling application to manage the secure resolvers that appear and disappear when a mobile system moves between networks (e.g. Android Private DNS).
vdukhovni commentedon Jun 20, 2024
An RFC-compliant validating resolver only sets the AD bit when all the data in the answer section (if non-empty) and/or authority section (for NODATA, NXDOMAIN or YXDOMAIN responses) is DNSSEC-validated. If there's a chain of CNAMEs leading to an answer all the CNAMEs must be validated (or be synthesised from a signed DNAME).
There is not presently a standard API or protocol for determining whether the stub resolver library is talking to a "local" resolver. The only step in that direction I am aware of is that non-ancient glibc versions by default ignore the AD bit unless the system administrator added "options trust-ad" to the
resolv.conffile, which they should only do when the network path to the configured full-service resolver(s) is trusted (loopback or internal LAN where risk of packet injection is believed to be low, but ideally only loopback).M66B commentedon Nov 29, 2024
Just for the record: quite some people contacted me about this problem, so this should be addressed in one or another way, and not left hanging. Basically, DANE is often not usable without this being resolved.
vdukhovni commentedon Nov 29, 2024
Which "this" are you expecting to be resolved?
M66B commentedon Nov 29, 2024
Changing this:
into
resolves the problem, but I'm not sure if this is the correct way to fix this regarding side effect, etc.
vdukhovni commentedon Nov 29, 2024
The correct logic is to first:
Delicates commentedon Sep 20, 2026
Small correction:
vdukhovni commentedon Sep 20, 2026
Yes, if the iterative resolver returns returns (some authoritative answers) it may be appropriate to trust those, especially if that iterative resolver is a mixed-mode nameserver that is also authoritative for various relevant zones.
[dane] Follow CNAMEs when looking up TLSA RRs