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
Shell bug-bountybugbountybugbounty-tooldnshackingnucleiosintpenetration-testingpentestpentest-toolpentestingreconreconnaissancescannersecuritysecurity-toolssubdomainsubdomain-enumerationvulnerabilities
fix(02-01): delete safe_count() eval injection vector from lib/common.sh
six2dez46aed848543a
diff --git a/lib/common.sh b/lib/common.shindex 45cbcc0..a397f55 100644--- a/lib/common.sh+++ b/lib/common.sh@@ -745,24 +745,6 @@ run_with_heartbeat_shell() {run_with_heartbeat "$label" /bin/bash -lc "$shell_cmd"}-# Count non-empty lines in a file safely-# Usage: NUMOFLINES=$(safe_count "file_path")-# NUMOFLINES=$(safe_count "command | pipeline") # legacy: still supported via eval-# Always returns a valid number (0 on failure)-safe_count() {- local result- if [[ -f "$1" ]]; then- # Safe path: count lines in file directly, no eval- result=$(sed '/^$/d' "$1" 2>/dev/null | wc -l | tr -d ' ') || result=0- else- # Legacy fallback for callers passing pipeline strings- # TODO: migrate remaining callers to pass file paths- result=$(eval "$1" 2>/dev/null | sed '/^$/d' | wc -l | tr -d ' ') || result=0- fi- [[ "$result" =~ ^[0-9]+$ ]] || result=0- echo "$result"-}-################################################################################ Pipeline Helpers###############################################################################diff --git a/tests/integration/test_full_flow.bats b/tests/integration/test_full_flow.batsindex e976920..12f3505 100644--- a/tests/integration/test_full_flow.bats+++ b/tests/integration/test_full_flow.bats@@ -242,18 +242,6 @@ source_reconftw() {[ "$status" -eq 0 ]}-@test "full flow: safe_count handles missing files" {- source_reconftw-- # shellcheck source=/dev/null- source "$SCRIPTPATH/lib/common.sh"-- # Test with non-existent file- local count- count=$(safe_count "/nonexistent/file.txt")- [ "$count" -eq 0 ]-}-@test "full flow: parallel_funcs handles empty list" {source_reconftwdiff --git a/tests/unit/test_common.bats b/tests/unit/test_common.batsindex 351a08b..fdbb9e4 100644--- a/tests/unit/test_common.bats+++ b/tests/unit/test_common.bats@@ -250,21 +250,6 @@ EOF[[ "$output" == *"DRY-RUN"* ]]}-###############################################################################-# safe_count tests-###############################################################################--@test "safe_count returns valid number" {- printf "line1\nline2\n" > test.txt- result=$(safe_count "cat test.txt")- [ "$result" -eq 2 ]-}--@test "safe_count returns 0 on failure" {- result=$(safe_count "cat nonexistent_file_xyz.txt")- [ "$result" -eq 0 ]-}-################################################################################ process_results tests###############################################################################