T09 · Insecure Skill Coding Practices
Error
- Location
- bilibili_up_master.py:16
- Finding
- Process-Wide TLS Certificate Verification Disabled## Vulnerability Details **File Location**: `bilibili_up_master.py`, lines 16-17 **Vulnerability Type**: Global TLS verification bypass **Risk Level**: High ### Vulnerable Code ```python ssl._create_default_https_context = ssl._create_unverified_context ``` ### Technical Analysis The module replaces Python's default HTTPS context factory with an unverified context. Consequently, HTTPS requests made through compatible standard-library clients after this module is imported may no longer validate server certificates or host identity. This modification is process-wide rather than limited to a single Bilibili request. Even though the audited implementation does not currently invoke `urllib.request`, another component running in the same process could rely on the modified default context. An attacker capable of intercepting network traffic could then present an untrusted certificate without causing certificate validation to fail. ### Attack Path 1. The application or Agent imports `bilibili_up_master.py`. 2. The module globally replaces the default verified HTTPS context. 3. The same process subsequently performs an HTTPS request through a client that uses this default context. 4. An attacker with a privileged network position intercepts the connection and presents an invalid or attacker-controlled certificate. 5. The client accepts the certificate, allowing the attacker to observe or modify HTTPS traffic. ### Impact Assessment Successful exploitation could compromise the confidentiality and integrity of HTTPS traffic originating from the affected process. Depending on later requests, exposed information could include API responses, session identifiers, authentication material, or user data. Modified responses could also influence downstream application behavior. The flaw does not independently grant local code execution or elevated operating-system privileges. Its scope is limited to compatible HTTPS operations performe ...[truncated 64 chars]
- Remediation
- ## Remediation Suggestions - Remove the assignment to `ssl._create_default_https_context`. - Use Python's verified default TLS behavior. - If a private certificate authority is required, create a narrowly scoped context with `ssl.create_default_context(cafile="trusted-ca.pem")`. - Pass any custom context only to the specific request that requires it rather than changing process-wide behavior. - Do not provide an option that silently disables certificate or hostname validation. - Add a regression test confirming that requests made with an invalid or self-signed certificate fail verification.
