Skip to content

-axfr: NS lookup failure, server and address caps, resume reuse are untested #303

Closed

Description

@TMHSDigital

Summary

The caps that stop -axfr from flooding a target with many name servers, the failed-NS-lookup path and the reuse of a saved transfer on resume are never executed by a test.

Where

  • main_axfr.go:60-62
  • main_axfr.go:72-82
  • main_axfr.go:92-104
  • main_axfr.go:130-132
  • main_axfr_test.go:60-155

Details

zoneTransfer has three e2e tests (main_axfr_test.go: transfer allowed, refused with NSEC3, refused with NSEC) and one for lab/simulate refusal. The cover profile shows these blocks never run, and no test file mentions them: the resumed-run shortcut if saved != nil && saved.AXFRDone { return targetAXFR{names: saved.AXFR, ...} } (main_axfr.go:60-62; AXFRDone appears only in main_resume.go and main_axfr.go, in no test); the failed or empty NS lookup that sets res.err and warns (72-79; AXFRError is only ever asserted to be empty, main_axfr_test.go:112); the flood bounds if len(servers) > axfrMaxServers { servers = servers[:axfrMaxServers] } (80-82) and if len(addrs) > axfrAddrsPerServer (98-100); the unresolvable name server branch (92-97); the cancel check (102-104).

Impact

The two caps are the documented protection that a target with many name servers "cannot turn -axfr into a flood" (main_axfr.go:15-16). A change that drops or miscounts either cap, or that stops a resumed run from reusing the saved transfer (so its candidate list no longer matches the interrupted run's and the saved resume position points at different names), would pass the suite.

Suggested fix

Add to main_axfr_test.go, using the existing axfrZone/dnstest helpers (all local, no live DNS):

  • NS lookup answers SERVFAIL: exit 0, output has "Warning: -axfr: name server lookup failed", -stats target has a non-empty axfr_error, and the wordlist scan still runs.
  • NS lookup answers NOERROR with no NS records: axfr_error is "no name servers found for example.test".
  • Zone with 10 NS records, all refusing: the server sees AXFR queries for at most 8 hosts (axfrMaxServers).
  • One name server with 4 A records, all refusing: at most 2 AXFR attempts (axfrAddrsPerServer), tried reflected in the verbose line.
  • One NS host that does not resolve plus one that allows the transfer: the transfer still succeeds and the bad host is only mentioned under -v.
  • -resume with a state file whose target has axfr_done: true, axfr: ["zt1","zt2"]: no NS or AXFR query reaches the server, and the two names are scanned as candidates.
  • Context cancelled between two addresses: returns without sending the next AXFR.

Acceptance criteria

  • Each case in the checklist under Suggested fix has a test
  • All new tests use the local DNS test helpers only

Getting started

  • Relevant files: main_axfr.go, main_axfr_test.go
  • How to run tests: make test (or go test ./...). Tests must stay hermetic: use -simulate, -simulate-zone or the local DNS test server, never a live domain.
  • Related docs: docs/DEVELOPER_GUIDE.md, docs/ARCHITECTURE.md

Filed by repo-audit/full-audit at d0c56f0. Severity: medium. Effort: M. audit-key: testing|main_axfr.go|zoneTransfer

Activity

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

    @TMHSDigital
    OwnerAuthor

    Done in 2b6b392 (tests only, in internal/cli/axfr_test.go, all against the in-process DNS server).

    • TestE2EZoneTransferNSLookupFails: SERVFAIL and no-NS answers; exit 0, a warning, a non-empty axfr_error, no transfer attempted, and the wordlist scan still runs.
    • TestE2EZoneTransferServerCap: 10 name servers, exactly 8 asked.
    • TestE2EZoneTransferAddressCap: one name server with 4 addresses, exactly 2 transfer attempts.
    • TestE2EZoneTransferSkipsUnresolvableServer: the transfer still succeeds; the bad host is mentioned only with -v.
    • TestE2EResumeReusesZoneTransfer: a saved transfer is reused with no NS or AXFR query, and the report carries the saved server and count.
    • TestZoneTransferStopsWhenCancelled: cancelling during the first transfer stops after one attempt.

    Five of these fail when the corresponding code in axfr.go is disabled (checked by temporary mutation); the NS-lookup-failure test was not mutation-checked. go test ./..., the new tests with -count=5 -race, and golangci-lint run pass.

    One difference from the checklist: for a NOERROR answer with no NS records the issue expects "no name servers found for example.test". That message cannot currently be produced, because Go's resolver returns an error for such an answer, so the test asserts what happens today ("name server lookup failed: ..."). I've noted the unreachable branch separately.

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

    help wantedseverity: mediumtesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions