# CVE-2026-33306: bcrypt-ruby has an Integer Overflow that Causes Zero Key-Strengthening Iterations at Cost=31 on JRuby

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** MEDIUM 4.5
- **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:U`
- **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
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.29% (percentile 14, 2026-11-26)
- **CWE:** CWE-190
- **Aliases:** GHSA-f27w-vcwj-c954
- **Published:** 2026-03-19T17:54:17.000Z
- **Modified:** 2026-06-17T10:37:17.547Z

## Who should check

- Projects that depend on RubyGems package bcrypt (\< 3.1.22)
- Anyone running bcrypt-ruby \< 3.1.22

## 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

- RubyGems `bcrypt`: affected \< 3.1.22; fixed 3.1.22 (osv)
- bcrypt-ruby: \< 3.1.22 (cvelist)

## Mitigation

- Upgrade bcrypt to 3.1.22 or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
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.
```

## 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.

## References

- vendor: <https://github.com/bcrypt-ruby/bcrypt-ruby/security/advisories/GHSA-f27w-vcwj-c954>
- vendor: <https://nvd.nist.gov/vuln/detail/CVE-2026-33306>
- patch: <https://github.com/bcrypt-ruby/bcrypt-ruby/commit/831ce64cb0a9502130fa93a28bfd9527a5fa45c4>
- other: <https://github.com/bcrypt-ruby/bcrypt-ruby/releases/tag/v3.1.22>
- other: <https://github.com/bcrypt-ruby/bcrypt-ruby>
- other: <https://github.com/rubysec/ruby-advisory-db/blob/master/gems/bcrypt/CVE-2026-33306.yml>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2026-33306>
- OSV: CC-BY 4.0 <https://osv.dev/vulnerability/GHSA-f27w-vcwj-c954> (license: <https://creativecommons.org/licenses/by/4.0/>)

HTML: <https://flawdb.com/CVE-2026-33306> · JSON: <https://flawdb.com/api/v1/entries/CVE-2026-33306>
