T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/extract_transcript.py:87
- Finding
- TLS Certificate Verification Is Disabled for yt-dlp Requests<![CDATA[ ## Vulnerability Details **File Location**: `scripts/extract_transcript.py:87` **Vulnerability Type**: Improper certificate validation **Risk Level**: High ### Vulnerable Code ```python self.ydl_opts = { 'writesubtitles': True, 'writeannotations': True, 'writeautomaticsub': True, 'subtitleslangs': ['en', 'en-US', 'en-CA'], 'skip_download': True, 'quiet': False, 'no_warnings': False, 'no_playlist': True, # Enhanced reliability (from user's yt-dlp config) 'nocheckcertificate': True, # Bypass SSL issues 'retries': 100, 'fragment_retries': 100, 'continuedl': True, } # Add cookies if provided and file exists if cookies_path and os.path.isfile(cookies_path): print(f'Using cookies from: {cookies_path}') self.ydl_opts['cookiefile'] = cookies_path ``` ### Technical Analysis The `nocheckcertificate` option disables TLS certificate validation for network operations performed by `yt-dlp`. The client may consequently accept an invalid, self-signed, expired, or attacker-controlled certificate instead of verifying that the remote endpoint is authentic. The risk is elevated by the optional cookie-file feature. When a user supplies an authenticated YouTube cookie file, `yt-dlp` may attach applicable session cookies to requests. A network attacker capable of redirecting or intercepting these requests could impersonate the expected server because the presented certificate is not validated. The same weakness also compromises response integrity. An attacker could alter retrieved metadata, subtitle URLs, or other content consumed by the extractor. ### Attack Path 1. A user invokes the extraction script, potentially with `--cookies` to access restricted content. 2. An attacker obtains a privileged network position, controls a configured proxy, compromises DNS resolution, or otherwise redirects outbound traffic. 3. The attacker presents a certificate that would normally fail trust or hostname validation. 4 ...[truncated 866 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the insecure option entirely: ```python # Remove this setting: 'nocheckcertificate': True, ``` 2. Retain the default TLS certificate and hostname validation behavior of `yt-dlp`. 3. If certificate validation fails, repair the system trust store or install an up-to-date CA bundle rather than bypassing validation. 4. Ensure HTTPS proxies are explicitly trusted and centrally controlled where a proxy is required. 5. Avoid using exported account cookies unless necessary. Use a dedicated, minimally privileged account for restricted content. 6. Protect cookie files with restrictive filesystem permissions and delete them when no longer needed. 7. Add a regression test or configuration assertion that rejects `nocheckcertificate`, equivalent certificate-bypass options, and insecure HTTP endpoints. ]]>
