Repository navigation
Description
Summary
-max-duration is checked only before a worker starts a job. Under a low -rate, every worker is parked in the rate limiter when the deadline passes, and each one still sends its queries afterwards. A 2-second budget at -rate 5 takes about 43 seconds.
Where
internal/scan/runner.go:591-592(if !s.cfg.pastDeadline() { ... s.processJob(ctx, j) })internal/scan/runner.go:316,:334(per-pass limiter; slots taken inside the lookup)internal/cli/cli.go:235(help: "then no new names are tested, lookups in flight finish")
Details
Rate slots are taken per query inside the lookup, from the limiter on the context, and that wait does not know about Config.Deadline. With the default -t 100 and -type A,AAAA, all 100 workers are waiting for slots when the deadline arrives. Each then sends its queries one slot at a time and its name is counted as tested. The overshoot is about t x queries-per-name / rate.
Impact
Scheduled jobs and the Action size their CI timeout to -max-duration. With a polite -rate, the job overruns, can hit the CI job timeout, and loses its report and resume state. The flag's help text promises a budget it does not keep.
Steps to reproduce
Built-in lab, no traffic leaves the machine:
- 200-line wordlist
wl.txt. subenum -simulate-zone lab1 -rate 5 -max-duration 2s -w wl.txt -stats s.json lab1.example- Wall time is about 43 s and
processedis 102. With-t 10it is about 7 s and 13 names.
Suggested fix
Take a job's rate slots before its lookup with a context bounded by Config.Deadline (wait on the limiter, then mark the slots prepaid in the wire budget), and count the job as skipped when the deadline wins. Alternatively, have the limiter's Wait return early on a deadline carried on the context for queries not yet sent.
Acceptance criteria
- The lab repro above finishes within about
-max-durationplus one round trip. - Names that never got a slot are counted as skipped, not tested, and the run is resumable from them.
- A test with a slow limiter and a short deadline asserts the bound.
Getting started
- Relevant files:
internal/scan/runner.go,internal/dns/ratelimit.go - How to run tests:
go test ./internal/scan
Filed by repo-audit/full-audit at a45b999. Severity: medium. Effort: M. audit-key: bug|internal/scan/runner.go|runWorkers
Activity
TMHSDigital commentedon Nov 29, 2026
Fixed in 1cfcbd7: the scan attaches its -max-duration deadline to the context after the pre-scan checks; the rate limiter refuses slots at or after it (ErrPastDeadline, classified as canceled), ResolveTypes reserves a name's slots all-or-nothing, and jobs refused a slot count as skipped and stay resumable. Lab repro (-rate 5 -max-duration 2s, 200 names) now takes ~4.3s (2s budget + ~2s of pre-scan checks, which #340 exempts) instead of ~43s, with 5 tested and 195 skipped and a working -resume. New tests TestRunDeadlineBoundsRateWaits (fails without the fix: 53 tested, 6.5s) and TestRateLimiterSendDeadline; gate (gofmt, vet, golangci-lint v2.15.0, full suite, -race on dns/scan) passes.
Add changelog entries for #459 and #460