Skip to content

GHSA-q2mw-fvj9-vvcw CVE-2026-42245

net-imap has quadratic complexity when reading response literals

High RubyGems
Severity
0.0 / 10
High · CVSS 4.0
Exploit chance (EPSS)
0.41%
Chance of exploitation in the next 30 days. Higher than 35.26% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-407 Inefficient Algorithmic Complexity
Fix
0.6.4
Upgrade net-imap to this version or later

Description

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.

Affected versions

RubyGems

PackageVulnerableFixed in
net-imap
>= 0.6.0, < 0.6.4
0.6.4
net-imap
>= 0.5.0, < 0.5.14
0.5.14
net-imap
< 0.4.24
0.4.24

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

net-imap RubyGems → 0.6.4

bundler
bundle update net-imap # Gemfile: gem "net-imap", ">= 0.6.4"

Severity breakdown

CVSS 4.0 0.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

Attack vector
Network
Attack complexity
Low
Attack requirements
Present
Privileges required
None
User interaction
Passive
Confidentiality (vulnerable system)
None
Integrity (vulnerable system)
None
Availability (vulnerable system)
Low
Confidentiality (subsequent systems)
None
Integrity (subsequent systems)
None
Availability (subsequent systems)
None

CVSS 3.1 7.5

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High

Weakness

CWE-407: Inefficient Algorithmic Complexity

An algorithm in a product has an inefficient worst-case computational complexity that may be detrimental to system performance and can be triggered by an attacker, typically using crafted manipulations that ensure that the worst case is being reached.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-46q3-7gv7-qmgg
Net::IMAP: Command Injection via ID command argument
Medium Also affects net-imap
GHSA-c4fp-cxrr-mj66
Net::IMAP: Denial of Service via incomplete raw argument validation
Low Also affects net-imap
GHSA-8p34-64r3-mwg8
Net::IMAP: Command Injection via non-synchronizing literal in "raw" argument
Medium Also affects net-imap
GHSA-hm49-wcqc-g2xg
net-imap vulnerable to command Injection via "raw" arguments to multiple commands
Critical Also affects net-imap
GHSA-75xq-5h9v-w6px
net-imap vulnerable to command Injection via unvalidated Symbol inputs
Medium Also affects net-imap
GHSA-87pf-fpwv-p7m7
net-imap vulnerable to denial of service via high iteration count for `SCRAM-*` authentication
Medium Also affects net-imap
GHSA-vcgp-9326-pqcp
net-imap vulnerable to STARTTLS stripping via invalid response timing
High Also affects net-imap
GHSA-j3g3-5qv5-52mj
net-imap rubygem vulnerable to possible DoS by memory exhaustion
Medium Also affects net-imap
Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor