T09 · Insecure Skill Coding Practices
Error
- Location
- volc_ata.py:43
- Finding
- Unrestricted API Endpoint Can Expose Credentials and Private Media<![CDATA[ ## Vulnerability Details **File Location**: `volc_ata.py`, lines 43–47, 151–169, 208–221, and 277–288 **Vulnerability Type**: Unrestricted sensitive-data transmission endpoint **Risk Level**: High ### Vulnerable Code ```python # volc_ata.py:43-47 self.app_id = app_id or os.environ.get('VOLC_ATA_APP_ID') or self.config.get('credentials', 'appid', fallback=None) self.token = token or os.environ.get('VOLC_ATA_TOKEN') or self.config.get('credentials', 'access_token', fallback=None) self.api_base = api_base or os.environ.get('VOLC_ATA_API_BASE') or self.config.get('api', 'base_url', fallback='https://openspeech.bytedance.com') self.submit_path = self.config.get('api', 'submit_path', fallback='/api/v1/vc/ata/submit') self.query_path = self.config.get('api', 'query_path', fallback='/api/v1/vc/ata/query') ``` ```python # volc_ata.py:151-169 def _submit_task( self, audio_data: str, text: str, format: str, language: str ) -> str: """Submit ATA task to API""" url = f"{self.api_base}{self.submit_path}" payload = { "app": { "appid": self.app_id }, "audio": audio_data, "text": text, "format": format, "language": language } headers = { "Authorization": f"Bearer; {self.token}", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) response.raise_for_status() result = response.json() return result.get('id') ``` ```python # volc_ata.py:208-221 def _query_task(self, task_id: str) -> Dict[str, Any]: """Query task status""" url = f"{self.api_base}{self.query_path}" payload = { "id": task_id } headers = { "Authorization": f"Bearer; {self.token}", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) response.raise_for_status() return response.json() ``` ```python # volc_ata.py:277 ...[truncated 3712 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. **Allowlist the production endpoint** - Accept only the documented Volcengine hostname by default. - Compare the parsed hostname exactly rather than using substring or suffix checks. - Reject embedded URL credentials, fragments, unexpected ports, and malformed URLs. 2. **Require secure transport** - Reject any scheme other than HTTPS. - Retain TLS certificate verification. - Do not provide an option to disable certificate validation in normal operation. 3. **Separate custom endpoints from production credentials** - Do not automatically send a production bearer token to a custom endpoint. - If custom endpoints are required for testing, require an explicit development mode and separate test credentials. - Display the final parsed destination and require explicit confirmation before transmitting private media to a non-default host. 4. **Constrain API paths** - Prefer fixed submission and query paths for the production service. - If paths must remain configurable, validate that they are relative paths and cannot replace the scheme or authority. 5. **Control redirects** - Disable redirects for requests containing credentials, or validate every redirect destination before following it. - Never forward authorization information to a destination outside the approved origin. 6. **Add network safety controls** - Set explicit connection and response timeouts. - Consider rejecting loopback, link-local, private, and cloud metadata addresses when custom endpoints are enabled. - Apply outbound network policy at the runtime or container level where possible. 7. **Protect credentials operationally** - Prefer environment-based secret injection or a credential store over command-line tokens, which may appear in process listings and shell history. - Document the exact data transmitted to the cloud service. - Recommend narrowly scoped, short-lived tokens and immediate rotation after s ...[truncated 1087 chars]
