T09 · Insecure Skill Coding Practices
- Location
SKILL.md:85- Finding
API Credentials and User Content Can Be Redirected Through a Mutable API Base URL
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:85-133
Vulnerability Type: Unvalidated external service destination
Risk Level: MediumVulnerable Code
bash export MAGICPODCAST_API_URL="https://api.magicpodcast.app" export MAGICPODCAST_API_KEY="${API_KEY:?Please set the environment variable}"bash payload="$(jq -n --arg text "$SOURCE_TEXT" --arg language "$LANGUAGE" '{text:$text,language:$language}')" # ... curl -sS -X POST "$MAGICPODCAST_API_URL/agent/v1/podcasts/text" \ -H "Content-Type: application/json" \ -H "x-api-key: $MAGICPODCAST_API_KEY" \ --data-binary "$payload"bash if ! safe_job_id "$JOB_ID"; then echo "Invalid job id" >&2 exit 1 fi # ... curl -sS "$MAGICPODCAST_API_URL/agent/v1/jobs/$JOB_ID" \ -H "x-api-key: $MAGICPODCAST_API_KEY"Technical Analysis
The API endpoint is constructed from the mutable
MAGICPODCAST_API_URLenvironment variable. The instructions do not verify that its effective value uses HTTPS or that its hostname is exactlyapi.magicpodcast.app.Both API operations attach
MAGICPODCAST_API_KEYthrough thex-api-keyheader. The creation request also sends the complete user-supplied source text. Consequently, a modified process environment can redirect credentials and potentially sensitive content to an unintended endpoint.Although the documented default points to the expected HTTPS service, assigning a secure default is not equivalent to validating the value at execution time. The job-ID validation does not protect the endpoint or the API key.
Attack Path
- An attacker with influence over the Agent's environment, launch configuration, shell profile, or workflow variables sets
MAGICPODCAST_API_URLto an attacker-controlled endpoint. - A user invokes the Skill and supplies text for podcast generation.
- The Agent constructs the request URL from the poisoned environment variable.
curlse ...[truncated 746 chars]
- An attacker with influence over the Agent's environment, launch configuration, shell profile, or workflow variables sets
- Remediation
View remediation
Remediation Suggestions
- Hardcode the trusted base URL when endpoint customization is unnecessary:
bash readonly MAGICPODCAST_API_URL="https://api.magicpodcast.app" - If configurability is required, parse and validate the URL before attaching credentials. Require the exact
httpsscheme and an explicit allowlist of trusted hostnames. - Reject URLs containing user information, unexpected ports, fragments, or nonstandard hostname representations.
- Configure
curlto use HTTPS only:bash curl --proto '=https' --tlsv1.2 ... - Avoid following redirects for authenticated requests. If redirects are required, validate every redirect destination and ensure credentials are not forwarded across origins.
- Fail closed when endpoint validation fails, before reading or transmitting source text.
- Use a narrowly scoped API key, rotate any key suspected of exposure, and monitor the external service for unauthorized use.
- Hardcode the trusted base URL when endpoint customization is unnecessary:
