T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/email_watcher.py:19
- Finding
- Hard-Coded Mailbox Credential and Account Identifiers<![CDATA[ ## Vulnerability Details **File Location**: `scripts/email_watcher.py`, lines 19-25 **Vulnerability Type**: Hard-coded secrets and sensitive account identifiers **Risk Level**: High ### Vulnerable Code ```python EMAIL = "1257037084@qq.com" AUTH_CODE = "xtepatkcgckvhjhf" IMAP_SERVER = "imap.qq.com" IMAP_PORT = 993 WHITELIST_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "whitelist.json") PROCESSED_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "processed_emails.json") QQ_TARGET = "6E07D3F2F7EC1C7107ECF9D495FF4755" ``` ### Technical Analysis The source code contains a QQ mailbox address, an IMAP authorization code, and a QQ OpenID. Any person or system with access to the project package can extract these values without requiring additional privileges. The exposed IMAP authorization code is especially sensitive because `connect_mail()` uses it directly to authenticate to `imap.qq.com`. If the credential remains valid, possession of the source package may be sufficient to access the associated mailbox through IMAP. This implementation also contradicts the documentation's placeholder-based configuration model and prevents secrets from being independently protected or rotated without changing source code. ### Attack Path 1. An attacker obtains a copy of the project directory, source archive, repository history, log attachment, or deployed script. 2. The attacker reads the `EMAIL` and `AUTH_CODE` constants. 3. The attacker connects to `imap.qq.com` on port 993 using IMAPS. 4. The attacker authenticates with the exposed mailbox address and authorization code. 5. If the authorization code is still active, the attacker accesses mailbox content within the permissions granted by QQ's IMAP service. ### Impact Assessment Successful exploitation may disclose email subjects, senders, bodies, verification codes, account recovery messages, financial information, and other sensitive mailbox content accessible through IMAP. The ...[truncated 309 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Revoke the exposed QQ IMAP authorization code immediately and generate a replacement. 2. Remove all real credentials and account identifiers from the source code and repository history. 3. Read secrets from environment variables or a protected secret-management service: ```python EMAIL = os.environ["QQ_EMAIL"] AUTH_CODE = os.environ["QQ_IMAP_AUTH_CODE"] QQ_TARGET = os.environ["QQ_TARGET"] ``` 4. Fail securely at startup if required variables are missing; do not provide sensitive default values. 5. Restrict secret-file permissions to the service account if a local configuration file must be used. 6. Add local secret files to `.gitignore` and distribute only a placeholder configuration template. 7. Enable automated secret scanning in the development and release pipeline. 8. Review mailbox access records for unauthorized use and rotate any related credentials that may also have been exposed. ]]>
