T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/fraud_analyzer.py:16
- Finding
- Hardcoded Production Database Credentials<![CDATA[ ## Vulnerability Details **File Locations**: - `scripts/fraud_analyzer.py:16-23` - `scripts/analyze_task_completers.py:17-23` - `scripts/analyze_user_publisher_tasks.py:16-22` - `scripts/analyze_user_tasks_completers.py:17-23` - `scripts/check_fraud.py:16-22` - `scripts/check_fraud_enhanced.py:17-23` - `scripts/query_user_detail.py:16-22` - `scripts/query_user_login_logs.py:16-22` - `scripts/query_user_task_ops.py:16-22` - `scripts/query_user_visit_logs.py:16-22` - `scripts/query_users_by_ip.py:16-22` - `SKILL.md:54-59` - `README.md:135-144` **Vulnerability Type**: Hardcoded database secret and insecure credential distribution **Risk Level**: Critical ### Vulnerable Code ```python DB_CONFIG = { 'host': 'rr-wz97dxha81orq30j0eo.mysql.rds.aliyuncs.com', 'port': 3389, 'user': 'oc_gw', 'password': 'm83KkZVLQp2Wg7HgDVb5cRjQ', 'database': 'yc_db', 'charset': 'utf8mb4' } ``` The same endpoint, username, and password are also published in the project documentation and duplicated across the query scripts. ### Technical Analysis The package embeds a reusable credential for an externally addressed Alibaba Cloud MySQL database. Anyone who can read the project can extract the credential and attempt to connect to the database without going through an authenticated application or authorization-enforcing service. The secret is not scoped to an individual operator or invocation. Its duplication across source files and documentation also makes revocation and secret rotation more difficult. Removing it from only one file would not eliminate the exposure, and prior copies may remain in distribution archives or version-control history. The connection configuration does not explicitly enable certificate-validated TLS. Consequently, the code does not demonstrate that database server identity or transport confidentiality is enforced. ### Attack Path 1. An attacker downloads, receives, or otherwise reads the Skill package. 2. The attacker extra ...[truncated 1325 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Immediately revoke and rotate the exposed database password. 2. Review database audit logs for connections and queries made using the exposed account. 3. Remove the credential from every source file, documentation file, release artifact, and version-control revision. 4. Treat the credential as compromised even if the database is currently protected by network filtering. 5. Replace direct database access with an authenticated internal API that performs: - Operator authentication - Role-based authorization - Case-scoped access checks - Row-level authorization - Output minimization and masking - Query auditing and rate limiting 6. If direct database access is operationally unavoidable, retrieve short-lived credentials from an approved secret manager rather than environment-independent plaintext files. 7. Restrict the database account to read-only access on narrowly defined views containing only fields required for fraud analysis. 8. Apply network allowlisting and deny public database access wherever possible. 9. Require TLS with certificate and hostname validation. 10. Use separate credentials per service or operator so access can be attributed and independently revoked. 11. Add automated secret scanning to CI and pre-commit checks. ]]>
