You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From an adversarial audit of internal/scanner/** (21 confirmed findings).
Fixes all HIGH + MEDIUM issues.
HIGH — path traversal (arbitrary file write + dir deletion):
Every scanner built its output dir as filepath.Join(resultsDir, <target>) where
the target (domain/subdomain/bucket/repo) was never stripped of '/' or '..'. Since
filepath.Join cleans the path, a target like "../../../../tmp/x" escaped the
results dir; the subdomain scan's end-of-run cleanup (RemoveAll) made it an
arbitrary-directory-deletion primitive, reachable from the unauthenticated-by-
default scan API.
- New utils.SanitizeTargetSegment(): collapses a target to one safe path segment
(no separators, no ".."). Applied in utils.ResultsDir and at every direct
path-build site: subdomain, nuclei, gf, sqlmap, dalfox, githubscan, backup,
domain, ports, s3, asr, dns, misconfig, cnames, jsendpoints, urls, zerodays,
exposure, depconfusion.
- Regression test asserts no sanitized segment can contain a separator/".." and
cannot escape via filepath.Join.
HIGH — NS-takeover detection was dead code (dns.go):
runNSTakeover built its resolver with dnsx.DefaultOptions, which only queries A
records, so result.NS was always empty and NS takeovers were never detected.
Now configures QuestionTypes=[]uint16{dns.TypeNS} so the NS section is populated.
MEDIUM:
- jsscan: cap remote JS body with io.LimitReader(10MB) — unbounded io.ReadAll
across ~100 workers could exhaust memory.
- cnames: on timeout, snapshot cnameRecords under the mutex before reading
(workers could still append → data race).
- asr/dns_asr: puredns I/O used fixed /tmp filenames shared across runs; now uses
a per-invocation os.MkdirTemp dir so concurrent ASR scans don't corrupt
each other.
go mod tidy promotes miekg/dns (now used directly) and gjson to direct deps.
CI replicated locally: CGO_ENABLED=1 go vet/build/test all pass; new utils tests
and backup tests pass.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
0 commit comments