Skip to content

Commit c46615a

Browse files
claude[bot]claude
andcommitted
fix: validate custom install path in install.sh to prevent path traversal
User-supplied custom path was passed directly to mkdir -p and cp -r without sanitization, allowing path traversal via .. segments or shell metacharacters. Added validation to reject traversal sequences, restrict to safe characters, and canonicalize via realpath before use. Co-Authored-By: Claude Code <noreply@anthropic.com>
1 parent 7a95d94 commit c46615a

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

examples/digital-brain-skill/scripts/install.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ case $choice in
3535
;;
3636
3)
3737
read -p "Enter custom path: " custom_path
38+
# Validate: reject empty, path traversal (..), and characters outside safe set
39+
if [[ -z "$custom_path" ]] || [[ "$custom_path" == *".."* ]] || [[ "$custom_path" =~ [^a-zA-Z0-9/_.\-\ ~] ]]; then
40+
echo "Invalid path. Use only letters, numbers, /, _, ., -, ~, and spaces."
41+
exit 1
42+
fi
43+
# Canonicalize to catch traversal via symlinks or relative segments
44+
custom_path="$(realpath --canonicalize-missing -- "$custom_path")"
3845
TARGET_DIR="$custom_path/$SKILL_NAME"
3946
;;
4047
*)

0 commit comments

Comments
 (0)