A man-in-the-middle attacker can cause Net::IMAP#starttls to return "successfully", without starting TLS.
When using Net::IMAP#starttls to upgrade a plaintext connection to use TLS, a man-in-the-middle attacker can inject a tagged OK response with an easily predictable tag. By sending the response before the client finishes sending the command, the command completes "successfully" before the response handler is registered. This allows #starttls to return without error, but the response handler is never invoked, the TLS connection is never established, and the socket remains unencrypted.
This allows man-in-the-middle attackers to perform a STARTTLS stripping attack, unless the client code explicitly checks Net::IMAP#tls_verified?.
TLS bypass, leading to cleartext transmission of sensitive information.
#starttls does not establish TLS.STARTTLS with a cleartext port.
This is strongly recommended anyway:
Net::IMAP#tls_verified? is true, before using the connection after #starttls.{
"github_reviewed": true,
"github_reviewed_at": "2026-05-04T22:01:52Z",
"cwe_ids": [
"CWE-392",
"CWE-393",
"CWE-636",
"CWE-754",
"CWE-841"
],
"severity": "HIGH",
"nvd_published_at": null
}