ipfs / kubo

An IPFS implementation in Go
https://docs.ipfs.tech/how-to/command-line-quick-start/
Other
16.14k stars 3.02k forks source link

DNS.Resolvers should be used for DNS multiaddrs: /dnsaddr /dns /dns4 /dns6 #9199

Open lidel opened 2 years ago

lidel commented 2 years ago

Version

0.14.0

Bug description

DNS.Resolvers allows for setting DNS over HTTPS resolver per domain or globally (. catch-all).

Custom DNS resolver set there is:

Threat model

Peer addresses include /p2p/{libp2p-key}, which removes the surface for MITM, so no peer identity spoofing / tampering is possible.

However, a privacy/censorship concern remains. DNS resolver provided by the operating system (delegating queries to user's ISP in cleartext) may lie about IPs, or simply return no TXT records, which will block access to things like bootstrappers at /dnsaddr/bootstrap.libp2p.io/, effectively cutting off user from IPFS network.

How to reproduce

To confirm that DNS.Resolvers is used for DNSLink, but not for DNSAddr, set bootstrap to DNS-only peers AND set DNS resolver to invalid one (which should always fail):

  "Bootstrap": [
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt"
  ],
  "DNS": {
    "Resolvers": {
      ".": "https://dns.invalid/dns-query"
    }
  },

After rebooting your daemon (with fresh repo, no prior peers cached, no mdns):

What is interesting, doing manual ipfs swarm connect /dnsaddr/ipfs.aergia.eu fails as expected:

$ ipfs swarm connect /dnsaddr/ipfs.aergia.eu
Error: Post "https://dns.invalid/dns-query": dial tcp: lookup dns.invalid on 1.1.1.1:53: no such host

So.. parts are wired up (manual swarm connect), parts are not (bootstrappers).

Expected behavior

DNS.Resolvers (if defined) should be used for resolving all DNS-based multiaddrs, namely:

Related

cc https://github.com/libp2p/go-libp2p/pull/1607

matyapiro31 commented 2 years ago

My issue is very relevant, so I write here, 1:These DoH config has no fall back system. (eg: when cloudflare service is not available, I want to use another DoH service.) 2: Add DNS over TLS/QUIC support. DoQ is the safest way to get DNS. some non-ICANN service, such as OpenNIC provides only DoT.

lidel commented 2 years ago

@matyapiro31 fallback resolvers are tracked in #8173. Please fill a separate issue for TLS/QUIC transport support :pray: