T09 · Insecure Skill Coding Practices
- Location
scripts/meeting_assistant.py:30- Finding
Unrestricted API Base URL Can Expose Credentials and Confidential Meeting Data
- Content
View full analysis
dict: return { "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json", } ``` ```python url = f"{DEFAULT_API_BASE}/v1/audio/transcriptions" files = {"file": (audio_path.name, audio_data)} data = {"model": "whisper-1", "language": language} headers = {"Authorization": f"Bearer {API_KEY}"} if API_KEY else {} response = requests.post(url, files=files, data=data, headers=headers) ``` ```python url = f"{DEFAULT_API_BASE}/v1/chat/completions" payload = { "model": "gpt-4o", "messages": [ {"role": "system", "content": system_prompt}, {"role": "user", "content": user_message}, ], "temperature": 0.3, } response = requests.post(url, json=payload, headers=get_headers()) ``` ```python url = f"{DEFAULT_API_BASE}/v1/chat/completions" payload = { "model": "gpt-4o", "messages": [ {"role": "system", "content": system_prompt}, {"role": "user", "content": f"Please extract todos from the following meeting content:\n\n{transcript}"}, ], "temperature": 0.2, "response_format": {"type": "json_object"}, } response = requests.post(url, json=payload, headers=get_headers()) ``` ### Technical Analysis The destination used for every API request is read directly from the `ASTRONCLAW_API_BASE` environment variable. The value is not validated before the application appends an API route and submits a request. The implementation does not enforce: - The HTTPS scheme. - The documented AstronClaw hostname. - An allowlist of trusted API hosts. - ...[truncated 2262 chars]- Remediation
View remediation
str: parsed = urlparse(value) if parsed.scheme != "https": raise ValueError("The API base URL must use HTTPS") if parsed.hostname not in ALLOWED_API_HOSTS: raise ValueError("The API hostname is not approved") if parsed.username or parsed.password or parsed.fragment: raise ValueError("The API base URL contains prohibited components") return value.rstrip("/") ``` Requests should also use a finite timeout and either disable redirects or validate them explicitly: ```python response = requests.post( url, json=payload, headers=get_headers(), timeout=(5, 120), allow_redirects=False, ) ``` ]]>
