bcrypt-ruby has an Integer Overflow that Causes Zero Key-Strengthening Iterations at Cost=31 on JRuby
Key facts
- Attack vector
- Local
- Privileges required
- None
- User interaction
- None
- Attack complexity
- High
- Attack requirements
- Present
- Impact type
- Code execution
- Confidentiality · integrity · availability
- High · High · None
- Fix status
- Fixed
Attack profile from CVSS 4.0 · CNA. Fix status from CNA and GitHub. Impact type from CWE-190 and the CVSS impact.
Summary
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.
Why it matters now
SSVC decision points
CISA ADP · SSVC 2.0.3
- Exploitation
- None
- Automatable
- No
- Technical impact
- Partial
The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| bcrypt-ruby | bcrypt-ruby | before 3.1.22 | 3.1.22 | Patch available | CNA |
| — | bcrypt (RubyGems) | before 3.1.22 | 3.1.22 | Patch available | GHSA-f27w-vcwj-c954 |
- bcrypt-ruby Vendorbcrypt-ruby Affected before 3.1.22 Fixed in 3.1.22 Patch available CNA
- bcrypt (RubyGems) Vendor— Affected before 3.1.22 Fixed in 3.1.22 Patch available GHSA-f27w-vcwj-c954
CPE configurations NVD · 1
| CPE | Versions | Role | Vendor |
|---|---|---|---|
| cpe:2.3:a:bcrypt-ruby_project:bcrypt-ruby:*:*:*:*:*:ruby:*:* | before 3.1.22 | Vulnerable | Bcrypt-ruby Project |
- cpe:2.3:a:bcrypt-ruby_project:bcrypt-ruby:*:*:*:*:*:ruby:*:* Versions before 3.1.22 Vulnerable ·Bcrypt-ruby Project
Remediation
- Fix · CNA bcrypt-ruby (bcrypt-ruby) Fixed in 3.1.22
- Fix · GHSA-f27w-vcwj-c954 bcrypt (RubyGems) Fixed in 3.1.22 Advisory →
Vendor assessments
Red Hat
Red Hat rating: Moderate. Red Hat's page for this CVE →
Not affected: 1 product
- Red Hat Satellite 6
Timeline
- 2026-10-02 Threatist record created from CVE-2026-33306
- 2026-10-03 Alias added: GHSA-f27w-vcwj-c954
References
Advisory 2
Sources
- CVE-2026-33306 · CVE Program
- CVE-2026-33306 · NVD
- FIRST EPSS
- GHSA-f27w-vcwj-c954 · GitHub Advisory Database · CC BY 4.0
- CVE-2026-33306 · Red Hat security data · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences