T09 · Insecure Skill Coding Practices
- Location
scripts/clawhub_device_login.py:26- Finding
Disabled TLS Verification Exposes Device Authentication Tokens to Interception
- Content
View full analysis
Vulnerability Details
File Location:
scripts/clawhub_device_login.py, lines 26–28, with the insecure context used at lines 40 and 53
Vulnerability Type: Improper TLS certificate and hostname validation
Risk Level: HighComplete Code Snippet
python ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONEThe resulting context is used for both POST and GET requests:
python with urllib.request.urlopen(req, timeout=30, context=ctx) as r: return r.status, json.loads(r.read().decode("utf-8", "ignore"))python with urllib.request.urlopen(req, timeout=30, context=ctx) as r: return r.status, json.loads(r.read().decode("utf-8", "ignore"))The affected requests include service discovery and the device authorization flow:
python site = os.environ.get("CLAWHUB_SITE", "https://clawhub.ai") api_base, auth_base = discover(site) registry = api_base or site payload = {"scope": "read write", "site_url": auth_base, "label": "WorkBuddy CLI (agent)"} st, body = post(registry.rstrip("/") + "/api/cli/device/code", payload)python st, body = post(url, {"device_code": device_code, "grant_type": GRANT}) if st == 200 and body.get("access_token"): token = body["access_token"]Technical Analysis
The script explicitly disables both certificate-chain verification and hostname verification for every HTTPS request made through its shared SSL context. HTTPS therefore provides encryption without authenticated server identity.
This affects:
- Registry discovery through
/.well-known/clawhub.jsonor/.well-known/clawdhub.json - Device-code requests
- Device-token polling
- Responses containing the eventual read/write access token
Because discovery responses can supply
apiBaseorregistry, an intercepted response can also redirect subsequent authentication requests to an attacker-selected endpoint ...[truncated 1582 chars]- Registry discovery through
- Remediation
View remediation
Remediation Suggestions
-
Remove the insecure TLS overrides:
python ctx = ssl.create_default_context()Do not set
check_hostnametoFalseorverify_modetossl.CERT_NONE. -
Require all configured and discovered endpoints to use HTTPS.
-
Validate discovery results before use. By default, require
apiBase,registry, andauthBaseto remain on the expected trusted origin. Any cross-origin registry should require explicit user authorization and an allowlisted trusted host. -
Fail closed on certificate errors rather than retrying with disabled verification.
-
Avoid persisting authentication state when endpoint validation fails. If a token may have been exchanged over an unauthenticated connection, revoke it and require a new device authorization.
-
Add tests confirming that self-signed certificates, hostname mismatches, expired certificates, and untrusted discovery redirects are rejected.
-
