CVE-2026-115774: Twisted: Denial of Service in the Twisted IMAP4 Server via a Negative Literal Size in SEARCH

Published Oct 23, 2026
·
Updated

Summary

An infinite-loop vulnerability (CWE-835) in the Twisted IMAP4 server lets an authenticated client freeze the whole process with one small command. twisted.mail.imap4.parseNestedParens reads an IMAP literal size with int() and never rejects a negative value. A negative size such as {-100} drives the parser cursor negative, and because a negative Python index wraps around the end of the string instead of raising, the scanning loop never terminates. It runs synchronously on the single-threaded reactor, so one SEARCH command holds the reactor at full CPU forever and every other connection stops being served.

Details

Meeting an inline literal, parseNestedParens reads the size between the braces and advances the cursor past the body:

python twisted/mail/imap4.py parseNestedParens literalSize = int(s[i + 1 : end]) # no sign check contentStack[-1].append((s[end + 3 : end + 3 + literalSize],)) i = end + 3 + literalSize # negative size -> i goes negative

int(b"-100") is -100, so i goes negative; the loop condition i < len(s) stays true and s[i : i + 1] on a negative index never raises, so the cursor cycles forever. The literalStringLimit guard only covers the synchronizing-literal continuation path, not this inline branch. The call is reached from selectSEARCH through argsearchkeys, dispatched only in the selected state, so a valid login and a selected mailbox (any low-privilege account) suffice. It runs in the reactor thread, and the connection timeout cannot fire because the reactor itself is frozen.

Affected product: Twisted (twisted.mail), the IMAP4 server twisted.mail.imap4.IMAP4Server Affected versions: 26.4.0 and earlier

PoC

Log in, select a mailbox, and send a SEARCH whose literal size is negative:

text C: t1 LOGIN testuser password-test C: t2 SELECT INBOX C: t3 SEARCH {-100}zzzzzzzzzz

The server never responds and one core stays at 100 percent. In a measured run a health service co-hosted on the same reactor stopped answering the instant the command arrived, showing the freeze hits the whole process and not just the attacking connection. A valid {5}zzzzz completes normally and a non-numeric {abc} is rejected with a parse error, which isolates the cause to the missing negative-size check.

Impact

A remote denial of service. One command of about ten bytes freezes the single-threaded reactor, so it stops serving not only every other IMAP connection but every other service co-hosted in the same process (for example SMTP and POP3 under twistd mail), and no timeout can recover it until the process is restarted. It requires an authenticated session, so any account holder can trigger it; there is no confidentiality or integrity impact and no code execution.

Other sources

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.

— MITRE

Affected Software

2 affected componentsFixes available
pypi/Twisted<26.10.0rc1
pip/twisted<=26.4.0
26.10.0rc1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/Twisted to a version that resolves this vulnerability.

    Fixed in 26.10.0rc1
  2. Upgrade

    Upgrade Twisted to a version that resolves this vulnerability.

    Fixed in 26.10.0rc1

Event History

Oct 23, 2026
CVE Published
via MITRE·08:14 PM
Data Sourced
via MITRE·08:14 PM
DescriptionSeverityWeakness
Advisory Published
via GitHub·08:46 PM
Data Sourced
via GitHub·08:46 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

Which deployments are exposed?

Deployments using twisted.mail.imap4.IMAP4Server in Twisted versions before 26.10.0rc1 are affected. The client must be able to authenticate to IMAP and enter the selected mailbox state.

2

What does an attacker need to do to trigger the issue?

An authenticated IMAP client sends a SEARCH command containing a negative literal size after selecting a mailbox. No user interaction is required.

3

How broadly can the outage affect services?

The parsing loop freezes Twisted's single-threaded reactor. This stops other IMAP connections and can also stop SMTP or POP3 services when they are hosted in the same process, until that process is restarted.

4

What version contains the fix?

The issue is fixed in Twisted version 26.10.0rc1.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203