T09 · Insecure Skill Coding Practices
- Location
scripts/email.js:68- Finding
IMAP TLS Certificate Validation Is Disabled
- Content
View full analysis
Vulnerability Details
File Location:
scripts/email.js:68-76andscripts/email.js:149-157
Vulnerability Type: Improper certificate validation
Risk Level: HighThe vulnerability appears in both IMAP connection paths:
js const imap = new Imap({ user: config.email, password: config.password, host: config.imap.host, port: config.imap.port, tls: config.imap.secure, tlsOptions: { rejectUnauthorized: false } });Technical Analysis
Setting
rejectUnauthorizedtofalseinstructs the TLS client to accept certificates that cannot be validated against a trusted certificate authority. This defeats server authentication even when the IMAP connection uses TLS.The client supplies
config.emailandconfig.passwordto the connected IMAP endpoint. Because the endpoint's identity is not verified, an attacker able to intercept or redirect network traffic can impersonate the configured mail server using an untrusted certificate. The issue affects bothlistEmails()andreadEmail().Sending credentials over the network is necessary for the declared IMAP functionality, but disabling certificate verification is not necessary and exceeds an acceptable minimum-risk implementation.
Attack Path
- The user invokes the
list,read, ortestcommand. - The Skill connects to the host specified by
config.imap.host. - An attacker controlling DNS resolution, a network gateway, a proxy, or another network interception point redirects the connection to an attacker-controlled IMAP service.
- The attacker presents a self-signed, expired, or otherwise untrusted certificate.
- The client accepts the certificate because
rejectUnauthorizedisfalse. - The client authenticates to the impersonated endpoint, potentially exposing the mailbox address and reusable authorization code.
- Depending on the negotiated authentication mechanism and interception environment, the attacker m ...[truncated 568 chars]
- The user invokes the
- Remediation
View remediation
Remediation Suggestions
- Remove the
tlsOptionsoverride and rely on Node.js certificate validation:js const imap = new Imap({ user: config.email, password: config.password, host: config.imap.host, port: config.imap.port, tls: config.imap.secure }); - Alternatively, explicitly set
rejectUnauthorized: true. - Fail closed and display a clear error when certificate validation fails.
- If private mail infrastructure requires a custom certificate authority, accept a narrowly scoped CA file through configuration rather than disabling validation globally.
- Validate that secure IMAP configurations use TLS and an appropriate port.
- Apply the corrected TLS configuration consistently to both
listEmails()andreadEmail(). - Rotate the configured mailbox authorization code if the Skill has previously been used over an untrusted network.
- Remove the
