GHSA-q2mw-fvj9-vvcw

Suggest an improvement
Source
https://github.com/advisories/GHSA-q2mw-fvj9-vvcw
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/05/GHSA-q2mw-fvj9-vvcw/GHSA-q2mw-fvj9-vvcw.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-q2mw-fvj9-vvcw
Aliases
  • CVE-2026-42245
Downstream
Related
Published
2026-05-04T22:02:56Z
Modified
2026-05-05T20:14:25.359214663Z
Severity
  • 2.3 (Low) CVSS_V4 - 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 CVSS Calculator
Summary
net-imap has quadratic complexity when reading response literals
Details

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.
Database specific
{
    "cwe_ids": [
        "CWE-407"
    ],
    "github_reviewed_at": "2026-05-04T22:02:56Z",
    "github_reviewed": true,
    "severity": "LOW",
    "nvd_published_at": null
}
References

Affected packages

RubyGems / net-imap

Package

Name
net-imap
Purl
pkg:gem/net-imap

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0.6.0
Fixed
0.6.4

Affected versions

0.*
0.6.0
0.6.1
0.6.2
0.6.3

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/05/GHSA-q2mw-fvj9-vvcw/GHSA-q2mw-fvj9-vvcw.json"
last_known_affected_version_range
"<= 0.6.3"

RubyGems / net-imap

Package

Name
net-imap
Purl
pkg:gem/net-imap

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0.5.0
Fixed
0.5.14

Affected versions

0.*
0.5.0
0.5.1
0.5.2
0.5.3
0.5.4
0.5.5
0.5.6
0.5.7
0.5.8
0.5.9
0.5.10
0.5.11
0.5.12
0.5.13

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/05/GHSA-q2mw-fvj9-vvcw/GHSA-q2mw-fvj9-vvcw.json"
last_known_affected_version_range
"<= 0.5.13"

RubyGems / net-imap

Package

Name
net-imap
Purl
pkg:gem/net-imap

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
0.4.24

Affected versions

0.*
0.1.0
0.1.1
0.2.0
0.2.1
0.2.2
0.2.3
0.2.4
0.2.5
0.3.0
0.3.1
0.3.2
0.3.3
0.3.4
0.3.4.1
0.3.5
0.3.6
0.3.7
0.3.8
0.3.9
0.3.10
0.4.0
0.4.1
0.4.2
0.4.3
0.4.4
0.4.5
0.4.6
0.4.7
0.4.8
0.4.9
0.4.9.1
0.4.10
0.4.11
0.4.12
0.4.13
0.4.14
0.4.15
0.4.16
0.4.17
0.4.18
0.4.19
0.4.20
0.4.21
0.4.22
0.4.23

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/05/GHSA-q2mw-fvj9-vvcw/GHSA-q2mw-fvj9-vvcw.json"
last_known_affected_version_range
"<= 0.4.23"