T09 · Insecure Skill Coding Practices
- Location
scripts/inbox_cleanup.py:78- Finding
Optional TLS Certificate Verification Bypass Exposes IMAP Credentials
- Content
View full analysis
imaplib.IMAP4: """Connect and authenticate to IMAP server.""" ctx = ssl.create_default_context() if skip_cert_verify: ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE if starttls: mail = imaplib.IMAP4(host, port) mail.starttls(ssl_context=ctx) else: mail = imaplib.IMAP4_SSL(host, port, ssl_context=ctx) mail.login(user, password) return mail ``` The unsafe option is also explicitly documented in `SKILL.md`: ```bash IMAP_SKIP_CERT_VERIFY=true # true = accept self-signed cert (required for Proton Bridge) ``` ### Technical Analysis When `skip_cert_verify` is enabled, the script disables both certificate-chain validation and hostname verification. TLS may still encrypt the connection, but the client no longer verifies that it is communicating with the intended IMAP server. The script subsequently transmits the IMAP username and password through `mail.login(user, password)`. An attacker able to intercept, redirect, or control the configured IMAP endpoint can present an arbitrary certificate, have it accepted by the client, and receive the authentication exchange. Network access and transmission of IMAP credentials are necessary for the declared mailbox-cleanup functionality. However, accepting an unauthenticated server is not necessary except for a narrowly constrained local self-signed service. The current implementation allows the bypass with any configurable host, exceeding the minimum safe network privilege needed for the Skill. ### Attack Path 1. A user enables `IMAP_SKIP_CERT_VERIFY=true`, as documented for sel ...[truncated 1377 chars]- Remediation
View remediation
