Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dnssec #429

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Dnssec #429

wants to merge 10 commits into from

Conversation

LeonardWalter
Copy link
Contributor

This is to start the process of integrating a DNSSEC validator to routedns.
This implementation is inspired by uw-ictd/DNSSEC-Validator and peterzen/goresolver, but adds concurrency and is adapted to work with the other routedns modules.

Currently, only validated DNS responses are forwarded. DNS responses that are not singed or have an invalid signature are dropped.

Example config file:

[resolvers.my-doh]
protocol = "doh"
address = "https://d.adguard-dns.com/dns-query{?dns}"

[groups.dnssec]
type = "dnssec"
resolvers = ["my-doh"]

[listeners.local-udp]
address = "127.0.0.1:9009"
protocol = "udp"
resolver = "dnssec"

Copy link
Owner

@folbricht folbricht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when a domain isn't signed? Will this fail? I'm wondering if there should be a flag or so to switch into a more permissive mode where DNSSEC responses are validated, but responses for unsigned domains are passed through.

Comment on lines 92 to 94
MsgHdr: dns.MsgHdr{
RecursionDesired: true,
},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically you don't need this as SetQuestion() below does it already (see https://github.com/miekg/dns/blob/v1.1.63/defaults.go#L35).

return err
}

for _, rr := range signedZone.Dnskey.RrSet {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getRRSet() can return nil, nil which would trigger a panic here

}

func extractRRset(r *dns.Msg) (*RRSet, error) {
result := &RRSet{RrSet: make([]dns.RR, 0)}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
result := &RRSet{RrSet: make([]dns.RR, 0)}
result := &RRSet{}

No need to initialize an empty list, you can read from and append to a nil list.

return nil, ErrNoResult
}
if r == nil || r.Rcode == dns.RcodeSuccess {
return r, err
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return r, err
return r, nil

err has already been checked and must be nil here.

Comment on lines 160 to 167
defer func() {
if r := recover(); r != nil {
Log.Warn("panic occurred",
slog.String("domainName", domainName),
slog.Any("panic", r),
)
}
}()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this? Seems more like we don't trust our own code to handle all nil pointers correctly.

Comment on lines 177 to 182
Log.Error("DS query failed",
slog.String("domainName", domainName),
"error", err,
)

return err
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than logging from within, might be better to extend the error and pass it back to the caller to handle. Something like

return fmt.Errorf("DS query failed for %q: %w", domainName, err)

Comment on lines 216 to 219
if err := g.Wait(); err != nil {
return err
}
return nil
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if err := g.Wait(); err != nil {
return err
}
return nil
return g.Wait()

Comment on lines 239 to 243
defer func() {
if err := recover(); err != nil {
Log.Error("AuthChain panic occurred", "error", err)
}
}()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, there should be a better way to deal with panics, i.e. avoid them at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants