T09 · Insecure Skill Coding Practices
- Location
commands/query.py:51- Finding
SQL Server Connection Does Not Enforce Verified Encryption
- Content
View full analysis
Vulnerability Details
File Location:
commands/query.py, lines 51-58
Vulnerability Type: Insecure transport of database credentials and business data
Risk Level: Mediumpython def connect_to_db() -> pyodbc.Connection: """返回一个新的 pyodbc 连接""" conn_str = ( f"DRIVER={{SQL Server}};" f"SERVER={SQL_SERVER};" f"DATABASE={SQL_DATABASE};" f"UID={SQL_USER};" f"PWD={SQL_PASSWORD}" ) return pyodbc.connect(conn_str, timeout=30)Technical Analysis
The Skill must connect to SQL Server to provide its declared passenger-flow query functionality, so network access and use of database credentials are functionally necessary. However, the connection string uses the legacy generic
SQL Serverdriver and does not explicitly require TLS encryption or server-certificate validation.The absence of settings such as
Encrypt=yesandTrustServerCertificate=nomeans the code does not guarantee that credentials, query parameters, and returned records are protected by authenticated encryption. The server destination is also taken from theMY_SQL_SERVERenvironment variable without application-level destination validation.This is an insecure coding and configuration issue rather than evidence of intentional exfiltration. The reviewed code does not send data to any hardcoded attacker-controlled service.
Attack Path
- An attacker obtains a network interception position between the Skill host and the configured SQL Server, or gains the ability to alter the
MY_SQL_SERVERenvironment variable. - The Skill invokes
connect_to_db()while processing a passenger-flow query. - The client opens a database connection without explicitly requiring verified TLS.
- Depending on the installed driver and server configuration, the attacker may observe or manipulate database traffic, or redirect the connection toward an unintended server.
- Database credenti ...[truncated 845 chars]
- An attacker obtains a network interception position between the Skill host and the configured SQL Server, or gains the ability to alter the
- Remediation
View remediation
Remediation Suggestions
-
Use a currently supported Microsoft SQL Server ODBC driver, such as ODBC Driver 18.
-
Require encrypted transport and certificate validation:
python conn_str = ( "DRIVER={ODBC Driver 18 for SQL Server};" f"SERVER={SQL_SERVER};" f"DATABASE={SQL_DATABASE};" f"UID={SQL_USER};" f"PWD={SQL_PASSWORD};" "Encrypt=yes;" "TrustServerCertificate=no;" ) -
Configure the SQL Server with a certificate issued by a trusted authority whose hostname or subject alternative name matches the configured server.
-
Do not use
TrustServerCertificate=yesas a permanent workaround, because it encrypts traffic without securely authenticating the destination. -
Restrict outbound network access so the Skill can connect only to the approved SQL Server host and port.
-
Validate the configured server against an administrator-controlled allowlist where deployment requirements permit it.
-
Use a dedicated least-privileged database account authorized only to connect to the required database and execute
openclaw_fetch_zwc_keliu. -
Rotate the database password if there is evidence that the Skill was previously used over an untrusted network.
-
