VAITP Dataset

← Back to the dataset

CVE-2026-115774

Negative size in IMAP SEARCH causes infinite loop, freezing Twisted reactor.

  • CVSS 4.9
  • CWE-400
  • Resource Management
  • Remote

Twisted is an event-based framework for internet applications, supporting Python 3.6+. Prior to 26.10.0rc1, twisted.mail.imap4.IMAP4Server reaches twisted.mail.imap4.parseNestedParens with a negative literal size in an authenticated SEARCH command after the client enters the selected mailbox state. The negative size moves the parser cursor below zero, and Python's negative indexing prevents the synchronous scanning loop from terminating. The loop freezes the single-threaded reactor, stopping other IMAP connections and any SMTP or POP3 services hosted in the same process until restart. This issue is fixed in version 26.10.0rc1.

CVSS base score
4.9
Published
2026-10-23
OWASP
A05 Security Misconfiguration
Orthogonal defect classification
Algorithm
Code defect classification
Incorrect Algorithm
Category
Resource Management
Subcategory
Resource Exhaustion
Accessibility scope
Remote
Impact
Denial of Service (DoS)
Affected component
Twisted
Fixed by upgrading
Yes

Solution

Upgrade Twisted to version 26.10.0rc1 or later.

Vulnerable code sample

from twisted.mail import imap4

def handle_search(line: bytes, buffer: bytes) -> None:
    # Extract literal size from the SEARCH command, e.g. b'SEARCH { -5 }\r\n'
    parts = line.split(b'{')
    if len(parts) < 2:
        return
    size_part = parts[1].split(b'}')[0].strip()
    # VULNERABLE: negative literal size leads to infinite parsing loop
    literal_size = int(size_part)          # may be negative
    imap4.parseNestedParens(buffer, literal_size)

Patched code sample

from twisted.mail import imap4

def handle_search(line: bytes, buffer: bytes) -> None:
    # Extract literal size from the SEARCH command, e.g. b'SEARCH { -5 }\r\n'
    parts = line.split(b'{')
    if len(parts) < 2:
        return
    size_part = parts[1].split(b'}')[0].strip()
    # FIX: reject negative literal sizes before parsing
    literal_size = int(size_part)
    if literal_size < 0:
        raise ValueError("Negative literal size in SEARCH command")
    imap4.parseNestedParens(buffer, literal_size)

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

Cite this entry

@misc{vaitp:cve2026115774,
  title        = {{Negative size in IMAP SEARCH causes infinite loop, freezing Twisted reactor.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-115774},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-115774/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.