{"id":"CVE-2026-33306","published":"2026-03-24T00:08:00Z","modified":"2026-03-24T15:39:03Z","title":"bcrypt-ruby has an Integer Overflow that Causes Zero Key-Strengthening Iterations at Cost=31 on JRuby","vendor":"bcrypt-ruby","product":"bcrypt-ruby","tier":"tail","description":{"text":"bcrypt-ruby is a Ruby binding for the OpenBSD bcrypt() password hashing algorithm. Prior to version 3.1.22, an integer overflow in the Java BCrypt implementation for JRuby can cause zero iterations in the strengthening loop.  Impacted applications must be setting the cost to 31 to see this happen. The JRuby implementation of bcrypt-ruby (`BCrypt.java`) computes the key-strengthening round count as a signed 32-bit integer. When `cost=31` (the maximum allowed by the gem), signed integer overflow causes the round count to become negative, and the strengthening loop executes **zero iterations**. This collapses bcrypt from 2^31 rounds of exponential key-strengthening to effectively constant-time computation — only the initial EksBlowfish key setup and final 64x encryption phase remain. The resulting hash looks valid (`$2a$31$...`) and verifies correctly via `checkpw`, making the weakness invisible to the application. This issue is triggered only when cost=31 is used or when verifying a `$2a$31$` hash. This problem has been fixed in version 3.1.22. As a workaround, set the cost to something less than 31.","provenance":"source","from":"CVE.org"},"cvss":{"score":4.5,"severity":"MEDIUM","version":"4.0","vector":"CVSS:4.0/AV:L/AC:H/AT:P/PR:N/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N/E:U","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.00247,"percentile":0.163,"provenance":"source"},"cwes":[{"id":"CWE-190","name":"Integer Overflow or Wraparound"}],"references":[{"url":"https://github.com/bcrypt-ruby/bcrypt-ruby/security/advisories/GHSA-f27w-vcwj-c954","tags":["x_refsource_CONFIRM"]},{"url":"https://github.com/bcrypt-ruby/bcrypt-ruby/commit/831ce64cb0a9502130fa93a28bfd9527a5fa45c4","tags":["x_refsource_MISC"]},{"url":"https://github.com/bcrypt-ruby/bcrypt-ruby/releases/tag/v3.1.22","tags":["x_refsource_MISC"]}],"priority":{"score":6.4,"factors":[{"name":"EPSS percentile","points":3.26},{"name":"CVSS severity","points":3.15}]},"vendorSlug":"bcrypt-ruby","affectedVersions":[{"vendor":"bcrypt-ruby","product":"bcrypt-ruby","versions":["< 3.1.22"]}],"ssvc":{"exploitation":"none","automatable":"no","technicalImpact":"partial","timestamp":"2026-03-24T15:38:08.809169Z","from":"CISA ADP","provenance":"source"},"affected":[{"ecosystem":"RubyGems","package":"bcrypt","vulnerableRanges":["<3.1.22"],"patched":["3.1.22"],"from":["GHSA-f27w-vcwj-c954"],"provenance":"source"}],"summary":{"text":"The bcrypt-ruby gem's JRuby implementation (the Java BCrypt code, BCrypt.java) computes the key-strengthening round count as a signed 32-bit integer, so at the maximum cost of 31 the count overflows and the strengthening loop runs zero iterations. An attacker with local access and no privileges can, when an application uses cost 31 (or verifies a $2a$31$ hash), exploit this to obtain password hashes that are far cheaper to brute-force, though user interaction and a high-complexity condition are needed for it to apply.","provenance":"ai","model":"claude-haiku-5-5","generatedAt":"2026-11-20T22:18:46Z"},"euvd":{"id":"EUVD-2026-14670","exploited":false,"provenance":"source"}}