T09 · Insecure Skill Coding Practices
- Location
scripts/_common.py:10- Finding
Bearer Access Key Can Be Transmitted to an Attacker-Controlled Server
- Content
View full analysis
dict: access_key = _ensure_access_key() headers = { "Authorization": f"Bearer {access_key}", } if content_type: headers["Content-Type"] = content_type return headers def api_get(path: str, timeout: int = 30) -> dict: validate_api_path(path) url = f"{BASE_URL.rstrip('/')}{path}" req = urllib.request.Request(url, method="GET", headers=_headers()) try: with urllib.request.urlopen(req, timeout=timeout) as resp: return json.loads(resp.read().decode("utf-8")) ``` The corresponding POST implementation uses the same pattern: ```python validate_api_path(path) url = f"{BASE_URL.rstrip('/')}{path}" data = json.dumps(body).encode("utf-8") req = urllib.request.Request( url, data=data, method="POST", headers=_headers(), ) try: with urllib.request.urlopen(req, timeout=timeout) as resp: return json.loads(resp.read().decode("utf-8")) ``` ### Technical Analysis `VOOOAI_BASE_URL` is accepted without validating its scheme, hostname, port, credentials, or relationship to the expected VoooAI origin. The API path allowlist only validates the path supplied to `api_get()` or `api_post()`; it does not validate the destination represented by `BASE_URL`. Every request adds `VOOOAI_ACCESS_KEY` as a bearer token. Consequently, a modified environment can direct authenticated requests to an arbitrary HTTP or HTTPS server. A non-HTTPS URL also exposes the token to network interception. Redirect behavior is not explicitly constrained, so ...[truncated 1377 chars]- Remediation
View remediation
