CVE-2026-33306
bcrypt-ruby has an Integer Overflow that Causes Zero Key-Strengthening Iterations at Cost=31 on JRuby
Also known as GHSA-f27w-vcwj-c954
Mitigation
- Upgrade bcrypt to 3.1.22 or later.
Who should check
- Projects that depend on RubyGems package bcrypt (< 3.1.22)
- Anyone running bcrypt-ruby < 3.1.22
Vulnerability facts
- Affected
- bcrypt < 3.1.22
- Fixed in
- 3.1.22
- Exploited in the wild
- Not in CISA KEV
- Public exploit / PoC
- None known
- Remote exploitation
- Not remotely exploitable (local or adjacent access needed)
- CVSS
- 4.5 (v4.0, CNA)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:UOpen in CVSS calculator
Show all 12 CVSS metrics
- Attack vector: Local
- Attack complexity: High
- Attack requirements: Present
- Privileges required: None
- User interaction: None
- Confidentiality impact: High
- Integrity impact: High
- Availability impact: None
- Confidentiality impact on other systems: None
- Integrity impact on other systems: None
- Availability impact on other systems: None
- Exploit maturity: Unreported
- EPSS
- 0.29% chance of exploitation in 30 days (percentile 14, 2026-11-26)
- CWE
- CWE-190
- Modified
Description
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.
Affected and fixed versions
| Package / product | Affected | Fixed | Source |
|---|---|---|---|
| RubyGems bcrypt | < 3.1.22 | 3.1.22 | osv |
| bcrypt-ruby | < 3.1.22 | — | cvelist |
Check your systems with an agent
Paste this into Claude Code, Cursor or another coding agent. It only reads; it changes nothing.
Check whether anything I run is affected by CVE-2026-33306. Work read-only: do not install, upgrade, delete or change anything. Details: https://flawdb.com/CVE-2026-33306.md Affected: bcrypt < 3.1.22 Fixed in: 3.1.22 Steps: 1. Search this machine and project for bcrypt (RubyGems), bcrypt-ruby: dependency manifests and lockfiles, installed packages, container images and running services. 2. For each match, note the installed version and whether it is inside the affected range. 3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
References
Vendor advisories
FAQ
Is CVE-2026-33306 being exploited?
There is no confirmed exploitation: CVE-2026-33306 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.29% chance of exploitation in the next 30 days (as of 2026-11-26).
How serious is CVE-2026-33306?
Medium: CVSS 4.5 (v4.0, scored by CNA). Not remotely exploitable (local or adjacent access needed). The attack needs conditions outside the attacker's control, which makes it harder.
Which versions are affected by CVE-2026-33306?
bcrypt < 3.1.22.
Is there a fix for CVE-2026-33306?
Yes. Fixed in 3.1.22. Upgrade bcrypt to 3.1.22 or later.
How do I check if I'm affected by CVE-2026-33306?
Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.