Skip to content

Fully dangling NS delegations end SERVFAIL and are not flagged; ask the parent zone #406

Closed

Description

@TMHSDigital

Summary

A delegated subzone whose name servers are all gone is the most exploitable NS takeover case, and -type NS does not flag it. A recursive resolver usually answers SERVFAIL for such a name, and TakeoverHint only inspects NS records already in the result. Asking the parent zone's servers for the delegation would catch it.

Where

  • docs/ROADMAP.md:64-69 (the known limitation)
  • internal/dns/takeover.go:145-161 (TakeoverHint / dangling-NS check)

Details

ROADMAP: "A recursive resolver asked about a subzone whose every name server is gone usually answers SERVFAIL rather than the delegation, so such a name ends up inconclusive … instead of flagged." A SERVFAIL result never reaches the takeover check.

Impact

To find fully dangling delegations, users have to rescan by hand against the parent zone's authoritative server.

Suggested fix

When NS is in -type and a name ends in SERVFAIL:

  1. Look up the parent zone's name servers, with the code -axfr already uses (internal/axfr).
  2. Send them one non-recursive NS query for the name.
  3. If the referral's NS targets do not exist (NXDOMAIN through the trusted resolver), mark the name dangling-ns.

Cache the parent's servers per zone, count the queries against -rate and -max-queries, and respect -exclude. Testing this needs referral support in internal/dnsserver (ROADMAP:58-63 says referrals are not modelled yet).

Open question: how should queries to the target's own name servers be paced?

Acceptance criteria

  • A lab scenario with a fully dangling delegation is flagged dangling-ns under -type NS
  • The extra queries are paced and counted, and shown in the run-quality report
  • ROADMAP updated

Getting started


Filed by repo-audit/full-audit at dd5b156. Severity: medium. Effort: L. audit-key: enhancement|internal/dns/takeover.go|DanglingNS

Activity

  1. added
    enhancement
    area: dns
    severity: medium
    on Nov 17, 2026
  2. TMHSDigital commented on Nov 21, 2026

    @TMHSDigital
    OwnerAuthor

    Implemented in 4679596.

    What changed

    • With NS in -type, a name whose lookup ends SERVFAIL is asked of the target zone's own name servers, found with the -axfr lookup (now axfr.NameServers) once per target. The query is one NS query that does not ask for recursion (dns.AskDelegation). When the referral names name servers that do not exist (NXDOMAIN through the trusted resolver, through the existing takeover cache), the name is reported with those NS records and marked dangling-ns. Otherwise it stays inconclusive. A flagged name is not expanded by -recursive.
    • Pacing (the open question): I went with the conservative option. The name server lookups and delegation queries each take a slot from the scan's -rate limiter. They stop at -max-queries, which counts their own queries the same way -nsec-walk does, and at -max-duration. No query is sent for a name or name server that -exclude rules out. They are counted in queries_sent and in two new report fields, parent_checks and parent_queries (Stats.ParentChecks / Stats.ParentQueries in pkg/subenum, plus a line in the text breakdown).
    • internal/dnsserver now models referrals (Reply.Referral, Reply.ReferralZone, Query.Recursive). In a lab scenario, a delegation where none of the name servers has an address answers SERVFAIL to a recursive query and a referral to a non-recursive one. In lab mode the check goes to the lab server. The new Lab 9 (-simulate-zone lab9) practises this.
    • ROADMAP no longer lists the known limitation. README, labs, library, output reference, stats schema, flag table and CHANGELOG are updated.

    Verification

    • New tests: TestAskDelegation* (dns), TestReferral (dnsserver), TestDanglingDelegation (labzone), TestDanglingDelegationAtParent, TestDelegationCheckMaxQueries, TestDelegationCheckWithoutNameServers and TestDelegationCheckNeedsNS (scan), and TestE2ELabDanglingDelegation (CLI, Lab 9 plus the -stats fields). With the check disabled, the scan and CLI tests fail, and so does the existing TestE2ELabDanglingNS.
    • gofmt, go vet, golangci-lint v2.15.0, go test -shuffle=on ./... and go mod tidy -diff all pass. CI is green.

    Not done

    • The check runs only in the main pass. A name that first times out and only ends SERVFAIL in the -retry-inconclusive pass is not checked.
    • Only a referral owned by the name itself counts. Names below a dangling cut stay inconclusive, and the cut itself is flagged when it is a candidate.
    • Outside a lab, the delegation queries go to port 53 of the name servers' addresses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: dnsenhancementseverity: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions