T09 · Insecure Skill Coding Practices
- Location
scripts/common.py:27- Finding
Unrestricted API Base URL Override Can Exfiltrate Credentials and Video Data
- Content
View full analysis
dict[str, str]: headers: dict[str, str] = { "Accept": "application/json", "User-Agent": "byted-airesearch-videoeval/0.1", PRODUCT_VERSION_HEADER: PRODUCT_VERSION_VALUE, } resolved_api_key = resolve_api_key(api_key) headers["Authorization"] = f"bearer {resolved_api_key}" return headers def build_url(path: str) -> str: if path.startswith("http://") or path.startswith("https://"): return path return f"{BASE_URL}{path}" ``` The resulting session is used to upload files: ```python session = create_session(api_key) url = build_url(UPLOAD_PATH) with open(file_path, "rb") as file_obj: files = { "file": (os.path.basename(file_path), file_obj, ALLOWED_MIME_TYPE) } response = session.post(url, files=files, timeout=timeout) ``` ### Technical Analysis The environment variable `BYTED_AIRESEARCH_VIDEOEVAL_BASE_URL` controls the destination of every API request. Its value is not validated against an allowlist and is not required to use HTTPS. At the same time, `create_session()` installs the supplied API key into the session-wide `Authorization` header. Consequently, setting the base URL to an attacker-controlled server causes the API key to be sent directly to that server. During submission, the selected video file is also transmitted to the same destin ...[truncated 1638 chars]- Remediation
View remediation
