Skip to content

A complete AI agency at your fingertips - From frontend wizards to Reddit community ninjas, from whimsy injectors to reality checkers. Each agent is a specialized expert with personality, processes, and proven deliverables.

Shell

fix(installer): refuse destination file symlinks when copying

Rudy Celekli37678803bfe0
diff --git a/scripts/install.sh b/scripts/install.sh
index 8fde392a..6be90822 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -283,7 +283,17 @@ OVERRIDE_PATH="" # --path (single-destination override)
# install_file <src> <dest> — copy, or symlink when --link is set.
install_file() {
- if $USE_LINK; then ln -sf "$1" "$2"; else cp "$1" "$2"; fi
+ if $USE_LINK; then
+ ln -sf "$1" "$2"
+ else
+ local target="$2"
+ [[ -d "$target" ]] && target="${target%/}/$(basename "$1")"
+ if [[ -L "$target" ]]; then
+ err "Refusing to copy through a destination symlink: $target"
+ return 1
+ fi
+ cp "$1" "$2"
+ fi
}
# resolve_dest <tool> <default> — --path > $ENV_VAR > default.
diff --git a/scripts/test-install.sh b/scripts/test-install.sh
index 5aeb290d..4f35319c 100755
--- a/scripts/test-install.sh
+++ b/scripts/test-install.sh
@@ -396,6 +396,17 @@ first=$(count_md "$dest")
run_install "$home" --tool claude-code --division engineering --path "$dest"
assert_eq "$first" "$(count_md "$dest")" "re-running installs the same set, not duplicates"
+# A project-owned symlink with an agent's filename must not redirect a copy
+# into another file outside the selected destination.
+home="$(sandbox symlink-destination)"
+dest="$home/dest"
+mkdir -p "$dest"
+printf 'KEEP THIS FILE\n' > "$home/sentinel"
+ln -s "$home/sentinel" "$dest/$(basename "$FIRST_ENG_FILE")"
+run_install "$home" --tool claude-code --no-convert --agent "$FIRST_ENG_SLUG" --path "$dest"
+assert_eq 1 "$RUN_STATUS" "copy mode refuses an existing agent-file symlink"
+assert_eq 'KEEP THIS FILE' "$(cat "$home/sentinel")" "symlink target is not overwritten"
+
# ---------------------------------------------------------------------------
echo ""
if [[ $xfailed -gt 0 ]]; then