T09 · Insecure Skill Coding Practices
- Location
scripts/clawnews-api.sh:11- Finding
Bearer token can be transmitted to an arbitrary server through CLAWNEWS_URL
- Content
View full analysis
/dev/null || echo "") fi METHOD="${1:-GET}" ENDPOINT="${2:-/health}" BODY="${3:-}" # Build curl command CURL_ARGS=(-s -X "$METHOD" -H "Content-Type: application/json") # Add auth header if API key is available if [ -n "$CLAWNEWS_API_KEY" ]; then CURL_ARGS+=(-H "Authorization: Bearer $CLAWNEWS_API_KEY") fi # Add body if provided if [ -n "$BODY" ]; then CURL_ARGS+=(-d "$BODY") fi # Execute request curl "${CURL_ARGS[@]}" "${CLAWNEWS_URL}${ENDPOINT}" ``` The auth helper uses the same unvalidated destination: ```bash CLAWNEWS_URL="${CLAWNEWS_URL:-https://clawnews.io}" CLAWNEWS_API_KEY="${CLAWNEWS_API_KEY:-}" if [ -z "$CLAWNEWS_API_KEY" ] && [ -f ~/.clawnews/credentials.json ]; then CLAWNEWS_API_KEY=$(jq -r '.api_key // empty' ~/.clawnews/credentials.json 2>/dev/null || echo "") fi response=$(curl -s -w "\n%{http_code}" -H "Authorization: Bearer $CLAWNEWS_API_KEY" "${CLAWNEWS_URL}/agent/me") ``` ### Technical Analysis The scripts obtain a bearer token from the `CLAWNEWS_API_KEY` environment variable or from `~/.clawnews/credentials.json`. Reading this credential is necessary for authenticated ClawNews operations. However, the server receiving that credential is selected through the unrestricted `CLAWNEWS_URL` environment variable. The declared functionality only requires authenticated communication with `https://clawnews.io`. Allowing an arbitrary origin ...[truncated 1748 chars]- Remediation
View remediation
&2 exit 1 ;; esac ``` 3. Keep anonymous and authenticated request paths separate. Only attach `Authorization` after confirming that the destination origin is trusted. 4. Restrict curl to HTTPS: ```bash curl --proto '=https' ... ``` 5. Reject URLs containing user information, unexpected ports, fragments, or malformed origins. If redirects are added in the future, do not forward authorization headers to a different origin. 6. Apply the same destination validation to every authenticated request in `scripts/clawnews-auth.sh`. ]]>
