T09 · Insecure Skill Coding Practices
Error
- Location
- run.py:41
- Finding
- Database Connections Do Not Explicitly Enforce TLS Certificate Validation<![CDATA[ ## Vulnerability Details **File Location**: `run.py`, lines 41-44 **Vulnerability Type**: Sensitive information transmitted without explicitly enforced TLS protection **Risk Level**: High ### Vulnerable Code ```python # Security Fix: Use standard SSL conn = pymysql.connect( host=host, port=port, user=user, password=password, database=db, charset='utf8mb4', autocommit=True ) ``` ### Technical Analysis The connection passes database credentials to PyMySQL but does not supply an `ssl` configuration, trusted CA certificate, certificate-verification requirement, or hostname-verification setting. The comment claiming that standard SSL is used does not itself enable or enforce TLS. The connection transmits the database username, password, preference keys, and preference values to a remote database. Without explicit TLS enforcement and certificate validation, transport security depends on external server or client defaults and is not guaranteed by the Skill. This violates secure-by-default principles for a feature designed to store potentially personal information. Remote database access is necessary for the declared synchronization functionality, but sending credentials and user information without enforcing a verified encrypted channel exceeds an acceptable minimum-risk implementation. ### Attack Path 1. A user invokes the Skill to set, retrieve, or list preferences. 2. The Skill parses the DSN and opens a connection to the configured remote database. 3. An attacker with a suitable network interception position redirects, observes, or tampers with the database connection. 4. If the connection is accepted without verified TLS, the attacker can capture database credentials and preference data or impersonate the database endpoint. 5. The stolen credentials can then be used to connect directly to the database and access or alter the `user_prefs` table. ### Impact Assessment Successful exploitation may expose the database username and password a ...[truncated 423 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Require TLS for every database connection. - Configure PyMySQL with a trusted CA bundle and enable certificate and hostname verification. - Fail closed if a verified TLS connection cannot be established. - Do not silently fall back to plaintext transport. - Restrict the database account to the intended database and minimum operations required on `user_prefs`. - Document the required TLS configuration for both user-provided and automatically provisioned databases. - Add an integration test that verifies rejected connections when the server certificate is invalid, untrusted, or issued for another hostname. A hardened connection should use an explicit SSL context or equivalent PyMySQL configuration that requires a trusted certificate and hostname validation. ]]>
