CVE-2026-42245: Net imap Net-imap Has Quadratic Complexity When Vulnerability

LOW
Advisory Identifier: GHSA-q2mw-fvj9-vvcw
CWE-407
Published
Advisory Summary

CVE-2026-42245 is a LOW net-imap has quadratic complexity when vulnerability (CWE-407: Inefficient Algorithmic Complexity) affecting Net imap libraries in the RubyGems ecosystem. The issue involves net-imap has quadratic complexity when reading response literals. Remediation is available by upgrading affected packages to version 0.6.4, 0.5.14, 0.4.24.

CVE-2026-42245 at a Glance

CVE Identifier CVE-2026-42245
GHSA Identifier GHSA-q2mw-fvj9-vvcw
Severity LOW
CVSS v3.1 Base Score N/A
CWE Classification CWE-407: Inefficient Algorithmic Complexity
Affected Product Net imap
Package Ecosystem RubyGems
Published Date
Last Updated

How to Fix CVE-2026-42245

To remediate this vulnerability, upgrade all affected Net imap dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

net-imap fixed: 0.6.4
Upgrade net-imap to 0.6.4
net-imap fixed: 0.5.14
Upgrade net-imap to 0.5.14
net-imap fixed: 0.4.24
Upgrade net-imap to 0.4.24
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for net-imap

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-42245, inspect your project dependencies for Net imap:

inspect dependencies for net-imap

Analyze the terminal output to locate any version of Net imap in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.6.4), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-407: Inefficient Algorithmic Complexity, where 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. In Net imap, 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

### 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.

CVE-2026-42245 Affected Net imap Versions

3 component(s)
Fixed Versions:
0.6.40.5.140.4.24
Product / Package Ecosystem Affected Versions Fixed Version
net-imap
RubyGems
≥ 0.6.0
< 0.6.4
0.6.4
net-imap
RubyGems
≥ 0.5.0
< 0.5.14
0.5.14
net-imap
RubyGems
< 0.4.24
0.4.24

References

Frequently Asked Questions

What is CVE-2026-42245?
CVE-2026-42245 is a security vulnerability in Net imap involving net-imap has quadratic complexity when reading response literals under CWE-407: Inefficient Algorithmic Complexity.
Which Net imap versions are affected?
Affected versions include releases prior to 0.6.4, 0.5.14, 0.4.24 across affected packages: net-imap.
What version fixes CVE-2026-42245?
Upgrading to 0.6.4, 0.5.14, 0.4.24 (or the latest patched release for your respective branch) resolves the vulnerability.
Is net-imap affected?
Yes, net-imap is affected in releases prior to 0.6.4, 0.5.14, 0.4.24. Upgrade your dependency to 0.6.4, 0.5.14, 0.4.24 or later.
What CWE is associated with CVE-2026-42245?
CVE-2026-42245 is classified under 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.).
How can I check RubyGems dependencies for CVE-2026-42245?
Run the dependency tree command: 'inspect dependencies for net-imap'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-q2mw-fvj9-vvcw",
  "modified" : "2026-05-14T20:48:14Z",
  "published" : "2026-05-04T22:02:56Z",
  "aliases" : [ "CVE-2026-42245" ],
  "summary" : "net-imap has quadratic complexity when reading response literals",
  "details" : "### Summary\n\n`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.\n\n### Details\n\nFor 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.\n\nBecause 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.\n\n`Net::IMAP::ResponseReader` runs continuously in the receiver thread until the connection closes.\n\n### Impact\n\nThis 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.\n\nFor 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.\n\nAlthough other threads should not be _completely_ blocked, their run time will be significantly impacted.\n\n### Mitigation\n\n* Upgrade to a patched version of net-imap that reads responses more efficiently.\n* Do not connect to untrusted IMAP servers.\n* 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.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "net-imap"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.6.0"
      }, {
        "fixed" : "0.6.4"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.6.3"
    }
  }, {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "net-imap"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.5.0"
      }, {
        "fixed" : "0.5.14"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.5.13"
    }
  }, {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "net-imap"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.4.24"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.4.23"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/ruby/net-imap/security/advisories/GHSA-q2mw-fvj9-vvcw"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-42245"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ruby/net-imap/commit/6091f7d6b1f3514cafbfe39c76f2b5d73de3ca96"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ruby/net-imap/commit/88d95231fc8afef11c1f074453f7d75b68c9dfda"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ruby/net-imap/commit/de685f91a4a4cc75eb80da898c2bf8af08d34819"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/ruby/net-imap"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ruby/net-imap/releases/tag/v0.4.24"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ruby/net-imap/releases/tag/v0.5.14"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ruby/net-imap/releases/tag/v0.6.4"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/net-imap/CVE-2026-42245.yml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-407" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-05-04T22:02:56Z",
    "nvd_published_at" : "2026-05-09T20:16:28Z"
  }
}