Skip to content

-dL lookahead runs the next target's NSEC walk beside the scan, doubling -rate #461

Done

Description

@TMHSDigital

Summary

Under -dL, the next target's lookup is prefetched before the current target's main pass starts. That lookup runs -nsec-walk with its own rate limiter, so while target i scans at -rate, target i+1's walk sends up to another -rate queries per second. The wire rate can reach twice -rate.

Where

  • internal/cli/session.go:798-800 (lookup.wait() then s.fetchAhead(la, i+1) before the main pass)
  • internal/cli/prefetch.go:34-36 (zoneTransfer for i+1 in a goroutine)
  • internal/cli/axfr.go:84 (Limiter: dns.NewRateLimiter(f.rate))
  • internal/scan/runner.go:316 (the main pass builds its own limiter)
  • internal/cli/cli.go:253 (-rate: "Max DNS queries per second on the wire, all workers combined")

Details

Before the lookahead from #365, a target's walk always finished before its scan started, so the two never overlapped. Now each has its own independent limiter. The -axfr name server lookups and transfers in the prefetch are not paced at all and also overlap the previous target's scan.

Impact

Operators who set -rate to stay under a resolver's or authoritative server's policy, or an engagement's rules of engagement, exceed it without notice. The walk also spends up to -max-queries per target outside the scan's budget during that time.

Steps to reproduce

  1. Two plain-NSEC lab zones in a -dL list.
  2. subenum -dL targets.txt -nsec-walk -rate 50 -w big.txt ...
  3. Count queries per second at the lab servers: while target 1's wordlist pass sends 50 qps, target 2's walk sends another 50 qps.

Suggested fix

Share one run-level dns.RateLimiter in the session and pass it to both scan.Config (instead of creating one per pass at runner.go:316) and WalkOptions.Limiter. Alternatively, when -rate is set, prefetch only the passive HTTP sources, not the walk or transfer.

Acceptance criteria

  • With -dL -nsec-walk -rate N, the combined wire rate stays at or below N.
  • A test with two lab targets and a counting server asserts it.

Related: #365

Getting started

  • Relevant files: internal/cli/prefetch.go, internal/cli/axfr.go, internal/scan/runner.go
  • How to run tests: go test ./internal/cli ./internal/scan

Filed by repo-audit/full-audit at a45b999. Severity: medium. Effort: M. audit-key: bug|internal/cli/prefetch.go|fetchAhead

Activity

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

    @TMHSDigital
    OwnerAuthor

    Fixed in e5daff4: under -rate the -dL lookahead fetches only the next target's passive sources; its -axfr transfer and -nsec-walk are deferred and run when that target starts (a new finishLookup step), so they no longer add to the current scan's rate. Without -rate the overlap from #365 is unchanged. New E2E test TestE2ERateDefersNextTargetTransfer (two -dL targets on a local server, fails without the fix) checks that no b.test query arrives while a.test's scan is answering and that b.test's transfer still runs under its own header. 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: clibugseverity: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions