T09 · Insecure Skill Coding Practices
- Location
scripts/_common.sh:7- Finding
Bearer Token Disclosure Through an Unrestricted API Base Override
- Content
View full analysis
Vulnerability Details
File Location:
scripts/_common.sh:7, 32-40
Vulnerability Type: Bearer credential exfiltration through an attacker-controlled destination
Risk Level: HighVulnerable Code
bash API_BASE="${INFERSPORTS_API_BASE:-https://api.infersports.dev}"bash local url="${API_BASE}${path}" resp http payload local hdr=(-H "Accept: application/json" -A "infersports-skill/${SKILL_VERSION}") [ -n "${INFERSPORTS_API_KEY:-}" ] && hdr+=(-H "Authorization: Bearer ${INFERSPORTS_API_KEY}") if [ "$method" = "POST" ]; then resp=$(curl -sS -m 15 -w $'\n%{http_code}' -X POST "$url" -H "Content-Type: application/json" "${hdr[@]}" -d "$body") \ || _die "network error reaching InferSports ($url)" "check connectivity or set INFERSPORTS_API_BASE, then retry" else resp=$(curl -sS -m 15 -w $'\n%{http_code}' "${hdr[@]}" "$url") \ || _die "network error reaching InferSports ($url)" "check connectivity or set INFERSPORTS_API_BASE, then retry" fiThe corresponding configuration is documented at
SKILL.md:161-162:markdown - `INFERSPORTS_API_KEY` — an `isk_…` key to raise rate limits / unlock the sharp book. Default keyless = Free tier (enough for these verbs). - `INFERSPORTS_API_BASE` — override the API host (default `https://api.infersports.dev`).Technical Analysis
The shared HTTP client constructs every destination from the environment-controlled
INFERSPORTS_API_BASE. WhenINFERSPORTS_API_KEYis present, it unconditionally adds that value to theAuthorizationheader.There is no validation that the resulting URL:
- Uses HTTPS.
- Targets the official
api.infersports.devhost. - Has no embedded credentials, unexpected port, fragment, or malicious path.
- Is an explicitly trusted development endpoint.
Consequently, the same production bearer token is sent to any configured destination. Supporting a custom endpoint may be useful for testing, but forwarding an official API credential to that endpoint is no ...[truncated 1433 chars]
- Remediation
View remediation
Remediation Suggestions
- Parse and validate the API base before issuing a request.
- Require HTTPS for all authenticated requests.
- Only attach
INFERSPORTS_API_KEYwhen the normalized origin exactly matches an allowlisted origin such as:text https://api.infersports.dev - Reject embedded user information, fragments, unapproved ports, and malformed or protocol-relative URLs.
- If custom endpoints are required for development:
- Require a separate explicit opt-in variable.
- Use a separate development credential variable.
- Do not forward the production key by default.
- Fail closed when both a custom base and the official API-key variable are configured.
- Avoid including sensitive URL components in error output.
- Add automated tests confirming that authentication is omitted or execution fails for HTTP and non-allowlisted origins.
