T09 · Insecure Skill Coding Practices
- Location
scripts/monitor.py:343- Finding
Configurable TMDB Endpoint Can Receive API Credentials
- Content
View full analysis
dict[str, Any]: api_key = get_env("TMDB_API_KEY") bearer = get_env("TMDB_BEARER_TOKEN") if not api_key and not bearer: return {} query = dict(params) headers = {"User-Agent": config["user_agent"], "Accept": "application/json"} if bearer: headers["Authorization"] = f"Bearer {bearer}" else: query["api_key"] = api_key url = f"{config['tmdb_base_url']}{path}?{urllib.parse.urlencode(query)}" request = urllib.request.Request(url, headers=headers) with urllib.request.urlopen(request, timeout=config["request_timeout_seconds"]) as response: return json.loads(response.read().decode("utf-8")) ``` ### Technical Analysis The destination receiving `TMDB_API_KEY` or `TMDB_BEARER_TOKEN` is constructed from `config["tmdb_base_url"]`. Configuration loaded from the project-level `config.toml` overrides the safe default, but the resulting URL is not validated against the official TMDB origin. When an API key is used, it is placed directly in the query string. When a bearer token is used, it is placed in the `Authorization` header. An attacker who can modify the project configuration can set `tmdb_base_url` to an attacker-controlled endpoint, including a plaintext HTTP endpoint, and receive the configured credential during the next execution. The checked-in `config.toml` does not currently override the official default endpoint, so the audited version does not contain an active credential-exfiltration host. Nevertheless, the code exposes a concrete credential disclosure path if repository or configuration contents are tampered with. ### Attack Path 1. An attacker obtains the ability to modify `config.tom ...[truncated 1169 chars]- Remediation
View remediation
