CVE-2026-33306: Bcrypt Bcrypt-ruby Has An Integer Overflow Vulnerability
MODERATECVE-2026-33306 is a MODERATE bcrypt-ruby has an integer overflow vulnerability (CWE-190: Integer Overflow or Wraparound) affecting Bcrypt libraries in the RubyGems ecosystem. The issue involves bcrypt-ruby has an integer overflow that causes zero key-strengthening iterations at cost=31 on jruby. Remediation is available by upgrading affected packages to version 3.1.22.
CVE-2026-33306 at a Glance
How to Fix CVE-2026-33306
To remediate this vulnerability, upgrade all affected Bcrypt dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade bcrypt to 3.1.22
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for bcrypt
How to Check if You Are Affected
To determine whether your application is affected by CVE-2026-33306, inspect your project dependencies for Bcrypt:
inspect dependencies for bcrypt
Analyze the terminal output to locate any version of Bcrypt in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.1.22), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-190: Integer Overflow or Wraparound, where the product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. this occurs when an integer value is incremented to a value that is too large to store in the associated representation. when this occurs, the value may become a very small or negative number. In Bcrypt, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-33306 Affected Bcrypt Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
bcrypt
|
RubyGems |
< 3.1.22
|
3.1.22
|
References
Frequently Asked Questions
What is CVE-2026-33306?
Which Bcrypt versions are affected?
What version fixes CVE-2026-33306?
Is bcrypt affected?
What CWE is associated with CVE-2026-33306?
How can I check RubyGems dependencies for CVE-2026-33306?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-f27w-vcwj-c954",
"modified" : "2026-03-25T21:36:33Z",
"published" : "2026-03-19T17:54:17Z",
"aliases" : [ "CVE-2026-33306" ],
"summary" : "bcrypt-ruby has an Integer Overflow that Causes Zero Key-Strengthening Iterations at Cost=31 on JRuby",
"details" : "### Impact\n\nAn 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.\n\nThe 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.\n\nThe 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.\n\n### Patches\n\nThis problem has been fixed in version 3.1.22\n\n### Workarounds\n\nSet the cost to something less than 31.",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "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"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "RubyGems",
"name" : "bcrypt"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.1.22"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 3.1.21"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/bcrypt-ruby/bcrypt-ruby/security/advisories/GHSA-f27w-vcwj-c954"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-33306"
}, {
"type" : "WEB",
"url" : "https://github.com/bcrypt-ruby/bcrypt-ruby/commit/831ce64cb0a9502130fa93a28bfd9527a5fa45c4"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/bcrypt-ruby/bcrypt-ruby"
}, {
"type" : "WEB",
"url" : "https://github.com/bcrypt-ruby/bcrypt-ruby/releases/tag/v3.1.22"
}, {
"type" : "WEB",
"url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/bcrypt/CVE-2026-33306.yml"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-190" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2026-03-19T17:54:17Z",
"nvd_published_at" : "2026-03-24T01:17:02Z"
}
}