Skip to content

Bare-IP -dns-server breaks -axfr, -nsec-walk and the -dry-run preflight #459

Done

Description

@TMHSDigital

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 (NormalizeDNSServer adds :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:

  1. subenum -dry-run -dns-server 127.0.0.1 -timeout 300 example.invalid prints preflight FAILED via 127.0.0.1: error.
  2. With -dns-server 127.0.0.1:53 the same command prints timeout, a real query attempt.
  3. subenum -axfr -dns-server 127.0.0.1 -w wl.txt example.test prints Warning: -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, -axfr and -nsec-walk work with a bare-IP -dns-server.
  • A unit test pins the resolver address handed to axfr.Options and the dry-run resolver to host:53.
  • The scattered normalization calls in internal/cli are 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

  1. added
    bug
    good first issue
    area: cli
    severity: medium
    on Nov 29, 2026
  2. TMHSDigital commented on Nov 29, 2026

    @TMHSDigital
    OwnerAuthor

    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.

  3. added a commit that references this issue on Nov 29, 2026
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: clibuggood first issueseverity: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions