T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/imap-test.py:27
- Finding
- IMAP credentials can be transmitted without transport encryption## Vulnerability Details **File Location**: `scripts/imap-test.py:27-46`; `scripts/mailbox-size.py:36-42`; related unsafe guidance at `references/troubleshooting.md:301-304` **Vulnerability Type**: Optional plaintext authentication over IMAP **Risk Level**: High ### Vulnerable Code `scripts/imap-test.py:27-46`: ```python # Create IMAP connection if use_ssl: print("Connecting with SSL/TLS...") if port == 993: imap = imaplib.IMAP4_SSL(server, port) else: # STARTTLS connection print("Using STARTTLS on non-standard port...") imap = imaplib.IMAP4(server, port) imap.starttls() else: print("Connecting without encryption (not recommended)...") imap = imaplib.IMAP4(server, port) print("✅ Connected successfully") # Test authentication print(f"Authenticating as {username}...") result = imap.login(username, password) ``` `scripts/mailbox-size.py:36-42`: ```python # Create IMAP connection if use_ssl: imap = imaplib.IMAP4_SSL(server, port) else: imap = imaplib.IMAP4(server, port) # Login imap.login(username, password) ``` Both scripts expose the insecure mode through a command-line flag: ```python parser.add_argument('--no-ssl', action='store_true', help='Disable SSL/TLS encryption') ``` The troubleshooting guide also recommends insecure transport as a diagnostic action: ```text ### Third-Party Tools (ImapSync, etc.) **Solutions:** 1. Install required dependencies 2. Use --nossl for testing 3. Process in smaller chunks 4. Monitor system resources ``` ### Technical Analysis When `--no-ssl` is selected, each script creates an ordinary `imaplib.IMAP4` connection and then invokes `imap.login(username, password)` without first negotiating STARTTLS. The IMAP authentication exchange therefore lacks transport confidentiality and integrity. The warning printed by `imap-test.py` does ...[truncated 1887 chars]
- Remediation
- ## Remediation Suggestions 1. Remove the `--no-ssl` option from both scripts. 2. Require either: - Implicit TLS through `imaplib.IMAP4_SSL`; or - STARTTLS before any authentication command. 3. Preserve certificate-chain and hostname validation. Do not add a certificate-bypass option. 4. If plaintext connectivity diagnostics are indispensable, prohibit `LOGIN`, `AUTHENTICATE`, and all other credential-bearing commands in that mode. 5. Separate unauthenticated TCP reachability testing from authenticated IMAP testing. 6. Remove documentation that recommends `--nossl` or temporarily disabling certificate validation. 7. Clearly state that authentication must never occur over plaintext IMAP, including on test networks. 8. Prefer OAuth2 or narrowly scoped, revocable app passwords where supported.
