T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/sticker.py:38
- Finding
- HTTPS Requests Fall Back to Disabled Certificate Verification<![CDATA[ ## Vulnerability Details **File Location**: `scripts/sticker.py`, lines 38–42 **Vulnerability Type**: Improper TLS certificate validation **Risk Level**: High ### Vulnerable Code ```python # Last resort: skip verification ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE return ctx ``` ### Technical Analysis When the script cannot locate a usable CA certificate file, `_ssl_context()` silently creates an SSL context that disables both certificate verification and hostname validation. This context is subsequently used by the Tenor search and arbitrary URL download functions. Disabling `verify_mode` allows a server with an untrusted, expired, self-signed, or otherwise invalid certificate to be treated as legitimate. Disabling `check_hostname` also permits a certificate issued for an unrelated hostname. ### Attack Path 1. The script runs in an environment where none of the enumerated CA files is available and `certifi` is unavailable or unusable. 2. A user or agent invokes `search-online`, `search`, or `download`. 3. `_ssl_context()` reaches its fallback and returns a context with certificate checks disabled. 4. An attacker with a network interception position presents an arbitrary certificate. 5. The script accepts the certificate and exchanges data with the attacker-controlled endpoint. 6. The attacker can observe search terms and the Tenor API key or replace downloaded sticker data. ### Impact Assessment A network-positioned attacker can compromise the confidentiality and integrity of affected HTTPS traffic. The attacker may obtain search queries and the API key, manipulate Tenor responses, or substitute malicious and misleading content for downloaded files. This does not directly execute the downloaded content, but it compromises all security guarantees normally provided by TLS. ]]>
- Remediation
- <![CDATA[ ## Remediation Suggestions - Remove the `CERT_NONE` fallback entirely. - Use `ssl.create_default_context()` with the operating system's trusted certificate store. - If a valid trust store cannot be initialized, fail closed and return a clear error. - Do not disable hostname validation under any circumstances. - Add automated tests confirming that self-signed, expired, and hostname-mismatched certificates are rejected. - Consider allowing a custom CA bundle only through an explicitly configured and trusted path. ]]>
