Skip to main content

net-imap CVE-2026-42245

LOW
Inefficient Algorithmic Complexity (CWE-407)
2026-05-04 https://github.com/ruby/net-imap GHSA-q2mw-fvj9-vvcw
2.3
CVSS 4.0 · Vendor: https://github.com/ruby/net-imap
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Establish IMAP connection to server
  2. Delivery
    Server transmits response with many string literals
  3. Exploit
    ResponseReader begins parsing response
  4. Execution
    Regex rescans entire buffer for each literal (O(n²) work)
  5. Persist
    Global VM lock held, blocking other threads
  6. Impact
    CPU exhausted, application becomes unresponsive

Vulnerability Assessment

Weakness
CWE
ASVS 5.0
V2 - Validation and Business Logic Algorithmic complexity limits
Exploitation Conditions

The vulnerability requires the client application to establish a connection to an IMAP server controlled by or compromised by an attacker. No authentication bypass is required - the attacker only needs to send a malicious IMAP response over the connection. The attack is triggered automatically when the receiver thread reads the response; no client-side user action is needed. Exploitation is limited to scenarios where the application connects to untrusted or externally-hosted IMAP servers, or where an attacker can perform man-in-the-middle interception of IMAP connections (unless TLS is enforced with certificate pinning). Applications connecting only to trusted internal IMAP servers or servers under the organization's control are not at risk unless the server is compromised by an attacker.

Impact

This is a denial of service vulnerability with medium-to-high real-world risk but limited default exploitability. CVSS vector is not provided, but attack vector is clearly network (AV:N) with no authentication required (PR:N) and no user interaction (UI:N). Complexity is low (AC:L) because the attacker only needs to connect as an IMAP server. However, no public exploit code is identified, and this requires the client to connect to a hostile server - a prerequisite that limits opportunistic exploitation. EPSS data is absent, so probability calculation is uncertain. The technical impact is significant: CPU exhaustion in production IMAP clients can cascade into application-level denial of service, hanging message synchronization and blocking foreground operations. The algorithmic flaw allows small responses (well under max_response_size) to consume disproportionate resources, making traditional size-based rate limiting ineffective. Organizations using net-imap in production (especially for mail synchronization, automated message processing, or persistent connections to external IMAP services) face real risk if they interact with untrusted servers or if malicious actors can control IMAP server responses.

Exploit ScenarioDerived

An attacker controls or compromises an IMAP server that a Ruby application connects to. The attacker crafts an IMAP response containing hundreds of thousands of small string literals (e.g., {100} ...{100} ...) staying below the default max_response_size limit. When the client's receiver thread parses this response, the ResponseReader rescans the accumulated buffer O(n) times, each with a linear regex, blocking the receiver thread for seconds or minutes and holding the Global VM lock. Other application threads attempting I/O or CPU-bound work experience severe latency, causing the application to appear frozen or unresponsive.

Monitor Track and reassess. Why: LOW severity (CVSS 0.1-3.9).
Patch available 0.1% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – May 04, 2026

net-imap ResponseReader exhibits quadratic time complexity O(n²) when parsing IMAP responses containing multiple string literals, allowing hostile IMAP servers to exhaust client CPU and block other threads via denial of service. A maliciously crafted response can consume 100-200ms per regex scan repeated hundreds of thousands of times per megabyte, holding the Global VM lock and starving concurrent threads despite staying within max_response_size limits. Vendor-released patches available in versions 0.4.24, 0.5.14, and 0.6.4.

RemediationAI

Upgrade net-imap to version 0.4.24 (for 0.4.x branch), 0.5.14 (for 0.5.x branch), or 0.6.4 (for 0.6.x branch) or later. The patches are available in RubyGems and GitHub releases. For applications that cannot immediately upgrade, implement a mitigating configuration: reduce max_response_size to 8 KiB or smaller when connecting to untrusted IMAP servers (trade-off: cannot fetch unpaginated message bodies larger than the limit, suitable for control operations). Avoid connecting to untrusted IMAP servers if possible. Patched code is available in commits 6091f7d6b1f3514cafbfe39c76f2b5d73de3ca96 and 88d95231fc8afef11c1f074453f7d75b68c9dfda on the main branch. See https://github.com/ruby/net-imap/security/advisories/GHSA-q2mw-fvj9-vvcw for detailed remediation guidance.

Affected Packages

rubygems net-imap fix: 0.4.24, 0.5.14, 0.6.4

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in rubygems

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

Net::IMAP::ResponseReader is the Ruby standard library's IMAP protocol parser. The vulnerability stems from CWE-407 (inefficient algorithm) in the response buffer parsing logic. For each literal string in an IMAP server response, the code rescans the entire accumulated buffer using a regular expression anchored to detect the literal size marker (e.g., {1024} ). This linear-time regex scan runs once per literal, creating quadratic total complexity. The regex /\{(\d+)\}\r\n\z/n operates on an ever-growing buffer, becoming progressively more expensive. Additionally, the regex retains Ruby's Global VM lock during execution, preventing parallel thread execution even when other threads are ready to run. The fix optimizes by only scanning the trailing bytes of each appended line (constant time operation) and caching the literal size state.

Know when the next one hits your stack

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (https://github.com/ruby/net-imap) PRIMARY 2.3 LOW
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

Primary rating from Vendor (https://github.com/ruby/net-imap) · only source for this CVE.

CVSS VectorVendor: https://github.com/ruby/net-imap

Attack Vector
Network
Attack Complexity
Low
Attack Requirements
Present
Privileges Required
None
User Interaction
Passive
Vulnerable system: Confidentiality
None
Vulnerable system: Integrity
None
Vulnerable system: Availability
Low
Subsequent system: Confidentiality
None
Subsequent system: Integrity
None
Subsequent system: Availability
None

Lifecycle Timeline

1
CVSS changed
May 09, 2026 - 20:22 NVD
2.3 (LOW)

DescriptionCVE.org

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.

Threat Intelligence Overview

EPSS Score
0.1%
Top 81% exploitable
Threat Intel
1
1 source
Data Quality
5 sources
Confidence: Medium
NVD CVE.org EPSS GHSA GitHub VulDB

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity LOW
CISA KEV No
Public POC No
EPSS 0.1%
Patch available Yes
Active threat No
Deciding rule
LOW severity (CVSS 0.1-3.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Defer
Exploitation· derived
None
System Exposure· derived
Open
Automatable· derived
No
Human Impact· derived
Low

Priority Score

12
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +12
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Denial of Service attacks render applications or systems unavailable by overwhelming resources or triggering failure conditions.

Affected Products (CPE)CVE.org

pkg:rubygems/net-imap
pkg:rubygems/net-imap
pkg:rubygems/net-imap

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy