Skip to content

Resume double-counts refound names' flags and leaks restored names across -dL targets #408

Closed

Description

@TMHSDigital

Summary

Two resume bookkeeping errors in how names a resumed run finds again ("refound") are counted:

  • The refound names' takeover, internal-address and partial-answer flags are counted twice.
  • Names restored for one -dL target are also suppressed for every later target.

Where

  • internal/cli/resume.go:148-165, 185-192 (withoutRepeat, withoutRefound)
  • internal/cli/session.go:58, 82 (restored map, created once per session)
  • internal/cli/session.go:587-591 (emitResult drops restored names)
  • internal/cli/session.go:779-790, 804-808
  • internal/scan/runner.go:682-710 (flags counted before the result is emitted)
  • internal/report/report.go:126-130, internal/scan/verdict.go:38

Details

Flags counted twice. A resumed pass looks up again some names that the stopped run had already found: up to a chunk per worker past RootDone. scanState.report increments takeover, internal and partial (and the pool's poolHits/confirmed) for each of them. emitResult then drops the restored name and counts s.refound++. But withoutRefound subtracts the refound count only from Found, Processed, Total and Stats.Found, so the flags end up counted in both the saved part and the resumed part. A doubled Partial can also push the verdict from complete to degraded.

Restored names leak across targets. restored is created once per session (session.go:82) and only ever added to. With nested -dL targets (example.com, dev.example.com) and -recursive or multi-label entries, both targets can find api.dev.example.com. A resumed run reports that name only under the first target and lowers the second target's Found count by a refound that its own state never counted.

Impact

These only affect resumed runs. The report's takeover, internal and partial counts disagree with the result list and -sarif. Under -dL, results also differ depending on whether the run was resumed.

Steps to reproduce

  • Flags: run -type A,AAAA,CNAME against a zone with takeover-prone CNAMEs past the first few hundred entries, press Ctrl+C after they were found, then run -resume … -stats s.json. takeover_candidates in s.json exceeds the number of hinted results.
  • Targets: make a -dL file with example.com and dev.example.com and a wordlist with api and api.dev. Interrupt during the second target, then resume. api.dev.example.com is missing from the second target's results.

Suggested fix

  • When emitResult drops a restored result, also count its Takeover, Internal and Partial flags, and subtract them in withoutRefound together with Found. Treat pool hit/confirmed the same way, or document that they count lookups.
  • Reset s.restored at the start of each target, before restoreTarget.

Acceptance criteria

  • After a resume, takeover, internal and partial counts equal those of an uninterrupted run
  • A resumed -dL run with nested targets reports the same names per target as an uninterrupted run
  • Tests for both in internal/cli/resume_test.go, using a lab zone

Getting started


Filed by repo-audit/full-audit at dd5b156. Severity: low. Effort: S. audit-key: bug|internal/cli/resume.go|withoutRefound

Activity

  1. added
    bug
    area: cli
    severity: low
    on Nov 17, 2026
  2. TMHSDigital commented on Nov 18, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in 16fdded.

    • A refound name's takeover, internal and partial flags are now counted (refoundCount) and subtracted by withoutRefound together with the name. The pool's PoolHits/Confirmed count lookups, repeated ones included, and are left as they are; the function's comment now says so.
    • The restored-name set is reset at the start of each target, so a name restored for one -dL target is no longer dropped from a later nested target that finds it.

    Verified: TestWithoutRefoundDropsFlags checks the flag arithmetic; TestE2EResumeNestedTargetsKeepTheirNames resumes a hand-built -dL state (example.com done, dev.example.com not started) in simulate mode and fails without the reset (the second target lost api.dev.example.com and reported found=1), passes with it. Full suite, vet and golangci-lint v2.15.0 pass; CI green.

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: low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions