reconFTW is a tool designed to perform automated recon on a target domain by running the best set of tools to perform scanning and finding out vulnerabilities
Phase 2: Security Quoting & Supply-Chain Hygiene - Context
Gathered: 2026-05-13 Status: Ready for planning
## Phase BoundaryClose five security/supply-chain audit gaps grouped into three plans:
- 02-01 — Remove the
evalinjection vector undersafe_count()(SEC-01) - 02-02 — Quote every variable in
sendToNotify()curl calls + 1-charmantraaxiom-exec path fix (SEC-02, FIX-01) - 02-03 — Refactor
AXIOM_EXTRA_ARGSto an explicit Bash array +verify_sha256on installer bootstrappers +tools.lockmanifest for stability-critical Go tools (SEC-03, SEC-04)
In scope: lib/common.sh (safe_count delete), modules/core.sh:1399-1414 (sendToNotify quoting), modules/web.sh:2340 (mantra path), modules/subdomains.sh + modules/web.sh (38 AXIOM_EXTRA_ARGS call sites), reconftw.sh (global AXIOM_EXTRA_ARGS_ARR parse), install.sh (rustup/uv SHA256 + tools.lock manifest), and the associated bats test and doc updates triggered by safe_count removal.
Out of scope (other phases): per-tool thread caps and scope-check unification (Phase 3 / PERF-01, FIX-02); the parallel_funcs/axiom failover bats tests for the new array refactor (Phase 4 / TEST-01, TEST-03); PARALLEL_MAX_JOBS / ALLOW_TRANSFER / RAISE_ULIMIT config exposure and MIN_DISK_SPACE_GB 2-vs-5 reconciliation (Phase 5 / DOCS-01, DOCS-02). UX/UI output overhaul beyond what already shipped is a new capability for a future milestone.
safe_count() Removal (Plan 02-01, SEC-01)
- D-01: Delete
safe_count()entirely fromlib/common.sh:748-764(function definition + Usage comment block). Zero live callers in anymodules/*.shorlib/*.shfile confirmed viagrep -rn 'safe_count' . --include='*.sh'(only the definition itself plus 3 bats tests show up).count_lines()(file path,lib/common.sh:125) andcount_lines_stdin()(lib/common.sh:136) already cover every legitimate use case. This is a fuller cleanup than the literal success criterion ("else branch is gone") but matches CLAUDE.md's "if certain something is unused, delete it completely" policy and removes the latent injection-vector surface entirely rather than leaving a zero-caller function as a future trap. - D-02: Delete the 3 bats tests that exercise the eval branch at
tests/unit/test_common.bats:254-267(2 tests) andtests/integration/test_full_flow.bats:245-256(1 test). These tests callsafe_count "cat test.txt"(pipeline-string form), which exercises the very eval branch we're removing — they cannot be ported as-is. Rewriting them ascount_linestests adds no new coverage becausecount_linesis already tested elsewhere intest_common.bats. Plain deletion is the correct outcome. - D-03: Update 5 doc/intel files that mention
safe_countto referencecount_linesinstead, or drop the reference if no replacement is needed. Files:CHANGELOG.md:203,CLAUDE.md:283,.planning/codebase/CONVENTIONS.md:162-164,.planning/codebase/STRUCTURE.md:18,.planning/codebase/ARCHITECTURE.md:63. The.planning/PROJECT.md:46Active bullet for SEC-01 will be moved to Validated by the transition step, not edited as part of the phase work.
sendToNotify() Quoting + mantra Path Fix (Plan 02-02, SEC-02 + FIX-01)
- D-04: Quote every variable expansion in the full
sendToNotify()body (modules/core.sh:~1390-1416), not just the three names listed in the success criterion. Concretely:"$discord_url","${slack_channel}","${1}"(named in criterion);"@${1}"in every-Fcurl-form expression;"-F channels=${slack_channel}","-F chat_id=${telegram_chat_id}","-F document=@${1}","-F file1=@${1}","-F file=@${1}"; the four bare$NOTIFY_CONFIGexpansions in the surroundinggrep -q ... $NOTIFY_CONFIGandsed -n ... ${NOTIFY_CONFIG}lines; and the URL interpolationhttps://api.telegram.org/bot${telegram_key}/sendDocument(inside an existing double-quoted curl arg, so already safe — but the planner should double-check). Full-function pass means a future contributor who copy-pastes any line in this block does not re-introduce the same class of bug from an unquoted neighbour. - D-05: Shellcheck-clean policy: after the quoting pass,
shellcheck modules/core.shshould produce no new SC2086 / SC2068 / SC2027 findings inside:1390-1420. If a flagged expansion is genuinely intentional (none expected in this block), use an inline# shellcheck disable=SCXXXXwith a one-line explanation comment on the line ABOVE. Project convention (.planning/codebase/CONVENTIONS.md:277) is inline suppressions only, never file-level. - D-06:
mantraaxiom-exec path fix (FIX-01): 1-character change atmodules/web.sh:2340—github.com/Brosck/mantra@latest→github.com/brosck/mantra@latestto match the local install path corrected in commitf64383c2. GitHub module path matching is case-sensitive; the current value 404s on the remote axiom node. Bundled in Plan 02-02 because it's a single-line edit in adjacent code-touch territory (notification + remote install). No commit boundary games — single commit per logical change is fine.
AXIOM_EXTRA_ARGS_ARR Array Refactor (Plan 02-03, SEC-03)
D-07: Parse once globally in
reconftw.shimmediately aftersecrets.cfgis sourced (right around line 503, before theCLI_*re-apply block). The parse isread -r -a AXIOM_EXTRA_ARGS_ARR <<< "${AXIOM_EXTRA_ARGS:-}". Single source of truth, parse cost paid exactly once per invocation, intentionally exposed asAXIOM_EXTRA_ARGS_ARR(matches the success criterion name verbatim) so users who setAXIOM_EXTRA_ARGS="--rate-limit 100"inreconftw.cfgget the correct multi-token expansion at every site. Backwards-compatible with existing string-form config values. If the var is unset/empty, the array is empty and"${AXIOM_EXTRA_ARGS_ARR[@]}"expands to nothing (bash 4.3+ behaviour withoutset -u, which reconftw never enables — confirmed by.planning/codebase/CONVENTIONS.md:5-13).D-08: Migrate all 38 call sites to
"${AXIOM_EXTRA_ARGS_ARR[@]}"uniformly. Breakdown for the planner's grep audit:modules/subdomains.sh: 21 sites (lines 672, 737, 745, 768, 962, 1100, 1107, 1233, 1366, 1570, 1587, 1666, 1742, 1825, 1838, 1905, 1926, 1944, 1990, 2068, plus any duplicates revealed bygrep -nE 'AXIOM_EXTRA_ARGS' modules/subdomains.sh)modules/web.sh: 17 sites (lines 340, 431, 506, 786, 1008, 1152, 1537, 1988, 1990, 2257, 2280, 2341, 2479, 2925, 2927, plus the local-pattern block at 144-200 to be removed per D-09).
Of the 38 sites today, ~25 use bare
$AXIOM_EXTRA_ARGS(word-split, works but silent intent) and ~13 use"$AXIOM_EXTRA_ARGS"(wrong — single-token; actively breaks--rate-limit 100-style values). Both patterns become"${AXIOM_EXTRA_ARGS_ARR[@]}".D-09: Remove the local
axiom_extra_args=()pattern fromwebprobe_fullatmodules/web.sh:144-155(thelocal -a axiom_extra_args=()declaration + IFS-jugglingread -r -ablock) and replace"${axiom_extra_args[@]}"at line 200 with"${AXIOM_EXTRA_ARGS_ARR[@]}". One uniform pattern across the codebase; the local block is redundant once the global parse runs at startup.D-10: Verification sweep after migration: (a)
grep -nE 'AXIOM_EXTRA_ARGS([^_]|$)' modules/{subdomains,web}.shmust return zero hits except for the newAXIOM_EXTRA_ARGS_ARRreferences and any doc comments. (b) A one-shot tokenisation smoke test: in a sandboxed shell, setAXIOM_EXTRA_ARGS="--rate-limit 100 --threads 50", sourcereconftw.sh --source-only, and inspect"${AXIOM_EXTRA_ARGS_ARR[@]}"— assert it expands to 4 tokens, not 1. (c)shellcheck modules/subdomains.sh modules/web.shreturns no new findings. The proper bats coverage lives in Phase 4 (TEST-03 axiom failover) per Phase 1's deferred-section precedent; do NOT add a new bats test in this phase.
Installer SHA256 + tools.lock (Plan 02-03, SEC-04)
User did not select this gray area for discussion — pattern is locked from the existing precedent at install.sh:1251-1289.
- D-11:
verify_sha256()for rustup and uv bootstrappers: extendinstall_rust_uv()atinstall.sh:159-188to follow the existing env-var-driven pinning pattern. AddRUSTUP_INSTALLER_SHA256andUV_INSTALLER_SHA256env vars (default unset). When set, the script must verify the downloaded tempfile against the pinned hash viaverify_sha256(already defined atinstall.sh:85-102) and abort with a clear error message before executing it. When unset, behaviour is unchanged — backwards-compatible. Hard-pinning would break on every upstream release (rustup ~weekly, uv ~monthly); env-var-driven means CI/security-conscious users can pin without forcing the maintainer into an upstream-release-tracking treadmill. Document the env vars in the install.sh comment block at:1228-1239alongside the existingGETJSWORDS_SHA256example. - D-12:
tools.lockmanifest pinning the 5 stability-critical Go tools (nuclei,httpx,ffuf,puredns,subfinder) per the success criterion. Format: a plain-texttools.lockfile in the repo root, one entry per line as<binary>=<module>@<version>, e.g.nuclei=github.com/projectdiscovery/nuclei/v3/cmd/[email protected]. The Go install loop atinstall.sh:501-518consultstools.lockfirst; if the entry exists,go install -v "$module_at_version"runs with the pinned version. If absent, fall through to the existing@latestbehaviour (so the other 50+ tools are unaffected). Plain text means easy to grep, easy fordependabot-style automation to update, and no Bash associative-array duplication of the existinggotoolsmap. Versions chosen by the planner viago install ...@latestonce, recording the resolved tag. - D-13: Scope cap: do NOT pin every Go tool. Commit
71653984("remove pinned versions") explicitly removed wholesale pinning because the maintenance burden was disproportionate to the value for tools that change rarely (e.g.,anew,unfurl,qsreplace). Pinning only the 5 named tools matches the success criterion and keeps the maintenance surface small.
Claude's Discretion
- The exact ordering of the global
AXIOM_EXTRA_ARGS_ARRparse line vs theCLI_*re-apply block inreconftw.shis a planner-level choice — anywhere betweensecrets.cfgsourcing (line 503) and the dispatch case (line 590) works, as long as it's BEFORE any module function runs. Plan 02-03's preferred placement is "immediately after secrets.cfg source" because that keeps array-parse state co-located with the var's canonical setter site. - The
tools.lockfile format detail (e.g., comment-line syntax#, blank-line tolerance, optional trailing comments) is up to the planner. Whatever format is chosen, it must round-trip cleanly throughawk/sedparsing ininstall.shand survive contributors editing it by hand. - Whether the doc updates in D-03 are bundled in the same commit as the
safe_countdelete or split into a follow-up commit is a planner-level call. Single-commit-per-logical-change is the established pattern. - Whether shellcheck is run as a pre-commit hook (already configured in
.pre-commit-config.yamlper.planning/codebase/CONVENTIONS.md) or as an explicit step in the executor's verification is the planner's call. The existing pre-commit gate is the canonical enforcer.
Downstream agents MUST read these before planning or implementing.
Phase scope and requirements
.planning/ROADMAP.md§"Phase 2: Security Quoting & Supply-Chain Hygiene" — phase goal, 5 success criteria, 3 plans.planning/REQUIREMENTS.md§"Security Hardening" (SEC-01, SEC-02, SEC-03, SEC-04) and §"Bug Fixes" (FIX-01) — the five v1 requirements this phase delivers
Codebase intel (driving the changes)
.planning/codebase/CONCERNS.md§"eval in safe_count() Legacy Fallback" — drives SEC-01 / Plan 02-01.planning/codebase/CONCERNS.md§"sendToNotify Unquoted Variables in curl Calls" — drives SEC-02 / Plan 02-02.planning/codebase/CONCERNS.md§"Unquoted AXIOM_EXTRA_ARGS — Inconsistent Quoting" — drives SEC-03 / Plan 02-03.planning/codebase/CONCERNS.md§"Installer Downloads and Executes Unverified Scripts" and §"All Go Tools Install @latest Without Version Pinning" — drives SEC-04 / Plan 02-03.planning/codebase/CONCERNS.md§"Axiom Mantra Module Path Stale in Axiom Branch" — drives FIX-01 / Plan 02-02
Architectural and conventions (must align with)
.planning/codebase/CONVENTIONS.md§"Source Guard Pattern" and §"Variable Naming" — confirmsUPPER_SNAKE_CASEglobals;AXIOM_EXTRA_ARGS_ARRmatches the existing convention.planning/codebase/CONVENTIONS.md§"Comments" — inline# shellcheck disable=policy for the sendToNotify pass.planning/codebase/ARCHITECTURE.md§"Component Responsibilities" —lib/common.shshared utilities listing (to be updated whensafe_countis removed).planning/codebase/STACK.md— supply-chain context for the 50+ Go tools and the rustup/uv bootstrap dependency
Existing reusable code
install.sh:82-102(verify_sha256()) — already-defined SHA-256 helper to wire intoinstall_rust_uv()install.sh:1251-1289(download_sha256map + verify loop) — the env-var-driven pinning precedent for D-11lib/common.sh:122-140(count_lines,count_lines_stdin) — canonical replacement helpers forsafe_countper D-01modules/web.sh:144-200(existingaxiom_extra_argslocal pattern inwebprobe_full) — the pattern to remove per D-09 and replace with the global D-07
Project constraints
.planning/PROJECT.md§Constraints — "external tools: 70+ runtime dependencies … no version pinning, a known supply-chain risk" — the constraint SEC-04 partially addressesCLAUDE.md§Conventions —function name()declaration form,_snake_caseprivate helpers, global UPPER_SNAKE_CASE config vars
Prior-phase precedent
.planning/phases/01-resilient-resume-timeout-safety/01-CONTEXT.md— tests in Phase 4 (not the implementation phase) precedent, shellcheck/JSONL conventions, opt-in default knob pattern
Reusable Assets
count_lines()atlib/common.sh:125— canonical file-line-count helper, already used by 11 call sites inmodules/core.shandmodules/modes.sh. Replaces every legitimatesafe_countuse case (D-01).count_lines_stdin()atlib/common.sh:136— covers the pipeline-input case that thesafe_countelse branch used to handle, but safely (noeval).verify_sha256()atinstall.sh:85-102— already returns 0 on match, 1 on mismatch, and 0 on missing hash tool (intentional skip-don't-block semantics). Compatible with both GNUsha256sumand macOSshasum -a 256. D-11 wires it intoinstall_rust_uv()with new env vars.download_sha256associative-array pattern atinstall.sh:1251-1289— the env-var-driven hash override precedent (GETJSWORDS_SHA256,AXIOM_CONFIG_SHA256). D-11 follows the same pattern for rustup/uv.gotoolsassociative-array atinstall.sh:293-355— the existing Go-tool install table. D-12 readstools.lockfirst, falls back to this table's@latestinstall for unpinned entries.bblue/bgreen/byellow/resetcolour vars +_print_msg/_print_errorhelpers — already wired throughlib/ui.sh. The smoke-test output in D-10 uses these so verbose mode still shows the verification result; no UI work needed.
Established Patterns
UPPER_SNAKE_CASEglobals (CONVENTIONS.md §"Variable Naming") —AXIOM_EXTRA_ARGS_ARRslots in alongsideAXIOM,AXIOM_EXTRA_ARGS,AXIOM_FLEET_COUNT. No special-case naming.- Env-var-driven optional verification — existing pinning is opt-in via env var, defaults to "skip don't block". D-11 follows this. Hard-pinning breaks the install loop on every upstream release without giving users a way to override.
local -a array_name=()+read -r -afrom a heredoc/here-string is the canonical Bash array-from-string pattern (CONVENTIONS.md does not call it out explicitly, butweb.sh:144-153andlib/parallel.shuse it). The global D-07 parse uses the same idiom.- Inline
# shellcheck disable=with explanation (CONVENTIONS.md §"Comments") — never file-level. D-05 honors this for any intentional word-split that survives the sendToNotify pass (none expected). - Single-commit-per-logical-change (PROJECT.md §"Recent trajectory" + Phase 1 execution log) — D-06 bundles the 1-char mantra fix with the sendToNotify quoting because they live in the same plan (02-02). D-03 doc updates can be one commit or split per planner judgment.
Integration Points
reconftw.sh:~500-578— config sourcing block. D-07 inserts the globalAXIOM_EXTRA_ARGS_ARRparse aftersecrets.cfgsource, BEFORE theCLI_*re-apply block, so the array is initialised before any module function (which all run after thecase $opt_modedispatch downstream).install.sh:159-188(install_rust_uv) — D-11 wiresverify_sha256calls into the rustup and uv download blocks. The existing tempfile pattern (mktemp→curl -o→sh "$_tmpfile") stays; verification is inserted between download and execution.install.sh:489-525(install_toolsloop) — D-12 readstools.lockonce before the loop, then per iteration checks if the currentgotoolis in the pinned map. The existinggo install -v "${gotools[$gotool]}@latest"becomesgo install -v "$pinned_or_latest".- Pre-commit hooks (
.pre-commit-config.yaml) — shellcheck + shfmt already run on every commit. The sendToNotify and AXIOM refactor passes go through this gate automatically; no new hook config needed. - No axiom-module impact — the array refactor is fully contained in
reconftw.sh(parse) +modules/subdomains.sh+modules/web.sh(consumers).modules/axiom.shitself does not readAXIOM_EXTRA_ARGSdirectly; it providesaxiom-scaninfrastructure that consumers pass args to.
- Deletion over deprecation: the user chose to fully delete
safe_count(), bats tests, and doc references rather than leave a deprecated stub. Planner should NOT propose a back-compat wrapper or a deprecation warning — there are zero callers and zero plugins depending on it. Clean delete is the agreed outcome (D-01/D-02/D-03). - Full-function quoting over minimum-criterion: the user explicitly chose to quote every expansion in
sendToNotify(), not only the names listed in the success criterion. Planner should NOT scope the diff down to the named vars to keep the patch small — the agreed standard is a shellcheck-clean function body (D-04/D-05). - One global
AXIOM_EXTRA_ARGS_ARRover per-function locals: the user explicitly rejected the per-function local-array pattern (including the existing one atwebprobe_full). Planner should NOT preserveaxiom_extra_args=()inwebprobe_fullas an exception — removing it is the explicit agreement (D-09). All 38 sites use the global. - Env-var-driven SHA pinning over hard-pin: although the user did not actively discuss SEC-04, the in-context default chosen here (D-11) matches the existing
GETJSWORDS_SHA256/AXIOM_CONFIG_SHA256precedent. Planner should NOT switch to hard-pinned hashes without surfacing it as a question first. - 5-tool
tools.lockover wholesale re-pinning: D-13 explicitly caps SEC-04 scope at the 5 tools named in the success criterion. Planner should NOT re-introduce pinning for every Go tool — commit71653984removed it for a reason.
- UX/UI output overhaul — user expressed interest in further UX/UI improvements to tool output. The 2026-03 audit already shipped the current UI overhaul (dot-fill status format, single-line summaries, parallel group rebalancing, OUTPUT_VERBOSITY gating). Any further UI work is a new capability that belongs in its own milestone, not in Phase 2's security/supply-chain remediation. Carry forward to roadmap backlog for consideration after the v1.0 audit-hardening milestone closes.
- Pin every Go tool, not just 5 — explicitly rejected per D-13 / commit
71653984history. Revisit if a future stability incident on a non-pinned tool justifies the maintenance burden. - Bats coverage for the new AXIOM_EXTRA_ARGS_ARR parse and the rustup/uv SHA path — Phase 4 (TEST-03 axiom failover) is the canonical place for axiom-touching test work. Phase 2 ships behaviour, Phase 4 ships coverage. Planner should NOT add bats tests in this phase even though the surface is small.
- Documenting
AXIOM_POST_STARTas executable inreconftw.cfg(separate concern surfaced by CONCERNS.md §"bash -lc with Config-Controlled Strings") — not in v1 requirements. Could be folded into Phase 5 (DOCS-01) doc-surfacing work. GH_TOKENps-aux exposure mitigation (CONCERNS.md §"GitHub Token File Passed Directly on Command Line") — listed in REQUIREMENTS.md v2 backlog as ARCH-02. Out of scope for v1.- Hard-pin rustup/uv hashes (vs env-var-driven) — the planner-locked D-11 chose env-var-driven. If a security incident or CI policy later requires hard-pinning, revisit by replacing D-11; the underlying
verify_sha256helper supports both modes.
Phase: 2-Security Quoting & Supply-Chain Hygiene Context gathered: 2026-05-13