Repository navigation
Description
Summary
-permute builds about 93 candidates for every name any source proposed (CT, Wayback, AXFR), keeps up to three copies of them in memory, and does all of this before -max-queries applies. With a large CT footprint, that means hundreds of MB and a second pass of millions of queries that -dry-run does not estimate.
Where
internal/candidates/candidates.go:96-98,131-150,159-166(every source name becomes a permutation seed)internal/permute/permute.go:28-65(Generate: 3 × len(Words) + 3 variants per seed in one map, then a sorted slice)internal/cli/permute.go:44-50,67-72(wordlist.NotInandwordlist.Buildmake further copies)
Details
Set.Add puts every proposed name into the seeds, and RelativeSeeds turns all of them into permutation seeds. For each seed, Generate adds 90 word combinations plus 3 numbered variants to a map, then copies them into a slice. Permutations builds a second map of the same size in wordlist.NotIn(generated, entries), then a third structure in wordlist.Build. All of this happens before scanTarget, so -max-queries caps only what is admitted, not what is built. finishedPermutation (resume) rebuilds the whole list only to count it.
Impact
crt.sh often returns 10k-100k names for a large organisation. At 50k seeds that is about 4.6M candidates and a peak of roughly 0.5 GB per target, plus a 4.6M-query second pass (about 77 minutes at 1000 qps). This is an estimate from the data structures, not a measurement.
Steps to reproduce
Run subenum -ct -permute <target with a large CT footprint> and watch RSS at the "Permutation pass for X: N candidates from M seed names" line.
Suggested fix
- Seed
-permutefrom found names (and-seeds) by default, and make source-proposed names opt-in. Or cap seeds or candidates and print a notice. - Generate into one deduplicated set and drop wordlist entries in the same pass, so only one structure is live.
- Have
finishedPermutationcount without building the full list. - Include the permutation pass in the
-dry-runestimate.
Acceptance criteria
- Peak memory of the permutation pass is bounded, or scales with found names rather than with source names
-
-dry-runreports the permutation pass size - A benchmark with 50k seeds in
internal/permuteorinternal/cli
Getting started
- Relevant files:
internal/permute/permute.go,internal/cli/permute.go,internal/candidates/candidates.go - Related: -permute and -dry-run gaps: seeds-only pass, custom words, resolver pool #376
Filed by repo-audit/full-audit at dd5b156. Severity: medium. Effort: M. audit-key: performance|internal/permute/permute.go|Generate
Activity
TMHSDigital commentedon Nov 18, 2026
Fixed in 3d8c23d.
candidates.Permutationsgenerates into a single set (permute.GenerateSet), deletes wordlist entries from it in place and copies the survivors out sorted.NotInandBuildare no longer used here, so the generated map, sorted copy,NotInset andBuildindex are no longer all held at once.candidates.MaxPermutations). Seeds are taken in sorted order, so a resumed pass rebuilds the same list, and the CLI prints a note when the cap is hit.-dry-run: the found names are not known before a scan, so the plan can't give the pass's exact size. Its notes now give the bound instead: up to 93 candidates per name, at most 1,000,000 per target.BenchmarkPermutations50kininternal/candidates. For 50,000 seeds the old pipeline took about 11 s with 1.8 GB allocated. The new one takes 0.9 s with 148 MB, capped at 1M candidates.I left source-proposed names as seeds rather than making them opt-in, since the cap bounds the cost either way.
TestPermutationsCappedchecks that the cap holds and that builds are reproducible. The full suite, vet and golangci-lint pass.