T09 · Insecure Skill Coding Practices
- Location
scripts/tafu_api.sh:17- Finding
Unrestricted API base URL override can disclose credentials and personal data
- Content
View full analysis
Vulnerability Details
File Location:
scripts/tafu_api.sh, lines 17-53
Vulnerability Type: Unvalidated destination used for authenticated requests
Risk Level: MediumVulnerable Code
sh BASE_URL="${TAFU_API_BASE_URL:-https://api.tafu.me/api/v1}" case "$PATH_INPUT" in /*) PATH_SUFFIX="$PATH_INPUT" ;; *) PATH_SUFFIX="/$PATH_INPUT" ;; esac BASE_URL="$(printf '%s' "$BASE_URL" | sed 's:/*$::')" URL="${BASE_URL}${PATH_SUFFIX}" if [ "$BODY_INPUT" = "" ]; then exec curl -sS --fail-with-body \ -X "$METHOD" \ -H "Authorization: Bearer $TAFU_API_KEY" \ "$URL" fi case "$BODY_INPUT" in @*) BODY_FILE="${BODY_INPUT#@}" exec curl -sS --fail-with-body \ -X "$METHOD" \ -H "Authorization: Bearer $TAFU_API_KEY" \ -H "Content-Type: application/json" \ --data-binary "@${BODY_FILE}" \ "$URL" ;; *) exec curl -sS --fail-with-body \ -X "$METHOD" \ -H "Authorization: Bearer $TAFU_API_KEY" \ -H "Content-Type: application/json" \ --data-binary "$BODY_INPUT" \ "$URL" ;; esacTechnical Analysis
The script allows
TAFU_API_BASE_URLto determine the destination of every API request without validating its scheme, hostname, port, or URL structure. The script subsequently attaches theTAFU_API_KEYbearer token to that destination.Consequently, anyone capable of modifying the skill's environment configuration can redirect authenticated requests to an attacker-controlled server. The override also permits cleartext
http://destinations, which could expose the bearer token and request data to network interception.Request bodies can contain birth dates, birth times, gender, location, and compatibility information for multiple people. The issue therefore affects both credentials and personal data.
Attack Path
- An attacker gains the ability to alter the skill envi ...[truncated 1113 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove
TAFU_API_BASE_URLsupport if endpoint customization is unnecessary. - If an override is required, parse it and enforce an explicit allowlist of trusted hostnames.
- Require the
httpsscheme and reject cleartext HTTP, URL user information, fragments, unexpected ports, malformed URLs, and hostname suffix tricks. - Construct the authorization header only after destination validation succeeds.
- Consider maintaining separate allowlists for production and approved development endpoints.
- Fail closed with a clear error when validation fails.
- Rotate
TAFU_API_KEYimmediately if requests may already have been redirected. - Apply least-privilege and spending limits to API keys where supported.
- Remove
