Vulnerabilities in pkg:pypi/Twisted
PACKAGECVE-2026-106454 is a MODERATE (CVSS 4.3) denial of service vulnerability (CWE-1333: Inefficient Regular Expression Complexity) affecting Twisted libraries in the PyPI ecosystem. The issue involves imap wildcardtoregexp() redos. Remediation is available in the latest vendor maintenance releases.
pkg:pypi/Twisted
Vulnerability advisories affecting package pkg:pypi/Twisted. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-8pqf-f4m5-798g | CVE-2026-106454 | MODERATE | Twisted: IMAP wildcardToRegexp() ReDoS |
| GHSA-grgv-6hw6-v9g4 | CVE-2026-42304 | HIGH | Twisted has a Denial of Service (DoS) in twisted.names via Crafted DNS Compression Pointer Chains |
| GHSA-xc8x-vp79-p3wm | CVE-2023-46137 | MODERATE | twisted.web has disordered HTTP pipeline response |
| GHSA-vg46-2rrj-3647 | CVE-2022-39348 | MODERATE | Twisted vulnerable to NameVirtualHost Host header injection |
| GHSA-3c45-wgjp-7v9r | CVE-2014-7143 | HIGH | Python Twisted trustRoot is not respected in HTTP client |
| GHSA-65rm-h285-5cc5 | CVE-2019-12855 | CRITICAL | Improper Certificate Validation in Twisted |
| GHSA-c2jg-hw38-jrqq | CVE-2022-24801 | CRITICAL | Inconsistent Interpretation of HTTP Requests in twisted.web |
| GHSA-92x2-jw7w-xvvx | CVE-2022-21712 | HIGH | Cookie and header exposure in twisted |
| GHSA-p5xh-vx83-mxcj | CVE-2020-10109 | CRITICAL | HTTP Request Smuggling in Twisted |
| GHSA-h96w-mmrf-2h6v | CVE-2020-10108 | CRITICAL | Improper Input Validation in Twisted |
| GHSA-3gqj-cmxr-p4x2 | CVE-2016-1000111 | MODERATE | Forced Browsing in Twisted |
CVE-2026-106454 at a Glance
Security Impact
CVSS: 4.3
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L).
How to Fix CVE-2026-106454
To remediate this vulnerability, upgrade all affected Twisted dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install Twisted>=Latest secure release
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show Twisted
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2026-106454, inspect your installed packages using pip:
pip show Twisted
Analyze the terminal output to locate any version of Twisted in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), your application is affected.
Note: The pip show Twisted command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-1333: Inefficient Regular Expression Complexity, where the product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential. In Twisted, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-106454 Affected Twisted Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
Twisted
|
PyPI |
≤ 26.4.0
|
|
References
Frequently Asked Questions
What is CVE-2026-106454?
Which Twisted versions are affected?
What version fixes CVE-2026-106454?
Is Twisted affected?
What is the CVSS score of CVE-2026-106454?
What CWE is associated with CVE-2026-106454?
How can I check PyPI dependencies for CVE-2026-106454?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-8pqf-f4m5-798g",
"modified" : "2026-10-15T14:02:08Z",
"published" : "2026-10-07T16:18:30Z",
"aliases" : [ "CVE-2026-106454" ],
"summary" : "Twisted: IMAP wildcardToRegexp() ReDoS",
"details" : "### Summary\n`wildcardToRegexp()` in `twisted/mail/imap4.py` converts IMAP LIST/LSUB wildcard patterns to Python regular expressions. It substitutes the two IMAP wildcards (`*` → `(?:.*?)` and `%` → `(?:(?:[^\\\\/])*?)`) but passes every other character through unchanged to `re.compile()`. This means that an authenticated IMAP client can send a quoted pattern string containing arbitrary regex syntax - including catastrophic-backtracking constructs such as `(a+)+z`.\n\nBecause Twisted runs a cooperative, single-threaded reactor, a blocking regex match freezes **all** I/O on the server for the duration of the match.\n\n---\n\n## Vulnerable Code\n\n### `twisted/mail/imap4.py`\n\n```python\n# line 4595\ndef wildcardToRegexp(wildcard, delim=None):\n wildcard = wildcard.replace(\"*\", \"(?:.*?)\")\n if delim is None:\n wildcard = wildcard.replace(\"%\", \"(?:.*?)\")\n else:\n wildcard = wildcard.replace(\"%\", \"(?:(?:[^%s])*?)\" % re.escape(delim))\n return re.compile(wildcard, re.I) # ← user input compiled verbatim\n```\n\n```python\n# line 4993\nclass MemoryAccountWithoutNamespaces:\n def listMailboxes(self, ref, wildcard):\n ref = self._inferiorNames(_parseMbox(ref.upper()))\n wildcard = wildcardToRegexp(wildcard, \"/\") # ← user-supplied wildcard\n return [(i, self.mailboxes[i]) for i in ref if wildcard.match(i)]\n```\n---\n\n### Proof of Concept\n\n```python\nfrom twisted.mail.imap4 import wildcardToRegexp\nimport time\n\nrx = wildcardToRegexp(\"(a+)+z\", \"/\")\nfor n in [20, 22, 24, 26, 28]:\n victim = \"a\" * n\n t0 = time.perf_counter()\n rx.match(victim)\n print(f\"n={n}: {time.perf_counter() - t0:.3f}s\")\n```\n\n**Output on Twisted 25.5.0:**\n\n```\n[*] Compiled regex: '(a+)+z'\n[*] Note: metacharacters ( ) + ? are NOT escaped - they go straight to re.compile()\n\n n time\n --- ----------\n 20 0.153s\n 22 0.651s\n 24 2.941s\n 26 14.545s\n 28 55.019s\n```\n\nTiming doubles roughly every two characters (exponential growth), confirming catastrophic backtracking.\n\n---\n\n## Impact\n\nTwisted's reactor is single-threaded and cooperative. A blocking `re.match()` call suspends the entire event loop - no other connection can be accepted, read, or written while the match runs. A single authenticated LIST command with a 28-character target mailbox name can stall the server for ~55 seconds.\n\nAn attacker who can register an account (or obtain credentials through other means) can:\n\n1. `CREATE` a mailbox whose name is an exponential-blowup trigger string.\n2. Issue `LIST \"\" \"(a+)+z\"` (or equivalent ReDoS pattern).\n3. Repeat at ~1-minute intervals to keep the server permanently unavailable.\n\nNo exploit code or special privileges beyond an IMAP login are required.\n\n---\n\n## Fix\n\nEscape non-wildcard characters before compiling:\n\n```python\ndef wildcardToRegexp(wildcard, delim=None):\n # Split on the two IMAP wildcards, escape everything else\n parts = re.split(r'([*%])', wildcard)\n result = []\n for p in parts:\n if p == '*':\n result.append('(?:.*?)')\n elif p == '%':\n if delim is None:\n result.append('(?:.*?)')\n else:\n result.append('(?:(?:[^%s])*?)' % re.escape(delim))\n else:\n result.append(re.escape(p)) # ← escape all other characters\n return re.compile(''.join(result), re.I)\n```\n\nAlternatively, apply `re.escape()` to the entire wildcard first, then substitute the (now-escaped) `\\*` and `\\%` tokens back with their regex equivalents.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "Twisted"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"last_affected" : "26.4.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/twisted/twisted/security/advisories/GHSA-8pqf-f4m5-798g"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-106454"
}, {
"type" : "WEB",
"url" : "https://github.com/twisted/twisted/pull/12788"
}, {
"type" : "WEB",
"url" : "https://github.com/twisted/twisted/commit/2f8a3c29246f4eb324690e06a9767a11dc4aec9f"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/twisted/twisted"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-1333" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2026-10-07T16:18:30Z",
"nvd_published_at" : "2026-10-06T20:17:27Z"
}
}