CVE-2026-42256: net-imap vulnerable to denial of service via high iteration count for `SCRAM-*` authentication
Summary When authenticating a connection with SCRAM-SHA1 or SCRAM-SHA256, a hostile server can perform a computational denial-of-service attack on the client process by sending a big iteration count value. Details A hostile IMAP server can send an arbitrarily large PBKDF2 iteration count in the SCRAM server-first-message, causing the client to perform an expensive OpenSSL::KDF.pbkdf2hmac call.
Published May 4, 2026 · Updated May 14, 2026
Affected packages
net-imap
- Ecosystem
- RubyGems
- Affected
- >= 0.6.0, <= 0.6.3
- Fixed in
- 0.6.4
- Check
bundle info net-imap
net-imap
- Ecosystem
- RubyGems
- Affected
- >= 0.5.0, <= 0.5.13
- Fixed in
- 0.5.14
- Check
bundle info net-imap
net-imap
- Ecosystem
- RubyGems
- Affected
- >= 0.4.0, <= 0.4.23
- Fixed in
- 0.4.24
- Check
bundle info net-imap
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
When authenticating a connection with SCRAM-SHA1 or SCRAM-SHA256, a hostile server can perform a computational denial-of-service attack on the client process by sending a big iteration count value.
Details
A hostile IMAP server can send an arbitrarily large PBKDF2 iteration count in the SCRAM server-first-message, causing the client to perform an expensive OpenSSL::KDF.pbkdf2_hmac call. Because the PBKDF2 function is a blocking C extension and holds onto Ruby’s Global VM Lock, it can freeze the entire Ruby VM for the duration of the computation.
OpenSSL enforces an effective maximum by using a 32-bit signed integer for the iteration count, Depending on hardware capabilities and OpenSSL version, this iteration count may be sufficient for to block all Ruby threads in the process for over seven minutes.
This is listed as one of the "Security Considerations", in RFC 7804: > A hostile server can perform a computational denial-of-service attack on clients by sending a big iteration count value. In order to defend against that, a client implementation can pick a maximum iteration count that it is willing to use and reject any values that exceed that threshold (in such cases, the client, of course, has to fail the authentication).
Impact
During SCRAM authentication to a hostile server, the entire Ruby VM will be locked for the duration of the computation. Depending on hardware capabilities and OpenSSL version, this may take many minutes.
OpenSSL::KDF.pbkdf2_hmac is a blocking C function, so Timeout cannot be used to guard against this. And it retains the Global VM lock, so other ruby threads will also be unable to run.
Mitigation
- Upgrade to a patched version of
net-imapthat adds themax_iterationsoption to theSASL-*authenticators, and callNet::IMAP#authenticatewith amax_iterationskeyword argument.
NOTE: The default max_iterations is 2³¹ - 1, the maximum signed 32 bit integer, the maximum allowed by OpenSSL. _To prevent a denial of service attack,_ this must be set to a safe value, depending on hardware and version of OpenSSL. _It is the user's responsibility_ to enforce minimum and maximum iteration counts that are appropriate for their security context.
- Alternatively, avoid
SCRAM-*mechanisms when authenticating to untrusted servers.
Credited to Masamuneee.
References
- https://github.com/ruby/net-imap/security/advisories/GHSA-87pf-fpwv-p7m7
- https://github.com/ruby/net-imap/commit/158d0b505074397cdb5ceb58935e42dd2bcfa612
- https://github.com/ruby/net-imap/commit/808001bc45c06f7297a7e96d341279e041a7f7f4
- https://github.com/ruby/net-imap/commit/99f59eab6064955a23debd95410263ad144df758
- https://github.com/ruby/net-imap/releases/tag/v0.4.24
- https://github.com/ruby/net-imap/releases/tag/v0.5.14
- https://github.com/ruby/net-imap/releases/tag/v0.6.4
- https://www.rfc-editor.org/rfc/rfc7804.html#page-15
- https://nvd.nist.gov/vuln/detail/CVE-2026-42256
- https://github.com/rubysec/ruby-advisory-db/blob/master/gems/net-imap/CVE-2026-42256.yml
- https://github.com/advisories/GHSA-87pf-fpwv-p7m7
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More RubyGems vulnerabilities
All RubyGems entriesCVE-2026-47240
Net::IMAP: Command Injection via non-synchronizing literal in "raw" argument
medium5.8Jun 9, 2026CVE-2026-47241
Net::IMAP: Denial of Service via incomplete raw argument validation
low2.1Jun 9, 2026CVE-2026-47242
Net::IMAP: Command Injection via ID command argument
medium5.8Jun 9, 2026CVE-2026-42245
net-imap has quadratic complexity when reading response literals
low2.3May 4, 2026CVE-2026-42246
net-imap vulnerable to STARTTLS stripping via invalid response timing
high7.6May 4, 2026CVE-2026-42257
net-imap vulnerable to command Injection via "raw" arguments to multiple commands
medium5.8May 4, 2026
