T09 · Insecure Skill Coding Practices
Error
- Location
- music_downloader.py:15
- Finding
- TLS Certificate Verification Is Disabled for All Network Requests<![CDATA[ ## Vulnerability Details **File Location**: `music_downloader.py:15, 34-37, 63-65, 73-75, 91-93, 101-103, 119-121, 129-131, 149-151, 156-158, 166-168, 187-189, 194-196, 208-210, 221-223, 230-232, 244-246, 256-258, 269-271, 280-282, 296-298, 311-313, 324-326, 378-380` **Vulnerability Type**: Improper TLS certificate validation **Risk Level**: High ### Vulnerable Code The code globally suppresses warnings and explicitly disables certificate verification throughout the search, API, URL-resolution, and download workflows: ```python warnings.filterwarnings('ignore') ``` Representative search request: ```python def search_thttt(self, keyword: str) -> List[Dict]: try: url = f"https://www.thttt.com/so.php?wd={quote(keyword)}" resp = self.session.get(url, timeout=15, verify=False) html = resp.text ``` Representative API request: ```python def get_url_thttt(self, hash_code: str) -> Optional[str]: try: url = "https://www.thttt.com/style/js/play.php" resp = self.session.post( url, data={'id': hash_code, 'type': 'dance'}, timeout=15, verify=False ) result = resp.json() ``` The final media download also disables certificate verification: ```python try: resp = self.session.get( url, headers=headers, timeout=60, stream=True, verify=False ) resp.raise_for_status() ``` The same `verify=False` setting appears in every provider integration at lines 37, 65, 75, 93, 103, 121, 131, 151, 158, 168, 189, 196, 210, 223, 232, 246, 258, 271, 282, 298, 313, 326, and 380. ### Technical Analysis The `verify=False` argument instructs Requests not to authenticate the certificate presented by an HTTPS server. Encryption may still be negotiated, but the client cannot establish that it is communicating with the intended provider rather than an impersonating server. Because verification is disabled during both meta ...[truncated 1720 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove `verify=False` from all `self.session.get()` and `self.session.post()` calls. Requests should use its default certificate validation: ```python resp = self.session.get(url, timeout=15) ``` 2. Remove the global warning suppression: ```python warnings.filterwarnings('ignore') ``` If warning filtering is needed for unrelated reasons, suppress only a narrowly identified warning at the smallest possible scope. 3. If a specific provider requires a private certificate authority, configure a dedicated CA bundle only for that provider: ```python resp = self.session.get( url, timeout=15, verify="/path/to/provider-ca-bundle.pem" ) ``` 4. Do not use an unverified connection as a compatibility fallback. Treat certificate failures as provider failures and continue to the next source. 5. Keep the operating system and Python CA trust store current. 6. Add automated tests that use an untrusted test certificate and verify that search, API, and download requests fail securely. ]]>
