T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/feishu-bot.sh:145- Finding
Unvalidated Bot Identifier Enables Path Traversal and Recursive Deletion
- Content
View full analysis
" exit 1 fi check_prerequisites # Check if bot exists if ! bot_exists "$bot_id"; then print_error "Bot '$bot_id' not found!" exit 1 fi backup_config # Define paths local workspace_path="$HOME/.openclaw/workspace-$bot_id" local agent_dir="$HOME/.openclaw/agents/$bot_id" # Modify config using jq local tmp_file=$(mktemp) jq --arg bot_id "$bot_id" ' .agents.list = [.agents.list[]? | select(.id != $bot_id)] | .channels.feishu.accounts = del(.channels.feishu.accounts[$bot_id]) | .bindings = [.bindings[]? | select(.agentId != $bot_id)] ' "$OPENCLAW_CONFIG" > "$tmp_file" mv "$tmp_file" "$OPENCLAW_CONFIG" # Remove directories (ask first) if [[ -d "$workspace_path" || -d "$agent_dir" ]]; then echo "" read -p "Delete workspace and agent directories? [y/N] " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then rm -rf "$workspace_path" "$agent_dir" ``` The same unvalidated identifier is used when creating directories: ```bash local workspace_path="$HOME/.openclaw/workspace-$bot_id" local agent_dir="$HOME/.openclaw/agents/$bot_id/agent" mkdir -p "$workspace_path" "$agent_dir" ``` ### Technical Analysis The user-controlled `bot_id` is incorporated directly into filesystem paths without format validation or canonical containment checks. Shell quoting prevents word splitting and shell metacharacter injection, but it does not prevent path traversal through values containing `../`. For example, a ...[truncated 1745 chars]- Remediation
View remediation
