// Security Advisory Triage

imaplib STARTTLS serves buffered plaintext as TLS-protected in CPython 3.14.0+

Python security announcements · published 2026-11-13 19:46 UTC
ACTION NEEDED VERIFY_EXPOSURE SECURITYAPI
WHAT CHANGEDCPython 3.14.0 introduced a regression in imaplib where IMAP4.starttls() wraps the socket in TLS but leaves the internal read-ahead buffer (self._readbuf) untouched. Plaintext bytes that arrived in the same recv() as the STARTTLS OK response are returned by readline() after the TLS handshake completes, causing the client to treat forged plaintext responses as if they came over the protected channel. The vulnerability is CVE-2026-115559, caused by commit 0fef47e which added IMAP4 IDLE support. CPython 3.13.13 and earlier are not affected.
WHY IT MATTERSA network attacker who cannot break TLS can inject forged IMAP responses (CAPABILITY, tagged command completions) after the server's legitimate STARTTLS OK. The client accepts these forged responses as authenticated because they appear to arrive after the TLS handshake with a valid certificate. This is a STARTTLS command/response injection vulnerability (same class as CVE-2011-0411).
WHAT TO DOCheck whether you are running CPython 3.14.0 or later with code that uses imaplib.IMAP4.starttls(). If so, apply the fix in GitHub pull request 160370. Remediation: see bulletin https://www.cve.org/CVERecord?id=CVE-2026-115559
Model-reported confidence 95% (not measured accuracy) Primary source ↗ written by anthropic/claude-sonnet-4.5
Show the reasoning — raw diff, triage verdict, confidence
RAW DIFF
+## [Security-announce][CVE-2026-115559] imaplib STARTTLS serves plaintext bytes buffered before the handshake as if they came over TLS
+https://mail.python.org/archives/list/security-announce@python.org/message/LVAGFOFG26QVXEM6VXXPRMMOZBHM4CVB/
+Tue, 10 Nov 2026 17:41:54 +0000
+
+There is a medium severity vulnerability affecting the imaplib library
+in CPython.
+
+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.
+
+First affected release: 3.14.0. The regression comes from the IMAP4
+IDLE support in gh-55454 (commit 0fef47e), which replaced
+self._file.readline() with the custom _readbuf buffering. Before that,
+starttls() replaced the file object and so discarded buffered
+plaintext; 3.13.13 is not affected.
+
+Please see the linked CVE ID for the latest information on affected versions:
+
+* https://www.cve.org/CVERecord?id=CVE-2026-115559
+* https://github.com/python/cpython/pull/160370
+
+Thanks to @digit50 for reporting this issue.
HOW IT WAS JUDGED
Triage signals below are model-reported assertions, preserved verbatim; they are not independent arithmetic verification.
triage verdictMATERIAL at 0.95, needed 0.5
triage reasoningPython standard library vulnerability in imaplib affecting any service using STARTTLS for IMAP connections.
signalsPython standard library vulnerability · imaplib STARTTLS command/response injection · affects CPython 3.14.0+ · plaintext bytes treated as TLS-protected · network attacker can forge IMAP responses · regression from recent IDLE support change · CVE assigned and published
suppression—
triage modelanthropic/claude-haiku-4.5 ($0.00000)
writer modelanthropic/claude-sonnet-4.5 ($0.00000)