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

feat: allow localhost http endpoints #28

Merged
merged 2 commits into from
Jan 8, 2025
Merged

feat: allow localhost http endpoints #28

merged 2 commits into from
Jan 8, 2025

Conversation

aschmahmann
Copy link
Contributor

Allows using HTTP in addition to HTTPS as a DNS endpoint. This makes self-hosting DNS resolvers much easier as there's no need to get a domain name, TLS certs from a CA, etc. One particular example of this is making it easier for folks to self-host local non-ICANN resolvers such as for ENS, Handshake, OpenNIC, etc.

Related to ipfs/boxo#645

@marten-seemann
Copy link
Contributor

This is insecure and should not be implemented. It is in direct violation of RFC 8484: DoH is DNS over HTTPS, not DNS over HTTP.

@aschmahmann
Copy link
Contributor Author

aschmahmann commented Dec 24, 2024

This is insecure

Insecure is not a "thing" by itself. Security is relative to a security model. For example, in the context of web browsers (generally a security-sensitive space) a context is considered "secure" under a particular security model (see https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts). That model includes HTTPS with TLS certificates bound to domain names and certified by trusted Certificate Authorities, but it also includes HTTP requests to locahost, 127.0.0.1, etc.

Is there a particular security concern / model that you had in mind?

It is in direct violation of RFC 8484: DoH is DNS over HTTPS, not DNS over HTTP.

That's true, and yet due to the inconvenience of this coupled with the fact that it is trivial to support DNS-over-HTTP in addition to DNS-over-HTTPS other applications used widely in the DNS space have chosen to support this.

For example: CoreDNS

  • Server code allows this support plain HTTP for DoH coredns/coredns#4997. The motivation here seems to be that requiring TLS termination to be combined with the DNS over HTTP logic is overly restrictive and was causing problems for people who wanted custom TLS termination
  • Client code allows this [DoH] Make protocol parsing more flexible coredns/coredns#5762. The motivation in that PR seems to be that people sometimes wanted to be able to use HTTP instead of HTTPS, for example wanting to have much simpler tests without needing self-generated certs and custom TLS verification

For example: Bind9 / dig (maintained / under the umbrella of https://www.isc.org/)

I didn't spend as much time digging in there, but dig has DNS over plain HTTP mode and that PR to bind9 calls out support for DNS over plain HTTP

In short, it seems like the RFC attempted to be very prescriptive about using HTTPS, but since with many stacks it's fairly straightforward to support both HTTP and HTTPS and there's utility in supporting HTTP a number of groups have chosen to ignore the RFC and support both HTTP and HTTPS anyway.

and should not be implemented

So to the matter at hand. Why not?

  1. It would make testing and debugging much nicer
  2. It would make it much easier for people to spin up their own DoH servers on localhost that could be plugged into applications
  3. Others major players in the DNS library space have gone down this route, why should this library be more restrictive?
  4. It's a 1 line change

@lidel lidel changed the title feat: allow http endpoints feat: allow localhost http endpoints Jan 7, 2025
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

Hm.. my understanding of motivation behind this PR is to allow use of self-hosted custom resolver.

Such things, to make sense, have to run on localhost, and do not go unencrypted over network. Approach similar to how web browsers mark localhost as secure context, and expose windo.crypto and other Web APIs even when the root document was loaded from local server without TLS.

Agree we should not allow unencrypted HTTP outside of localhost – misconfigurations happen and RFC Marten mentioned is stric ton purpose, to avoid situation where people's DNS queries are sent in cleartext over network.

As a pragmatic compromise, pushed 18cfb6d with refactor that limits this PR to localhost, following spirit of secure contexts in browsers and https://datatracker.ietf.org/doc/html/draft-west-let-localhost-be-localhost

If non-localhost http:// URL is used, NewResolver returns an error.
Added tests to ensure this behavior does not regress.

@lidel lidel merged commit 68cc2ce into master Jan 8, 2025
9 checks passed
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.

4 participants