Repository navigation
Description
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-62main_axfr.go:72-82main_axfr.go:92-104main_axfr.go:130-132main_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",
-statstarget has a non-emptyaxfr_error, and the wordlist scan still runs. - NS lookup answers NOERROR with no NS records:
axfr_erroris "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),triedreflected 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. -
-resumewith a state file whose target hasaxfr_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(orgo test ./...). Tests must stay hermetic: use-simulate,-simulate-zoneor 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
TMHSDigital commentedon Nov 15, 2026
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-emptyaxfr_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.gois disabled (checked by temporary mutation); the NS-lookup-failure test was not mutation-checked.go test ./..., the new tests with-count=5 -race, andgolangci-lint runpass.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.
Test the -axfr failure, cap, resume and cancel paths (TMHSDigital#303)