Repository navigation
Description
Summary
#417 made -dns-server 1.1.1.1 valid, but the flag value itself is never normalized. -axfr, -nsec-walk and the -dry-run preflight pass the raw value to the dialer, which fails with "missing port in address", while the main scan with the same flag works.
Where
internal/cli/axfr.go:70,:95(zoneTransfer:Resolver: f.dnsServer,opts.Server = f.dnsServer)internal/cli/dryrun.go:85(dns.NewResolver(timeout, f.dnsServer))internal/axfr/axfr.go:174->internal/dns/transport.go:213(nd.DialContext(ctx, network, d.addr))internal/validate/validate.go:41(NormalizeDNSServeradds:53)
Details
The if normalized, err := validate.NormalizeDNSServer(x); err == nil { x = normalized } idiom is repeated at about eight call sites (internal/cli/cli.go:928, internal/cli/ptr.go:110, internal/cli/mcp.go:176, internal/scan/options.go:93, internal/scan/runner.go:321, internal/tui/form.go:573, pkg/subenum/subenum.go:666, pkg/subenum/zone.go:96). The two CLI paths above do not have it. The library's zone path does normalize, so the CLI and library disagree.
Impact
With a bare IP (on the command line, in the config file or in SUBENUM_DNS_SERVER), the zone transfer and NSEC walk are silently skipped (a warning, then a scan without them), and -dry-run reports a FAILED preflight. Nothing points at the cause.
Steps to reproduce
Hermetic, against 127.0.0.1:
subenum -dry-run -dns-server 127.0.0.1 -timeout 300 example.invalidprintspreflight FAILED via 127.0.0.1: error.- With
-dns-server 127.0.0.1:53the same command printstimeout, a real query attempt. subenum -axfr -dns-server 127.0.0.1 -w wl.txt example.testprintsWarning: -axfr: name server lookup failed: ... missing port in address; scanning example.test without a zone transfer.
Suggested fix
Normalize once, right after flag and config parsing (f.dnsServer in the session's validation step), then remove the per-call copies in the CLI. Alternatively, normalize inside dns.NewResolver/newDialer, so every caller is covered, and keep scan.Options.Validate as the single engine-side normalization.
Acceptance criteria
-
-dry-run,-axfrand-nsec-walkwork with a bare-IP-dns-server. - A unit test pins the resolver address handed to
axfr.Optionsand the dry-run resolver tohost:53. - The scattered normalization calls in
internal/cliare reduced to one.
Related: #417
Getting started
- Relevant files:
internal/cli/axfr.go,internal/cli/dryrun.go,internal/cli/cli.go,internal/validate/validate.go - How to run tests:
go test ./internal/cli ./internal/validate
Filed by repo-audit/full-audit at a45b999. Severity: medium. Effort: S. audit-key: bug|internal/cli/axfr.go|zoneTransfer
Activity
TMHSDigital commentedon Nov 29, 2026
Fixed in 5fbcd4b: -dns-server is now normalized once right after flag/env/config parsing, and the per-call copies in scanOptions and the -ptr pass are gone. Verified with a new TestParseFlagsNormalizesDNSServer (flag and config-default cases) and by running
-dry-run -dns-server 127.0.0.1, which now queries 127.0.0.1:53 instead of failing on a missing port. gofmt, vet, golangci-lint v2.15.0 and the full test suite pass.Add changelog entries for #459 and #460