T09 · Insecure Skill Coding Practices
- Location
scripts/douyinlive.py:193- Finding
TLS Certificate Verification Disabled for Douyin WebSocket Connection
- Content
View full analysis
Vulnerability Details
File Location:
scripts/douyinlive.py, lines 193-206
Vulnerability Type: Improper certificate validation
Risk Level: HighVulnerable Code
python def send_websocket(self, room_id, sign, ttwid): cookie = f"ttwid={ttwid}" ws_url = f"wss://webcast100-ws-web-lq.douyin.com/webcast/im/push/v2/?app_name=douyin_web&version_code=180800&room_id={room_id}&signature={sign}" self.ws = websocket.WebSocketApp( ws_url, header=self.headers, cookie=cookie, on_open=self.on_open, on_message=self.on_message, on_error=self.on_error, on_close=self.on_close ) self.ws.run_forever(sslopt={'cert_reqs': ssl.CERT_NONE})The actual WebSocket URL contains additional protocol parameters, but the security-relevant connection behavior is the explicit use of
ssl.CERT_NONE.Technical Analysis
The WebSocket client disables TLS certificate verification for a connection carrying a Douyin session cookie, anti-bot signature, room identifier, acknowledgements, and live-room messages. Encryption without certificate validation does not authenticate the remote endpoint.
This exceeds the minimum privileges and network behavior required by the Skill. Receiving live comments requires a WebSocket connection, but it does not require accepting arbitrary or self-signed server certificates.
The error handler also silently discards errors:
python def on_error(self, ws, error): passThis makes certificate and connection anomalies harder for operators to detect.
Attack Path
- An attacker obtains a network interception position, such as through a malicious proxy, compromised router, hostile Wi-Fi access point, or DNS manipulation.
- The attacker redirects or intercepts the WebSocket connection.
- The attacker presents a certificate that is not trusted for the Douyin hostname.
- B ...[truncated 956 chars]
- Remediation
View remediation
Remediation Suggestions
-
Remove the certificate override and use the platform trust store:
python self.ws.run_forever() -
If explicit TLS options are necessary, require certificate validation:
python self.ws.run_forever( sslopt={ "cert_reqs": ssl.CERT_REQUIRED, "check_hostname": True } ) -
Do not silently suppress connection errors. Log sanitized certificate and connection failures without exposing cookies or signatures.
-
Add connection timeouts, message-size limits, and exception handling around gzip and protobuf parsing.
-
Test that invalid, expired, hostname-mismatched, and self-signed certificates are rejected.
-
