{"id":"CVE-2026-42245","aliases":["CVE-2026-42245","GHSA-q2mw-fvj9-vvcw"],"related":[],"kind":"vulnerability","state":"published","title":"net-imap: Quadratic complexity when reading response literals","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"### 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.","format":"markdown","source":"ghsa"},{"lang":"es","text":"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.","source":"nvd"}],"published":"2026-05-04T22:02:56.000Z","modified":"2026-09-10T03:51:06.713Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":2.3,"rating":"LOW"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":2.3,"rating":"LOW"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"LOW"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"}],"cwes":["CWE-407"],"affected":[{"ranges":[{"version":"< 0.4.24","status":"affected"},{"version":">= 0.5.0, < 0.5.14","status":"affected"},{"version":">= 0.6.0, < 0.6.4","status":"affected"}],"vendor":"ruby","product":"net-imap","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0.6.0","status":"affected","fixed":"0.6.4"}],"ecosystem":"RubyGems","package":"net-imap","purl":"pkg:gem/net-imap","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0.5.0","status":"affected","fixed":"0.5.14"}],"ecosystem":"RubyGems","package":"net-imap","purl":"pkg:gem/net-imap","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"0.4.24"}],"ecosystem":"RubyGems","package":"net-imap","purl":"pkg:gem/net-imap","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"0.4.24"},{"status":"affected","introduced":"0.5.0","fixed":"0.5.14"},{"status":"affected","introduced":"0.6.0","fixed":"0.6.4"}],"vendor":"ruby-lang","product":"net::imap","cpe":"cpe:2.3:a:ruby-lang:net\\:\\:imap:*:*:*:*:*:ruby:*:*","source":"nvd"}],"references":[{"url":"https://github.com/ruby/net-imap/security/advisories/GHSA-q2mw-fvj9-vvcw","tags":["mitigation","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ruby/net-imap/commit/6091f7d6b1f3514cafbfe39c76f2b5d73de3ca96","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ruby/net-imap/commit/88d95231fc8afef11c1f074453f7d75b68c9dfda","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ruby/net-imap/commit/de685f91a4a4cc75eb80da898c2bf8af08d34819","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ruby/net-imap/releases/tag/v0.4.24","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ruby/net-imap/releases/tag/v0.5.14","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ruby/net-imap/releases/tag/v0.6.4","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-42245","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/ruby/net-imap","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/rubysec/ruby-advisory-db/blob/master/gems/net-imap/CVE-2026-42245.yml","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2026-05-12T17:53:55.917Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-42245","url":"https://www.cve.org/CVERecord?id=CVE-2026-42245","licence":"CVE Terms of Use","modified":"2026-05-12T18:30:58.415Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-q2mw-fvj9-vvcw","url":"https://github.com/advisories/GHSA-q2mw-fvj9-vvcw","licence":"CC-BY-4.0","modified":"2026-09-10T03:51:06.713Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-42245","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-42245","licence":"Public domain","modified":"2026-07-24T19:10:00.160Z"}],"updatedAt":"2026-11-25T22:59:21.147Z","epss":{"score":0.0041,"percentile":0.3733,"date":"2026-12-01T12:00:22.000Z"}}