Labs / Network Security / Keys, signed names & mail

Lab 3 of 3 · Keys, signed names & mail

DNSSEC validation: follow the chain of trust

Follow DNSSEC signatures from an answer up to the root, and catch a forged one.

Start this lab 6 steps

The idea

A plain DNS answer is a name and an address, with nothing to show who wrote it. DNSSEC signs every answer, and each zone's key is vouched for by the zone above, up to the root, whose key your device already holds. A forged answer breaks the chain somewhere, and a Recursive resolver that checks says so.

Two answers for one name
Two answers for one name
Reading an RRSIG
Reading an RRSIG
From the laptop's anchor to the address
From the laptop's anchor to the address
Three verdicts, three answers
Three verdicts, three answers
The check runs on the laptop
The check runs on the laptop
A signature covers a span of days
A signature covers a span of days

Steps

  1. The café answers for the bank

    Petra is in a café, on its Wi-Fi, about to check her account at Fernbank Credit Union, online.fernbank.lab. Her laptop, guestLaptop, joined the café's Wi-Fi hotspot, hotspot, and took its settings from it, so the hotspot is also her Recursive resolver: every name she looks up, it answers.

    This hotspot cheats. For every name but one it asks publicResolver, a big public resolver, and passes the answer on. For online.fernbank.lab it answers itself, with its own address, where it runs a copy of the bank's sign-in page.

    Look up the bank's name the way the laptop does, open the page, then ask publicResolver directly, 10.53.2.53.

    guestLaptop:~# dig online.fernbank.lab
    guestLaptop:~# curl -sS -m 3 http://online.fernbank.lab/
    guestLaptop:~# dig @10.53.2.53 online.fernbank.lab
  2. Signatures ride with the records

    A zone is the part of the name tree one set of servers answers for: fernbank.lab sits under lab, which sits under the root.

    fernbank.lab is a signed zone. The bank's DNS provider, dnsHost, keeps a key pair for it, and next to every set of records it publishes an RRSIG: a signature made with the private key. A record and its signature travel together, so a resolver can check one against the other.

    The public key is published too, in the same zone, as a DNSKEY record. A signed zone usually has two.

    The zone-signing key, ZSK, signs the zone's records. The key-signing key, KSK, signs only the DNSKEY set itself. Why two keys becomes clear in the next step.

    Ask dnsHost, 10.53.2.20, for the bank's address with its signature, then for fernbank.lab's keys.

    guestLaptop:~# dig +dnssec +noall +answer @10.53.2.20 online.fernbank.lab
    guestLaptop:~# dig +multi +noall +answer @10.53.2.20 DNSKEY fernbank.lab
  3. Who vouches for the key

    A key needs someone to vouch for it, and in DNS that's the parent zone. fernbank.lab sits under lab, run by tldNs.

    When the bank signed up for DNSSEC, its provider gave lab a DS record: a SHA-256 hash of fernbank.lab's KSK. lab publishes it, signed with lab's own keys.

    The same holds one level up: the root zone, on rootNs, publishes a DS for lab's KSK. Nobody vouches for the root's key, so every validator, a resolver that checks signatures, ships with the root's DS built in, a trust anchor. Real systems get theirs from the operating system, the way a browser gets its trusted certificates.

    Ask tldNs, 10.53.2.11, for the DS of fernbank.lab, then hash fernbank.lab's keys yourself on dnsHost with dnssec-dsfromkey and compare. Last, read the laptop's trust anchor.

    guestLaptop:~# dig +dnssec +noall +answer @10.53.2.11 DS fernbank.lab
    dnsHost:~# dnssec-dsfromkey -2 -f /etc/bind/zones/fernbank.lab.zone fernbank.lab
    guestLaptop:~# cat /etc/bind/bind.keys
  4. Secure, insecure, bogus

    publicResolver is a validating resolver: for every answer it walks the chain in the drawing, from the trust anchor down: the root's DS for lab, then the links you checked by hand. Each answer ends up in one of three states.

    Secure: every link checked out. The resolver sets ad and answers, as it did for the bank's name.

    Insecure: the zone isn't signed, and the zone above proves it. Most of the world's domains are still unsigned, so a validator must answer for them: it does, without ad.

    Bogus: a link fails, a signature that doesn't fit, one that ran out, a DS with no matching key. The resolver answers SERVFAIL and gives no address at all.

    tidetimes.lab, a tide-tables site on the same dnsHost, never signed up for DNSSEC. Ask publicResolver for www.tidetimes.lab, then for tidetimes.lab's DS, with signatures.

    guestLaptop:~# dig @10.53.2.53 www.tidetimes.lab
    guestLaptop:~# dig +dnssec @10.53.2.53 DS tidetimes.lab
  5. Check it on the laptop

    ad is one bit in the answer. It says "publicResolver checked this", and it travels to the laptop with no protection at all, through the hotspot. The hotspot strips it from what it passes on, and it could set it on its forgery instead.

    A validator's verdict is only as good as the path back from it, so do the checking where you are. delv looks a name up through the laptop's resolver, here the hotspot, asking for every signature, DNSKEY and DS along the way, and checks the chain itself from bind.keys. Whatever the hotspot says, it can't forge lab's DS.

    Look up the bank's name with delv through the hotspot, then through publicResolver.

    guestLaptop:~# delv online.fernbank.lab
    guestLaptop:~# delv @10.53.2.53 online.fernbank.lab
  6. Signatures run out

    A month later, publicResolver stops finding the bank. Nothing in the zone changed: dnsHost's signing job stopped, and the last signatures it made have since run out.

    Signatures have an end date for a reason: without one, a recorded answer would stay valid for ever, even after the bank moved. So a signed zone must be signed again, again and again, and when that stops, the zone goes bogus on every validating resolver at once. It's one of the most common DNSSEC outages.

    Ask publicResolver for the bank's address, then ask dnsHost directly with the signature, and read its dates. Then sign the zone again on dnsHost, reload it, and have publicResolver drop the failure it remembers.

    guestLaptop:~# dig @10.53.2.53 online.fernbank.lab
    guestLaptop:~# dig +dnssec +noall +answer @10.53.2.20 online.fernbank.lab
    dnsHost:~# dnssec-signzone -K /etc/bind/keys -o fernbank.lab /etc/bind/zones/fernbank.lab.zone
    dnsHost:~# rndc reload fernbank.lab
    publicResolver:~# unbound-control flush_bogus
    guestLaptop:~# dig @10.53.2.53 online.fernbank.lab

Run these steps on real machines

Keep reading

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab