CVE-2026-115559

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

Published Nov 10, 2026 CVSS 4.0 · 6.3 Medium EPSS < 1% KEV · Not listed
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.

Analysis

AI-generated

Technical impact

The flaw occurs when Python’s imaplib wraps the socket in TLS via STARTTLS but fails to reset its internal read‑ahead buffer. Plaintext bytes that arrive in the same network packet containing the server’s OK to STARTTLS remain in the buffer and are later returned as if they were encrypted. A network attacker who cannot decrypt TLS but can influence the ordering of packets can inject forged responses after the OK line. The client then accepts these forged CAPABILITY lists and command completions as genuine, potentially misleading application logic and allowing the attacker to manipulate the client’s behavior. According to the CWE list, it is classified as CWE-319, indicating improper handling of sensitive information. This injection class of vulnerability resembles CVE‑2011‑0411 and can lead to improper authentication logic or data disclosure, but does not provide direct code execution.

Affected Systems

The issue affects CPython’s built‑in IMAP client library (imaplib) in all releases that implement the STARTTLS wrapper. No specific version range is specified, so any CPython version that uses the legacy imaplib implementation is susceptible.

Risk and Exploitability

The CVSS score of 6.3 indicates moderate severity. The EPSS score of less than 1 percent reflects a very low probability of exploitation in practice. The vulnerability is not listed in the CISA KEV catalog. Exploitation requires an attacker who can interpose between the client and the IMAP server during the STARTTLS handshake, which is typically limited to those on the same network path or using a compromised network router. While the attack surface is narrow, the potential impact on authenticated client sessions warrants prompt attention.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade CPython to the patched release that removes the buffered‑read bug in imaplib’s STARTTLS implementation.
  • If an upgrade cannot be performed immediately, change the client configuration to use an explicit TLS connection (IMAP4_SSL) instead of opportunistic STARTTLS, ensuring that all communication occurs under a negotiated TLS session before any data is read.
  • Optionally, add a client‑side guard that verifies that no plaintext data is returned after the STARTTLS handshake completes, and reject any unexpected responses.

Generated by OpenCVE AI on November 16, 2026 at 22:28 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories available
History
Type Values Removed Values Added
Weaknesses CWE-20
Type Values Removed Values Added
Weaknesses CWE-319
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'none', 'Technical Impact': 'partial'}, 'version': '2.0.3'}

Type Values Removed Values Added
Weaknesses CWE-20
Type Values Removed Values Added
Weaknesses CWE-200
Type Values Removed Values Added
First Time appeared Python
Python cpython
Python Software Foundation
Python Software Foundation cpython
Vendors & Products Python
Python cpython
Python Software Foundation
Python Software Foundation cpython
Type Values Removed Values Added
Weaknesses CWE-200
Type Values Removed Values Added
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.
Title imaplib STARTTLS serves plaintext bytes buffered before the handshake as if they came over TLS
References
Metrics cvssV4_0

{'score': 6.3, 'vector': 'CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N'}

Weaknesses
  • CWE-319

    Cleartext Transmission of Sensitive Information

Sources

Status
PUBLISHED
Assigner
PSF
Published
Updated
Nov 16, 2026, 6:28 PM
Reserved
Oct 22, 2026, 10:10 PM
Status
Awaiting Analysis
Published
Nov 10, 2026, 7:19 PM
Modified
Nov 16, 2026, 7:17 PM