T09 · Insecure Skill Coding Practices
- Location
tennis_live_gate_skill.py:363- Finding
Live Tennis API Key Can Be Sent to an Arbitrary Endpoint
- Content
View full analysis
Vulnerability Details
File Location:
tennis_live_gate_skill.py:363-368; externally reachable throughscripts/status.py:38-42
Vulnerability Type: Unrestricted credential forwarding
Risk Level: HighVulnerable Code
python url = base_url.rstrip("/") + path if params: url += "?" + urllib.parse.urlencode(params) req = urllib.request.Request(url, headers={"X-API-Key": api_key}) try: with urllib.request.urlopen(req, timeout=timeout) as resp: return json.loads(resp.read().decode("utf-8"))The status script permits the destination to be selected through an environment variable:
python base_url = os.environ.get("LIVETENNIS_BASE_URL", DEFAULT_BASE_URL) players = [sys.argv[1], sys.argv[2]] print(f"Resolving live match for: {players[0]} vs {players[1]}\n") try: state = fetch_live_tennis_state(players, api_key=api_key, base_url=base_url)Technical Analysis
The HTTP helper attaches the sensitive
LIVETENNIS_API_KEYvalue to every request as anX-API-Keyheader. However,base_urlis not constrained to the official Live Tennis API origin and is not required to use HTTPS.In
scripts/status.py, this value comes directly fromLIVETENNIS_BASE_URL. Consequently, anyone who can influence the process environment or convince a user to configure a custom endpoint can redirect requests and their credential to an attacker-controlled server. Anhttp://destination also exposes the key to network interception.A base URL override can be useful for testing, but unrestricted forwarding of a production credential exceeds the minimum privileges required by the declared functionality. The normal operation only needs access to the official Live Tennis API host.
Attack Path
- An attacker influences deployment instructions, shell configuration, a task runner, or the environment used to launch the status script.
- The attacker sets
LIVETENNIS_BASE_URLto a ...[truncated 833 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the production base URL override unless it is operationally necessary.
- Require the
httpsscheme before attaching any credential. - Allowlist the exact official hostname,
api.livetennisapi.com, and the expected API path prefix. - Reject URLs containing user information, unexpected ports, fragments, or ambiguous host representations.
- Prevent credential forwarding when an HTTP redirect changes the origin.
- If testing against alternate services is required, use an explicitly named test-only key and require a separate opt-in flag.
- Add tests confirming that HTTP URLs, unknown hosts, and cross-origin redirects are rejected before a request is sent.
- Avoid printing the key or including it in raised exceptions and diagnostic logs.
