2.3low
net-imap: Quadratic complexity when reading response literals
- Severity
- 2.3low CVSS:4.0 by GitHub_M
- Exploit likelihood
- 0.41% (higher than 37% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-q2mw-fvj9-vvcw
Description
Net::IMAP implements Internet Message Access Protocol (IMAP) client functionality in Ruby. Prior to versions 0.4.24, 0.5.14, and 0.6.4, Net::IMAP::ResponseReader has quadratic time complexity when reading large responses containing many string literals. A hostile server can send responses which are crafted to exhaust the client's CPU for a denial of service attack. This issue has been patched in versions 0.4.24, 0.5.14, and 0.6.4.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| ruby net-imap | < 0.4.24, >= 0.5.0, < 0.5.14, >= 0.6.0, < 0.6.4 | CVE List |
| net-imap (RubyGems) | from 0.6.0 before 0.6.4, from 0.5.0 before 0.5.14, before 0.4.24 | GitHub Advisory Database |
| ruby-lang net::imap | before 0.4.24, from 0.5.0 before 0.5.14, from 0.6.0 before 0.6.4 | NVD |
All scores
| GitHub_M | 2.3low CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N |
| GitHub | low CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N |
| NVD | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
Classification
SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.
What each source says
CVE List
Net::IMAP implements Internet Message Access Protocol (IMAP) client functionality in Ruby. Prior to versions 0.4.24, 0.5.14, and 0.6.4, Net::IMAP::ResponseReader has quadratic time complexity when reading large responses containing many string literals. A hostile server can send responses which are crafted to exhaust the client's CPU for a denial of service attack. This issue has been patched in versions 0.4.24, 0.5.14, and 0.6.4.
GitHub Advisory Database
Summary
Net::IMAP::ResponseReader has quadratic time complexity when reading large responses containing many string literals. A hostile server can send responses which are crafted to exhaust the client's CPU for a denial of service attack.
Details
For each literal in a response, ResponseReader rescans the entire growing response buffer. The regular expression that is used to scan the response buffer runs in linear time. With many literals, this becomes O(n²) total work. The regular expression should run in constant time: it is anchored to the end and only the last 23 bytes of the buffer are relevant.
Because the algorithmic complexity is super-linear, this bypasses protection from max_response_size: a response can stay well below the default size limit while still causing very large CPU cost.
Net::IMAP::ResponseReader runs continuously in the receiver thread until the connection closes.
Impact
This consumes disproportionate CPU time in the client's receiver thread. A hostile server could use this to exhaust the client's CPU for a denial of service attack.
For a response near the default max_response_size, each individual regexp scan could take between 100 to 200ms on common modern hardware, and this may be repeated 200k times per megabyte of response. While the regexp is scanning, it retains the Global VM lock, preventing other threads from running.
Although other threads should not be completely blocked, their run time will be significantly impacted.
Mitigation
- Upgrade to a patched version of net-imap that reads responses more efficiently.
- Do not connect to untrusted IMAP servers.
- When connecting to untrusted servers, a much smaller
max_response_size(for example: 8KiB) will limit the impact. Although this is too small for fetching unpaginated message bodies, it should be enough for most other operations.
NVD (es)
Net::IMAP implementa la funcionalidad de cliente del Protocolo de Acceso a Mensajes de Internet (IMAP) en Ruby. Antes de las versiones 0.4.24, 0.5.14 y 0.6.4, Net::IMAP::ResponseReader tiene una complejidad temporal cuadrática al leer respuestas grandes que contienen muchos literales de cadena. Un servidor hostil puede enviar respuestas diseñadas para agotar la CPU del cliente para un ataque de denegación de servicio. Este problema ha sido parcheado en las versiones 0.4.24, 0.5.14 y 0.6.4.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-42245 changed 2026-05-12 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-q2mw-fvj9-vvcw changed 2026-09-10 | CC-BY-4.0 |
| NVD | CVE-2026-42245 changed 2026-07-24 | Public domain |