T09 · Insecure Skill Coding Practices
- Location
scripts/imap-test.py:27- Finding
IMAP credentials can be transmitted without transport encryption
- Content
View full analysis
Vulnerability Details
File Location:
scripts/imap-test.py:27-46;scripts/mailbox-size.py:36-42; related unsafe guidance atreferences/troubleshooting.md:301-304
Vulnerability Type: Optional plaintext authentication over IMAP
Risk Level: HighVulnerable 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 resourcesTechnical Analysis
When
--no-sslis selected, each script creates an ordinaryimaplib.IMAP4connection and then invokesimap.login(username, password)without first negotiating STARTTLS. The IMAP authentication exchange therefore lacks transport confidentiality and integrity.The warning printed by
imap-test.pydoes ...[truncated 1887 chars]- Remediation
View remediation
Remediation Suggestions
- Remove the
--no-ssloption from both scripts. - Require either:
- Implicit TLS through
imaplib.IMAP4_SSL; or - STARTTLS before any authentication command.
- Implicit TLS through
- Preserve certificate-chain and hostname validation. Do not add a certificate-bypass option.
- If plaintext connectivity diagnostics are indispensable, prohibit
LOGIN,AUTHENTICATE, and all other credential-bearing commands in that mode. - Separate unauthenticated TCP reachability testing from authenticated IMAP testing.
- Remove documentation that recommends
--nosslor temporarily disabling certificate validation. - Clearly state that authentication must never occur over plaintext IMAP, including on test networks.
- Prefer OAuth2 or narrowly scoped, revocable app passwords where supported.
- Remove the
