mirror of
https://github.com/walkinglabs/learn-harness-engineering.git
synced 2026-09-19 05:06:27 +08:00
dee964ca39
any_file_match() used `ls $REPO/$pattern` without quoting $REPO. Because the variable was unquoted during word splitting, a crafted REPO value such as "/tmp; rm -rf /" would be split on the semicolon into a second, independent command — a classic shell injection (CWE-78). Replace the `ls | grep` pipeline with `compgen -G "$REPO/$pattern"`. The entire `$REPO/$pattern` is now double-quoted, so no splitting or pathname expansion happens on $REPO, and compgen performs the glob match without spawning an external process. All other 17 `$REPO` uses in the file were already correctly quoted (inside `[[ ]]`, `"$REPO/..."`, or `find "$REPO"`), so this was the single exploitable point.