Skip to content

Every inconclusive lookup is retained for the whole scan, even when unread #300

Closed

Description

@TMHSDigital

Summary

The engine keeps the name of every timed-out, refused or failed lookup until the scan ends, whether or not -retry-inconclusive or -inconclusive is set. Under -no-abort against a failing resolver that grows with the wordlist (about 1 GB at 10M candidates).

Where

  • internal/scan/runner.go:233-248
  • internal/scan/runner.go:886-889
  • internal/scan/runner.go:651
  • internal/scan/runner.go:261-270
  • main_session.go:759-771
  • main_resume.go:308

Details

processJob records every timeout, refusal and failure unconditionally: st.add(outcome); if inconclusive(outcome) { s.pending.add(j, outcome) } (runner.go:886-889). pendingList.add appends a pendingLookup{j job; outcome} (40 bytes: a 16-byte string header, two ints, one int outcome) and so keeps the candidate's name string alive (a 32 to 48 byte allocation that would otherwise be garbage once the job ends). The list is only drained by retryPending, which runs only if cfg.RetryInconclusive (runner.go:639-641). At the end snap.Inconclusive = st.pending.names() (runner.go:651) builds a second []string (16 bytes per name) while the list is still referenced, and sorts it. In the CLI the only readers are inconclusiveNames, called only when -inconclusive <file> is set (main_session.go:806-807), and the resume state; otherwise the list sits in s.results[i].final.Stats for every target until the process exits, and mergeStats copies it again on resume (main_resume.go:308).

Impact

About 72 to 90 bytes retained per failed lookup during the scan, about 110 to 130 bytes at the peak when names() runs, and 48 bytes per name kept afterwards for the rest of a -dL run. With the reliability guard on, failures can reach 20 percent of the candidates before it aborts (runner.go:1063), so a 5M-line wordlist can hold 1M names: roughly 100 MB peak, about half of what the wordlist itself costs. With -no-abort, or under -auto-rate while the controller has not given up (runner.go:1058-1060), there is no bound: a 10M-candidate scan against a resolver that refuses or times out everything holds about 1 GB, plus an O(F log F) sort of F names, for a list nobody asked for. Hurts from roughly 1M failed lookups.

Steps to reproduce

subenum -no-abort -w <multi-million-line list> -dns-server <address that drops or refuses> example.com (hermetically: a local dnsserver handler returning Refused for every name, or the resolveHook used by the scan tests returning OutcomeRefused); watch heap grow linearly with processed candidates although neither -retry-inconclusive nor -inconclusive is set.

Suggested fix

Collect names only when something will read them: add a Config field (for example ListInconclusive) that the CLI sets when -inconclusive or -retry-inconclusive is given and that pkg/subenum keeps on by default or exposes, since Stats.Inconclusive is documented there (pkg/subenum/subenum.go:270-273); otherwise only count. Independently, shrink the entry: for depth-1 jobs store the root index (4 to 8 bytes) and rebuild Entries[root] + "." + Domain in names(), keeping the full name only for recursive children; and release pending.items before building the sorted slice.

Notes

Related: #217 (introduced the list and the retry pass).

Acceptance criteria

  • Names are collected only when a consumer asked for them (retry pass, -inconclusive, library callers that read Stats.Inconclusive)
  • Counts are unchanged when the list is not collected
  • A benchmark or test shows heap does not grow with failed lookups when the list is off

Getting started

  • Relevant files: internal/scan/runner.go, main_session.go, main_resume.go
  • How to run tests: make test (or go test ./...). Tests must stay hermetic: use -simulate, -simulate-zone or 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: S. audit-key: performance|internal/scan/runner.go|pendingList

Activity

  1. added
    performance
    area: scan
    severity: medium
    on Nov 15, 2026
  2. TMHSDigital commented on Nov 15, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in 654f974.

    The engine now keeps the list of inconclusive names only when something will read it: -inconclusive <file> or the -retry-inconclusive pass (which drops the list once it has taken it). A wordlist entry is stored as its index rather than its name. The counts in the report are unchanged, and pkg/subenum still fills Stats.Inconclusive for library callers.

    Verified with three new tests in internal/scan/inconclusive_list_test.go, including a heap comparison: a 100,000-name scan where every lookup is refused now stays within 1 MB of one where every name is NXDOMAIN (with collection forced on it was 7.4 MB against 3.7 MB). go test ./... and golangci-lint run pass.

    Two differences from the suggestion: the CLI does not ask for the list under -retry-inconclusive alone, since nothing reads the final list then, and the library has no opt-out. One side effect: the -resume state file holds the names only when -inconclusive was given.

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: scanperformanceseverity: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions