T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/rwc.py:75
- Finding
- MQTT TLS Certificate Verification Is Explicitly Disabled<![CDATA[ ## Vulnerability Details **File Location**: `scripts/rwc.py:75-78` **Vulnerability Type**: Improper TLS certificate validation **Risk Level**: High ### Vulnerable Code ```python client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2) if self.code: client.username_pw_set("bblp", self.code) client.tls_set(cert_reqs=ssl.CERT_NONE) client.tls_insecure_set(True) return client ``` ### Technical Analysis The MQTT client enables TLS but explicitly disables certificate validation through both `cert_reqs=ssl.CERT_NONE` and `tls_insecure_set(True)`. Consequently, the client cannot authenticate that it is communicating with the intended ESP32 or MQTT broker. This defeats the identity-verification property of TLS. An attacker capable of intercepting local network traffic can present an arbitrary certificate, impersonate the broker, and observe or modify MQTT communications. The device access code is configured as the MQTT password and may be exposed during such an interception. Because this client sends physical actuator commands, successful interception can have effects beyond confidentiality loss. ### Attack Path 1. An attacker obtains a position on the same local network or otherwise gains the ability to redirect MQTT traffic. 2. The attacker redirects traffic intended for the configured device IP to a malicious MQTT broker. 3. The malicious broker presents an untrusted or self-signed certificate. 4. The client accepts the certificate because verification is disabled. 5. The client authenticates using the configured access code. 6. The attacker captures credentials, supplies forged telemetry, or receives and manipulates actuator commands. 7. The attacker can subsequently impersonate the broker or use recovered credentials to attempt unauthorized device control. ### Impact Assessment A successful attacker may obtain the MQTT device access code, compromise telemetry integrity, monitor device activity, and interfere with relay, servo, LED, bu ...[truncated 139 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Remove `tls_insecure_set(True)`. - Replace `ssl.CERT_NONE` with `ssl.CERT_REQUIRED`. - Configure a trusted CA certificate using `tls_set(ca_certs=...)` or a properly maintained system trust store. - Validate the expected broker hostname or device identity. - Use a private CA or certificate pinning where devices use locally issued certificates. - Fail closed when certificate verification cannot be completed. - Rotate existing device access codes if the client has operated on an untrusted network. - Consider mutual TLS so that both the device and client authenticate each other. ]]>
