Skip to content

fix(osint-autopilot): close remaining domain-arg traversal at all three entry points - #16

Merged
elementalsouls merged 0 commit into
mainfrom
harden/domain-validation
Aug 10, 2026
Merged

fix(osint-autopilot): close remaining domain-arg traversal at all three entry points#16
elementalsouls merged 0 commit into
mainfrom
harden/domain-validation

Conversation

@elementalsouls

@elementalsouls elementalsouls commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Follow-up to #14stacked on top of it (branched from that PR's head, so the diff here includes it). Merge #14 first and this rebases clean; or merge this alone and #14 is subsumed.

#14's guard is the right idea in the right place (before ENG= is built, before mkdir -p), but it leaves the hole open in two ways and covers one of three entry points.

1. . and .. still pass

^[A-Za-z0-9.-]+$ matches them:

$ bash recon_pipeline.sh ..
[*] engagement dir: /Users/me/Research/engagements/..

mkdir -p "$ENG"/{evidence/{...},assets,findings,notes,buckets} then scatters the whole evidence tree into ~/Research. A leading - also passes (-rf, --help), reaching whois "$D" (recon_pipeline.sh:26) and gau --subs --threads 5 "$D" (:82) as an option rather than an operand.

2. Two of three entry points had no guard at all

Both Python scripts build the same path from the same unvalidated sys.argv[1]:

  • findings_gen.py:7ENG = os.path.expanduser(f"~/Research/engagements/{D}")
  • build_xlsx.py:10 — identical, plus OUT = f"{ENG}/{D}-osint-consolidated.xlsx"

Verified by removing the new guard and re-running the self-check:

FAIL: findings_gen.py did not reject '../../tmp/pwned'
  (got: WROTE /tmp/sandbox/Research/engagements/../../tmp/pwned/findings/findings.csv)

Fix

Full dotted-hostname match, applied at all three entry points:

[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?)+

Requires at least one label separator, so ./../nodot are out; forbids leading/trailing - per label, so option injection is out. example..com, example.com., and example.com;id are rejected too.

Check

scripts/test_domain_guard.sh — no network, $HOME sandboxed to a temp dir:

$ bash skills/osint-autopilot/scripts/test_domain_guard.sh
PASS: domain guard holds on all three entry points

It asserts on the guard's own invalid domain string rather than a non-zero exit, so a script failing for an unrelated reason can't make it pass vacuously — confirmed by deleting a guard and watching it fail (output above). It also asserts the sandbox is empty afterward, and that a real domain still passes.

Note, not fixed here

.github/workflows/lint.yml pins shellcheck to scandir: ./scripts, so the scripts under skills/*/scripts/ — including the one this PR adds — are never linted. Fixed separately in #17. (An earlier revision of this description said that path doesn't exist; it does, it just holds one file.)

🤖 Generated with Claude Code

@elementalsouls
elementalsouls force-pushed the harden/domain-validation branch from 5a6210d to 504b1d5 Compare August 10, 2026 20:38
@elementalsouls
elementalsouls merged commit e970d79 into main Aug 10, 2026
2 of 4 checks passed
@elementalsouls
elementalsouls deleted the harden/domain-validation branch August 10, 2026 20:38
elementalsouls added a commit that referenced this pull request Aug 11, 2026
…ee entry points (#16)

Follow-up to #14. That guard blocked separators but still admitted:

  - `.` and `..`, which match `[A-Za-z0-9.-]+`. `recon_pipeline.sh ..`
    resolves ENG to `~/Research` and `mkdir -p` scatters the evidence
    tree there.
  - a leading `-`, which reaches `whois "$D"` and `gau ... "$D"` as an
    option rather than an operand.

It also only covered the shell driver. `findings_gen.py` and
`build_xlsx.py` build the same `~/Research/engagements/{D}` path from the
same unvalidated argv[1] and had no check at all — verified by removing
the new guard and watching findings_gen.py write to
`engagements/../../tmp/pwned/findings/findings.csv`.

Replaces the character class with a full dotted-hostname match and
applies it at all three entry points. `test_domain_guard.sh` asserts on
the guard's own error string (not merely a non-zero exit, which any
unrelated failure would satisfy), runs no network, and sandboxes $HOME.

Co-authored-by: Sachin Sharma <elementalsoul@Sachins-MacBook-Pro.local>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant