T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/get_password_from_user.py:553
- Finding
- LAN Secret Intake Uses an Unverifiable Self-Signed TLS Certificate<![CDATA[ ## Vulnerability Details **File Location**: `scripts/get_password_from_user.py:553-585, 657-659` **Vulnerability Type**: Unauthenticated TLS endpoint for sensitive credential collection **Risk Level**: High ### Vulnerable Code ```python def ensure_self_signed_cert(hostname: str, cert_dir: str): cert_path = os.path.join(cert_dir, "cert.pem") key_path = os.path.join(cert_dir, "key.pem") openssl = shutil.which("openssl") if openssl is None: raise RuntimeError("openssl is required to generate a self-signed cert") san = "DNS:localhost,IP:127.0.0.1" try: ipaddress.ip_address(hostname) san = f"IP:{hostname},DNS:localhost,IP:127.0.0.1" except ValueError: san = f"DNS:{hostname},DNS:localhost,IP:127.0.0.1" subprocess.run( [ openssl, "req", "-x509", "-newkey", "rsa:2048", "-sha256", "-days", "1", "-nodes", "-keyout", key_path, "-out", cert_path, "-subj", f"/CN={hostname}", "-addext", f"subjectAltName={san}", ], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) return cert_path, key_path ``` The generated certificate is then used directly by the intake server: ```python context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) context.load_cert_chain(certfile=cert_path, keyfile=key_path) httpd.socket = context.wrap_socket(httpd.socket, server_side=True) ``` ### Technical Analysis The LAN-mode intake page collects both an account secret and a current TOTP code. A new self-signed certificate is generated for every execution, but the implementation provides no trusted certificate authority, previously trusted public key, pinned fingerprint, or authenticated out-of-band verification procedure. TLS encryption without authenticated server ...[truncated 1947 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Make localhost-only intake the preferred and safest operating mode. 2. For LAN mode, use a certificate whose identity can be verified: - Issue the server certificate from a locally trusted private CA; or - Provision a persistent certificate and pin its public-key fingerprint in a previously authenticated setup step; or - Use an authenticated secure transport that already establishes server identity. 3. Communicate any certificate fingerprint through a channel independent of the LAN connection and require the user to verify it before entering credentials. 4. Do not instruct users to bypass an unverifiable browser certificate warning. 5. Consider requiring a challenge bound to the specific intake session in addition to TOTP. This complements, but does not replace, authenticated TLS. 6. Document the LAN threat model and explicitly state that subnet filtering and TOTP do not prevent man-in-the-middle interception. ]]>
