T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/collect_air_data.py:46
- Finding
- Disabled TLS Verification Exposes the Dirigera Bearer Token<![CDATA[ ## Vulnerability Details **File Location**: `scripts/collect_air_data.py`, lines 46-49 **Vulnerability Type**: TLS certificate validation disabled for an authenticated request **Risk Level**: High ### Vulnerable Code ```python # Create SSL context that ignores certificate verification ssl_context = ssl.create_default_context() ssl_context.check_hostname = False ssl_context.verify_mode = ssl.CERT_NONE ``` The resulting context is subsequently used for the request containing the bearer token: ```python req = urllib.request.Request(url, headers=headers) with urllib.request.urlopen(req, context=ssl_context, timeout=30) as response: devices = json.loads(response.read().decode('utf-8')) ``` ### Technical Analysis The collector transmits a bearer token in the `Authorization` header while explicitly disabling both certificate-chain validation and hostname verification. Consequently, the client cannot establish that it is communicating with the legitimate Dirigera hub. Although the destination is a private LAN address, local network traffic is not inherently trustworthy. An attacker capable of manipulating local routing, ARP resolution, or network infrastructure can impersonate the hub using any TLS certificate. The client will accept that certificate and disclose its bearer token. The attacker can also return fabricated device data. Because accepted readings are written to the SQLite database and may later be included in reports, this affects both credential confidentiality and data integrity. ### Attack Path 1. The attacker gains access to the same local network or compromises a router, access point, or other device able to manipulate traffic. 2. The attacker redirects traffic intended for `192.168.1.100:8443`, such as through ARP spoofing or routing manipulation. 3. The attacker presents an arbitrary TLS certificate while impersonating the Dirigera API. 4. The collector accepts the certificate because certificate and hostname verification are d ...[truncated 794 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Keep certificate-chain and hostname validation enabled. - Configure the client to trust the Dirigera hub's certificate or its issuing CA explicitly. - If the device uses a self-signed certificate, pin the expected certificate or public-key fingerprint and fail closed if it changes. - Do not fall back to an unverified connection when validation fails. - Restrict the token file to the account running the collector, preferably with permissions equivalent to `0600`. - Use a token with the minimum Dirigera API permissions required to read environmental sensor data. - Rotate the existing token if it may previously have traversed an untrusted local network. - Avoid logging authorization headers or token values in future error-handling changes. ]]>
