T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/net_http.py:12
- Finding
- HTTPS certificate and hostname verification disabled in HTTP inspection## Vulnerability Details **File Location**: `scripts/net_http.py`, lines 12–18 **Vulnerability Type**: Improper TLS certificate validation **Risk Level**: High ```python try: if follow: resp = urllib.request.urlopen(req, timeout=timeout) else: ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE resp = urllib.request.urlopen(req, timeout=timeout, context=ctx) ``` ### Technical Analysis The default execution path, used when `--follow` is not specified, explicitly disables both certificate-chain validation and hostname verification. Consequently, an HTTPS connection succeeds even when the server presents a self-signed, forged, expired, or wrong-host certificate. This behavior is unnecessary for ordinary HTTP diagnostics and violates secure-by-default TLS handling. It also does not correctly implement the documented redirect option: `urllib.request.urlopen` follows redirects by default, independently of the disabled TLS settings. ### Attack Path 1. A user invokes `net_http.py` for an HTTPS endpoint without `--follow`. 2. An attacker able to influence the network path, DNS resolution, proxy, or destination endpoint intercepts the request. 3. The attacker presents an arbitrary TLS certificate. 4. The script accepts the certificate because chain and hostname verification are disabled. 5. The attacker supplies forged status codes, headers, redirects, or response-body content. 6. The script displays the attacker-controlled response as if it originated from the requested HTTPS endpoint. ### Impact Assessment Exploitation requires control over, or influence on, the network path, name resolution, proxy configuration, or destination server. It does not directly grant local operating-system privileges or code execution. However, it destroys the authenticity and integrity guarantees expected from HTTPS. An attacker can falsify d ...[truncated 180 chars]
- Remediation
- ## Remediation Suggestions - Retain the secure defaults provided by `ssl.create_default_context()`; do not set `check_hostname` to `False` or `verify_mode` to `ssl.CERT_NONE`. - Implement redirect suppression separately with a custom `urllib.request.HTTPRedirectHandler` rather than changing TLS validation. - Make verified HTTPS requests the default in every operational mode. - If unverified inspection is genuinely required, place it behind an explicit option such as `--insecure`, print a prominent warning, and label the resulting data as unauthenticated. - Add tests confirming rejection of self-signed, expired, and hostname-mismatched certificates. - Add separate tests verifying that redirect behavior matches the `--follow` option.
