Twisted: Denial of Service in the Twisted IMAP4 Server via a Negative Literal Size in SEARCH
影響パッケージ
| 種類 | パッケージ | 影響を受ける版 | 直った版 |
|---|---|---|---|
| twisted | twisted | — | — |
| pip | Twisted |
26.10.0rc1 未満 |
26.10.0rc1 |
原文の説明 取得元が公開している説明をそのまま載せています (多くは英語)。
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:
# 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 select_SEARCH through arg_searchkeys, dispatched only in the selected state, so a valid login and a selected mailbox (any low-privilege account) suffice. It r…
出典: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory