T09 · Insecure Skill Coding Practices
Error
- Location
- send_mail.py:7
- Finding
- Hard-Coded SMTP Credentials Expose the Email Account<![CDATA[ ## Vulnerability Details **File Location**: `send_mail.py`, lines 7-10 **Vulnerability Type**: Hard-coded secret and plaintext credential exposure **Risk Level**: Critical ### Vulnerable Code ```python smtp_server = "smtp.cloudtrend.com.cn" smtp_port = 587 sender = "ai_assistant@cloudtrend.com.cn" password = "A5b3C3D6!" ``` ### Technical Analysis A plaintext SMTP account and password are embedded directly in the distributed source code. Any person or process able to read the skill package can recover these credentials without invoking the intended skill interface. Source repositories, package archives, backups, build logs, and copied installations can preserve the secret even after it is removed from the latest version. The credential must therefore be considered compromised. If it is valid, an attacker can use an independent SMTP client to authenticate directly to the configured server. ### Attack Path 1. An attacker obtains read access to the skill source, a repository clone, a package archive, or a backup containing `send_mail.py`. 2. The attacker extracts the SMTP hostname, port, sender address, and plaintext password from lines 7-10. 3. The attacker connects to `smtp.cloudtrend.com.cn` on port `587`. 4. The attacker initiates STARTTLS and authenticates as `ai_assistant@cloudtrend.com.cn`. 5. If the credential remains valid, the attacker sends unauthorized messages using the compromised account, subject to the SMTP account's server-side permissions and limits. No access to the Agent's normal skill interface is required after the credential has been recovered. ### Impact Assessment Successful exploitation can provide the attacker with the SMTP sending privileges assigned to the exposed account. This may enable: - Unauthorized or fraudulent email delivery. - Impersonation of the configured sender. - Phishing or spam originating from a trusted organizational domain. - Reputational damage and mail-domain blocklisting. - Consumption of send ...[truncated 346 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Revoke and rotate the exposed SMTP password immediately; deleting it from the current file is insufficient because historical copies may remain. 2. Review SMTP authentication and sending logs for unauthorized use of the account. 3. Store the replacement credential in a managed secret store or a protected runtime environment variable. 4. Use an application-specific token rather than a reusable account password where supported. 5. Restrict the SMTP account to the minimum required permissions, sender identities, recipient scope, and sending rate. 6. Ensure secret files and environment configuration are readable only by the service account that executes the skill. 7. Add automated secret scanning to source-control and release pipelines. 8. Rewrite repository history or invalidate all exposed values if the file was committed to source control. 9. Return generic authentication errors to users and keep sanitized diagnostics only in access-controlled logs. A safer configuration pattern is: ```python import os smtp_server = os.environ["SMTP_SERVER"] smtp_port = int(os.environ.get("SMTP_PORT", "587")) sender = os.environ["SMTP_SENDER"] password = os.environ["SMTP_PASSWORD"] ``` ]]>
