T09 · Insecure Skill Coding Practices
- Location
- scripts/request_persona.sh:225
- Finding
- Unrestricted service endpoints permit plaintext transmission of credentials and persona data<![CDATA[ ## Vulnerability Details **File Location**: `scripts/request_persona.sh:225, 258-259`; `scripts/persona_client.sh:35-54` **Vulnerability Type**: Unvalidated endpoint configuration and insecure transmission of sensitive data **Risk Level**: High ### Vulnerable Code ```bash # scripts/request_persona.sh local telegram_api_base="${TELEGRAM_API_BASE:-https://api.telegram.org}" ``` ```bash # scripts/request_persona.sh if ! send_owner_prompt "$telegram_api_base" "$telegram_bot_token" "$telegram_owner_chat_id" "$request_id" "$requester_id" "$reason"; then print_refusal return 0 fi ``` The called function constructs a URL containing the Telegram bot token: ```bash curl -sS --fail \ --request POST \ --data-urlencode "chat_id=$owner_chat_id" \ --data-urlencode "text=$text" \ --data-urlencode "reply_markup=$reply_markup" \ "$api_base/bot$bot_token/sendMessage" >/dev/null ``` The persona-service client similarly accepts an unrestricted base URL and sends credentials and approved persona data to it: ```bash http_get_next() { local url url="${PERSONA_SERVICE_URL%/}/persona/client/next?client_id=${PERSONA_CLIENT_ID}" local args=() if [[ -n "$PERSONA_CLIENT_SHARED_SECRET" ]]; then args+=(-H "X-Client-Secret: ${PERSONA_CLIENT_SHARED_SECRET}") fi curl -sS --fail "${args[@]}" "$url" } http_post_response() { local body="$1" local url url="${PERSONA_SERVICE_URL%/}/persona/client/responses" local args=(-H "Content-Type: application/json") if [[ -n "$PERSONA_CLIENT_SHARED_SECRET" ]]; then args+=(-H "X-Client-Secret: ${PERSONA_CLIENT_SHARED_SECRET}") fi curl -sS --fail "${args[@]}" -d "$body" "$url" } ``` ### Technical Analysis `TELEGRAM_API_BASE` and `PERSONA_SERVICE_URL` are used without validating their URL scheme, hostname, port, embedded credentials, or destination. Consequently, the scripts allow plaintext HTTP endpoints or attacker-controlled HTTPS endpoints. The Telegram bot token is included directly in the re ...[truncated 2044 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Parse both endpoint settings with a dedicated URL parser before invoking `curl`. 2. Require the `https:` scheme for all non-development deployments. 3. Reject URLs containing embedded usernames or passwords, fragments, control characters, or unsupported ports. 4. Restrict `TELEGRAM_API_BASE` to `https://api.telegram.org` by default. If custom endpoints are required for testing, gate them behind an explicit development-only option. 5. Add a configurable hostname allowlist for `PERSONA_SERVICE_URL`. 6. Use `curl` options such as `--proto '=https'`, `--proto-redir '=https'`, and an appropriate `--max-redirs` value. 7. Consider certificate or public-key pinning for controlled persona-service deployments. 8. Avoid placing the Telegram token in logs or errors, and document immediate token and shared-secret rotation after suspected exposure. 9. Add automated tests confirming that `http://`, malformed URLs, embedded credentials, and unapproved hosts are rejected before any network request occurs. ]]>
