T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/sitemap_gen.py:72
- Finding
- TLS Certificate and Hostname Verification Disabled<![CDATA[ ## Vulnerability Details **File Location**: `scripts/sitemap_gen.py`, lines 72–74 **Vulnerability Type**: Improper TLS certificate validation **Risk Level**: High ### Vulnerable Code ```python ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE ``` ### Technical Analysis The crawler explicitly disables both TLS certificate-chain validation and hostname verification for every HTTPS request. Consequently, it accepts expired, self-signed, untrusted, and hostname-mismatched certificates. HTTPS encryption without certificate validation does not authenticate the remote server. An attacker capable of intercepting network traffic can impersonate the requested website and return attacker-controlled HTML. Because the crawler parses links from successful HTML responses, the attacker can manipulate discovered pages and generated sitemap content. ### Attack Path 1. A user invokes the Skill to crawl an HTTPS website. 2. An attacker gains a network interception position, such as through a malicious access point, compromised proxy, DNS manipulation, or local network control. 3. The attacker presents an arbitrary TLS certificate for the requested hostname. 4. The crawler accepts the certificate because certificate and hostname checks are disabled. 5. The attacker supplies modified HTML containing selected same-domain links and query strings. 6. The crawler parses those links, makes additional requests, and incorporates successful URLs into the generated sitemap. ### Impact Assessment The attacker does not directly obtain operating-system privileges through this flaw. However, an on-path attacker can: - Impersonate any HTTPS website crawled by the tool. - Read requested paths and query strings. - Modify crawler responses and discovered URL sets. - Inject misleading or attacker-selected URLs into sitemap, text, or JSON output. - Influence subsequent network requests made by the crawler. - Undermine the confidentiality ...[truncated 117 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions Retain Python's secure default TLS behavior: ```python ctx = ssl.create_default_context() ``` Do not assign `ssl.CERT_NONE`, and do not disable `check_hostname`. The request can then continue to use the verified context: ```python resp = urllib.request.urlopen(req, timeout=timeout, context=ctx) ``` Additional hardening measures include: 1. Fail closed when certificate validation fails. 2. Return or log a clear TLS validation error without silently retrying insecurely. 3. Use the operating system's trusted certificate store. 4. If private development certificates must be supported, allow the user to provide an explicit CA bundle rather than disabling verification globally. 5. If an insecure testing mode is considered unavoidable, require an explicit command-line option, display a prominent warning, and ensure it is disabled by default. 6. Add automated tests confirming rejection of self-signed, expired, and hostname-mismatched certificates. ]]>
