imaplib STARTTLS serves plaintext bytes buffered before the handshake as if they came over TLS

State
Published
Severity
6.3 Medium
Published
Nov 10, 2026
Updated
Nov 16, 2026
Reserved
Oct 22, 2026

Read the record on cve.org

Description

IMAP4.starttls() wraps the socket in TLS but leaves self._readbuf, imaplib's own read-ahead buffer, untouched. Any plaintext bytes that arrived in the same recv() as the tagged OK to STARTTLS are returned by readline() after the handshake, so the client treats them as the first responses on the protected channel. A network attacker who cannot break TLS can append forged lines after the server's OK, let the handshake complete with the real server and a valid certificate, and have the client accept the forged CAPABILITY and the forged tagged completion of the next command. This is the STARTTLS command/response injection class of CVE-2011-0411.

ProductVersions
CPython Python Software Foundationbefore 3.16.0 Affected

Weaknesses

  • CWE-319 Cleartext Transmission of Sensitive Information

References

Every record here comes from the CVE Program's CVE List. © 1999-2026 The MITRE Corporation. CVE is a registered trademark of The MITRE Corporation. The records are reproduced under the CVE Program terms of use.

© 2026 NVIDIA, the NVIDIA logo, and NVIDIA Inception are trademarks and/or registered trademarks of NVIDIA Corporation in the U.S. and other countries.