T09 · Insecure Skill Coding Practices
- Location
scripts/register.sh:54- Finding
Remote-to-Local Command Execution Through Unsafe Credential File Sourcing
- Content
View full analysis
\&, \ -> \\ (H-04 fix) local escaped_value escaped_value=$(printf '%s' "$value" | sed 's/[&\]/\\&/g') if [[ "$(uname -s)" == "Darwin" ]]; then sed -i '' "s|^${key}=.*|${key}=${escaped_value}|" "$ENV_FILE" else sed -i "s|^${key}=.*|${key}=${escaped_value}|" "$ENV_FILE" fi else printf '%s=%s\n' "$key" "$value" >> "$ENV_FILE" fi } ``` Remote API response fields are subsequently persisted: ```bash save_env "SWARMSYNC_ACCESS_TOKEN" "$ACCESS_TOKEN" save_env "SWARMSYNC_USER_ID" "$USER_ID" ``` ```bash save_env "SWARMSYNC_AGENT_ID" "$AGENT_ID" save_env "SWARMSYNC_AGENT_SLUG" "$LOCAL_SLUG" ``` ### Technical Analysis The script treats `~/.openclaw/.env` as both a data file and executable shell input. The `source` built-in evaluates every line using the current shell, including command substitutions, shell operators, function calls, redirections, and arbitrary commands. Several values written into this file originate from SwarmSync API responses. The `save_env` function does not serialize them as shell-safe literals or enforce strict field formats. Its escaping only ad ...[truncated 2071 chars]- Remediation
View remediation
