T09 · Insecure Skill Coding Practices
- Location
scripts/get_data.py:73- Finding
TLS Certificate and Hostname Verification Are Disabled
- Content
View full analysis
List[ssl.SSLContext]: """构建多个 SSL 上下文,按宽松度递增排列,用于自动 fallback.""" ctxs: List[ssl.SSLContext] = [] # 策略 1: 默认上下文 + 关闭证书校验 try: c1 = ssl.create_default_context() c1.check_hostname = False c1.verify_mode = ssl.CERT_NONE ctxs.append(c1) except Exception: pass # 策略 2: 完全不验证的上下文(兼容旧 OpenSSL) try: c2 = ssl._create_unverified_context() # noqa: SLF001 ctxs.append(c2) except Exception: pass ``` These insecure contexts are subsequently used for API requests in `scripts/get_data.py`, lines 128–139: ```python for ctx in _SSL_CONTEXTS: opener = urllib_request.build_opener( urllib_request.ProxyHandler({}), urllib_request.HTTPSHandler(context=ctx), ) for attempt in range(_MAX_RETRIES): try: with opener.open(req, timeout=TIMEOUT_SECONDS) as resp: raw = resp.read().decode("utf-8", errors="replace") ``` ### Technical Analysis Both SSL contexts accepted by the HTTP layer explicitly disable certificate validation. The first context turns off hostname matching and assigns `ssl.CERT_NONE`; the second uses Python's private unverified-context function. Consequently, the client does not establish that it is communicating with the legitimate API server. Despite being described as fallback strategies, no verified TLS context is attempted. An invalid, self-signed, expired, or attacker-controlled certificate is accepted immediately. Disabling the system proxy does not provide server authentication and can also bypass security controls expected in managed environments. The affected requests retrieve manifests, issue resolution results, and issue information. These responses are trusted as JSON and incorpora ...[truncated 1361 chars]- Remediation
View remediation
