Skip to content

Delegation check: the live name server discovery path is never tested #468

Done

Description

@TMHSDigital

Summary

Every delegation-check test sets cfg.ZoneServer, the lab shortcut, so the path real scans take (find the zone's name servers, resolve them to endpoints, ask each in turn) never runs in the suite.

Where

  • internal/scan/delegation.go:54-58 (lab shortcut used by every test)
  • internal/scan/delegation.go:60-75 (axfr.NameServers, endpoint resolution, "none of the name servers ... could be resolved"; servers is 64.7% covered)
  • internal/scan/delegation.go:111-115 (an endpoint errors, move to the next)
  • internal/dns/referral.go:84 (ID/QR mismatch rejection)
  • internal/scan/delegation_test.go:76

Impact

Dangling-delegation detection (a takeover signal, #406) on real targets runs code no test exercises. A regression shows up only as missing findings in the field. For example, dropping the endpoints append at delegation.go:68 leaves go test ./internal/scan green.

Suggested fix

  • A config without ZoneServer, with the resolver a dnstest server answering NS for the domain with two hosts whose A records point at a second dnstest server (port override through a test seam): endpoints contain both, and a SERVFAIL name gets its NS records.
  • NS hosts that do not resolve: the "none of the name servers of X could be resolved" notice is emitted once.
  • The first endpoint times out and the second answers: records come from the second, and queries are counted for both.
  • readDelegation with a wrong ID or QR=0 returns an error and no hosts.

Getting started

  • Relevant files: internal/scan/delegation.go, internal/scan/delegation_test.go, internal/dns/referral.go, internal/dnstest
  • How to run tests: go test ./internal/scan -run Delegation

Filed by repo-audit/full-audit at a45b999. Severity: medium. Effort: M. audit-key: testing|internal/scan/delegation.go|parentZone.servers

Activity

  1. added
    help wanted
    testing
    area: scan
    severity: medium
    on Nov 29, 2026
  2. TMHSDigital commented on Nov 29, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in 529ca52: Config has a new unexported zonePort test seam (port 53 when unset). New TestDelegationFindsZoneNameServers runs the real discovery path with no ZoneServer, through a local resolver: two NS hosts, both endpoints kept, 5 lookup queries counted; the endpoint that fails is asked first and the next one answers with ns1.gone.example.net, and the delegation queries are counted on top. TestDelegationUnresolvedNameServers covers NS hosts that don't resolve: no check, and one notice saying none of the name servers could be resolved. TestReadDelegationRejectsForeignReply covers wrong ID and QR=0. Dropping the endpoints append now fails the first test. Gate (gofmt, vet, golangci-lint v2.15.0, full suite) passes.

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: scanhelp wantedseverity: mediumtesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions