T09 · Insecure Skill Coding Practices
- Location
scripts/net_http.py:12- Finding
HTTPS certificate and hostname verification disabled in HTTP inspection
- Content
View full analysis
Vulnerability Details
File Location:
scripts/net_http.py, lines 12–18
Vulnerability Type: Improper TLS certificate validation
Risk Level: Highpython 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
--followis 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.urlopenfollows redirects by default, independently of the disabled TLS settings.Attack Path
- A user invokes
net_http.pyfor an HTTPS endpoint without--follow. - An attacker able to influence the network path, DNS resolution, proxy, or destination endpoint intercepts the request.
- The attacker presents an arbitrary TLS certificate.
- The script accepts the certificate because chain and hostname verification are disabled.
- The attacker supplies forged status codes, headers, redirects, or response-body content.
- 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]
- A user invokes
- Remediation
View remediation
Remediation Suggestions
- Retain the secure defaults provided by
ssl.create_default_context(); do not setcheck_hostnametoFalseorverify_modetossl.CERT_NONE. - Implement redirect suppression separately with a custom
urllib.request.HTTPRedirectHandlerrather 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
--followoption.
- Retain the secure defaults provided by
