T09 · Insecure Skill Coding Practices
- Location
deploy.sh:7- Finding
Environment-Controlled Deployment Endpoint Can Expose Source Files and API Credentials
- Content
View full analysis
[api-key]}" PATH_TO_FILES="${2:?Usage: ./deploy.sh [api-key]}" API_KEY="${3:-${CLAWDSHIP_API_KEY:-}}" API_BASE="${CLAWDSHIP_API:-https://api.clawdship.dev}" if [ ! -d "$PATH_TO_FILES" ]; then echo "❌ Directory not found: $PATH_TO_FILES" >&2 exit 1 fi # Create tar.gz ARCHIVE=$(mktemp /tmp/clawdship-XXXXXX.tar.gz) trap 'rm -f "$ARCHIVE"' EXIT echo "📦 Packaging $PATH_TO_FILES..." tar czf "$ARCHIVE" -C "$PATH_TO_FILES" . # Build curl command CURL_ARGS=(-s -w "\n%{http_code}" -X POST "${API_BASE}/v1/sites") CURL_ARGS+=(-F "name=${SLUG}" -F "type=static" -F "slug=${SLUG}" -F "archive=@${ARCHIVE}") if [ -n "$API_KEY" ]; then CURL_ARGS+=(-H "Authorization: Bearer $API_KEY") fi ``` ### Technical Analysis The deployment destination is obtained from the inherited `CLAWDSHIP_API` environment variable without validating its URL scheme, hostname, or trust level. The script subsequently sends both the generated project archive and, when available, the bearer API credential to that destination. Shell array usage prevents ordinary shell-command injection through `API_BASE`; however, it does not prevent data exfiltration to an attacker-selected HTTP server. If an attacker can influence the environment in which the script is launched—for example, through a compromised wrapper, CI configuration, shell profile, task runner, or parent process—the attacker can replace the legitimate API origin with an arbitrary endpoint. The script also accepts non-HTTPS destinations. An `http://` endpoint would transmit the uploaded project and authorization header without transport encryption, allowing interception or modification by a networ ...[truncated 1928 chars]- Remediation
View remediation
&2 exit 1 ;; esac ``` 3. **Separate production and development behavior** Require a deliberate command-line flag for custom endpoints rather than silently inheriting them from the environment. Display the destination and request confirmation before uploading files or credentials to a non-production origin. 4. **Never transmit credentials over plaintext HTTP** Reject any URL that does not use HTTPS. URL validation should parse and compare the scheme and hostname rather than relying on loose substring or prefix checks. 5. **Bind credential transmission to the trusted origin** Add the `Authorization` header only after confirming that the final request destination is the approved Clawdship API origin. Review redirect behavior as well, ensuring credentials cannot be forwarded to another host. 6. **Reduce archive exposure** Support an exclusion file or safe defaults for sensitive content such as `.env`, private keys, credential files, `.git`, and local configuration. Clearly warn users that every file beneath the selected directory will be uploaded. 7. **Harden CI and automation environments** Protect deployment environment variables, review inherited variables before execution, restrict who can modify workflow definitions, and prevent untrusted pull requests from changing deployment configuration. ]]>
