T09 · Insecure Skill Coding Practices
Error
- Location
- query_db.py:13
- Finding
- Hardcoded MySQL Root Credentials Exposed in Source and Process Arguments<![CDATA[ ## Vulnerability Details **File Location**: `query_db.py`, lines 13–14 and 38 **Vulnerability Type**: Hardcoded secret and plaintext credential exposure **Risk Level**: Critical ### Vulnerable Code ```python MYSQL_USER = "root" MYSQL_PASSWORD = "123456" ``` ```python cmd = f'docker exec {MYSQL_CONTAINER} mysql -u{MYSQL_USER} -p{MYSQL_PASSWORD} {database} -e "{sql}"' ``` ### Technical Analysis The script embeds a plaintext MySQL root password directly in source code. Anyone with access to the project, source archives, backups, or copied logs can recover the credential. The password is also inserted into the command-line arguments passed to `docker exec` and the MySQL client. Depending on the remote system configuration, command arguments may be visible through process inspection, monitoring systems, diagnostic output, or audit logs. Because the associated database user is `root`, disclosure of this credential has substantially greater consequences than disclosure of a narrowly scoped application credential. ### Attack Path 1. An attacker obtains read access to the project, a source archive, a backup, or output containing the constructed command. 2. The attacker extracts the hardcoded username and password. 3. The attacker identifies an accessible MySQL endpoint or gains command access to the configured development host. 4. The attacker authenticates using the recovered root credential. 5. The attacker accesses any database objects available to the MySQL root account. ### Impact Assessment If the credential is valid, an attacker could obtain full administrative access to the MySQL instance. The potential scope includes disclosure, modification, and deletion of data across all accessible databases, account or privilege changes, and interference with database availability. The exact network reachability of MySQL is not established by the reviewed files, but local access through the configured development host is explicitly part of the skill's i ...[truncated 24 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Rotate the exposed password immediately and investigate whether it has appeared in repositories, logs, backups, or process-monitoring records. 2. Remove all credentials from source code and repository history. 3. Store secrets in an approved secret manager or a protected credential file with restrictive permissions. 4. Avoid passing passwords as command-line arguments. Use a protected MySQL option file, secret mount, or another mechanism that does not expose the password in process arguments. 5. Replace the root account with a dedicated, read-only service account restricted to the required schema and operations. 6. Add automated secret scanning to source-control and CI workflows. ]]>
