T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/monitor.py:29
- Finding
- HTTPS Certificate Validation Is Disabled<![CDATA[ ## Vulnerability Details **File Location**: `scripts/monitor.py`, lines 29-32 **Vulnerability Type**: Improper certificate validation **Risk Level**: High ### Vulnerable Code ```python # Create SSL context that doesn't verify certificates ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE with urlopen(req, timeout=30, context=ctx) as resp: ``` ### Technical Analysis The monitor explicitly disables both TLS certificate verification and hostname validation. Consequently, HTTPS connections provide encryption without reliable server authentication. The application will accept expired, self-signed, forged, or hostname-mismatched certificates. This behavior contradicts the documented claim that HTTPS fetching is secure. An attacker with a privileged network position—such as control over a proxy, gateway, DNS response, or hostile wireless network—can impersonate the monitored server and return arbitrary content. ### Attack Path 1. A user configures the monitor to retrieve an HTTPS page. 2. An attacker obtains a network position capable of intercepting or redirecting the connection. 3. The attacker presents a forged or self-signed TLS certificate. 4. The monitor accepts the certificate because certificate and hostname checks are disabled. 5. The attacker supplies modified page content. 6. The altered content produces a different hash and can trigger false change notifications or be stored in the configured output file. ### Impact Assessment An attacker can compromise the integrity and authenticity of every HTTPS response processed by the monitor. This can produce false monitoring results, suppress legitimate changes, trigger notification commands, and contaminate persisted snapshots. The issue does not directly grant local privileges, but it allows remote manipulation of security-relevant application behavior. ]]>
- Remediation
- <![CDATA[ ## Remediation Suggestions - Remove the assignments to `check_hostname` and `verify_mode`. - Use Python's default verified TLS context: ```python ctx = ssl.create_default_context() with urlopen(req, timeout=30, context=ctx) as resp: ... ``` - Do not offer an insecure mode by default. If a development-only override is necessary, require an explicit option, display a prominent warning, and prevent its use in production automation. - Add tests confirming that self-signed, expired, and hostname-mismatched certificates are rejected. - Update the documentation to describe the actual TLS verification behavior. ]]>
