T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/voiceclone.py:49
- Finding
- Plaintext HTTP Transmission of Credentials, Access Tokens, and Biometric Voice Data<![CDATA[ ## Vulnerability Details **File Location**: `scripts/voiceclone.py`, lines 49–50, 239–247, 269–286, and 348–400 **Vulnerability Type**: Plaintext transmission of sensitive information **Risk Level**: High ### Vulnerable Code ```python TRAIN_BASE_URL = "http://opentrain.xfyousheng.com/voice_train" AUTH_TOKEN_URL = "http://avatar-hci.xfyousheng.com/aiauth/v1/token" ``` The authentication request is sent to the plaintext HTTP endpoint: ```python req = urllib.request.Request( AUTH_TOKEN_URL, data=body_json.encode("utf-8"), headers={ "Authorization": sign, "Content-Type": "application/json", }, ) with urllib.request.urlopen(req, timeout=30) as resp: result = json.loads(resp.read().decode("utf-8")) ``` Subsequent training requests include an access token and application identifier: ```python def _headers(self, sign: str) -> dict: return { "X-Sign": sign, "X-Token": self.token, "X-AppId": self.app_id, "X-Time": str(self._ts), "Content-Type": "application/json", } def _post(self, path: str, body: dict) -> dict: """POST JSON to training API.""" self._ensure_token() sign = self._sign_body(body) headers = self._headers(sign) data = json.dumps(body).encode("utf-8") req = urllib.request.Request( TRAIN_BASE_URL + path, data=data, headers=headers, ) with urllib.request.urlopen(req, timeout=60) as resp: return json.loads(resp.read().decode("utf-8")) ``` Local biometric voice recordings are also loaded and transmitted to the plaintext training endpoint: ```python with open(audio_path, "rb") as f: audio_data = f.read() ``` ```python headers = { "X-Sign": sign, "X-Token": self.token, "X-AppId": self.app_id, "X-Time": str(ts), "Content-Type": f"multipart/form-data; boundary={boundary}", } req = urllib.request.Request( TRAIN_BASE_URL + "/task/submitWithAudio", data=body_bytes, hea ...[truncated 2584 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Replace both plaintext endpoints with provider-supported HTTPS endpoints: ```python TRAIN_BASE_URL = "https://opentrain.xfyousheng.com/voice_train" AUTH_TOKEN_URL = "https://avatar-hci.xfyousheng.com/aiauth/v1/token" ``` 2. Confirm that the provider officially supports TLS on these endpoints before deployment. Do not silently fall back to HTTP if HTTPS fails. 3. Reject redirects from HTTPS to HTTP. Validate the final URL scheme and expected hostname for every request. 4. Retain Python's default certificate-chain and hostname validation. Do not install permissive SSL contexts. 5. If the provider does not offer authenticated HTTPS, do not transmit credentials or biometric recordings directly. Use a trusted, TLS-protected gateway under the operator's control or discontinue the integration. 6. Minimize token lifetime and scope where supported, and ensure server-side timestamp and nonce validation prevents replay. 7. Clearly notify users before uploading voice recordings, identify the destination service, and document the service's biometric-data retention and deletion controls. ]]>
