Skip to content

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

MediumCVSS 4.5 EPSS 0.24% PoC
Published
Updated
Exploit status
Proof-of-concept only
CISA SSVC
No known exploitation · automatable: no · technical impact: partial
Technology
DebianRed Hat

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.

Upgrade path

6 packages: 3 fixed, 2 with no fix yet.

PackageAffectedFixed inStatus
debian/ruby-bcrypt(Debian 12) = 3.1.18-1; = 3.1.20-1; = 3.1.21-1; = 3.1.22-1 +1 more No fix listed No fix yet
debian/ruby-bcrypt(Debian 13) = 3.1.20-1; = 3.1.21-1; = 3.1.22-1; All versions No fix listed No fix yet
bcrypt-ruby project bcrypt-ruby < 3.1.22 3.1.22 Fixed
debian/ruby-bcrypt(Debian 14) < 3.1.22-1; = 3.1.20-1; = 3.1.21-1 3.1.22-1 Fixed
rubygems bcrypt(RubyGems) < 3.1.22; <= 3.1.21; = 3.1.3; = 3.1.6 +16 more 3.1.22 Fixed
bcrypt-ruby = < 3.1.22 No fix listed Versions listed

Affected products

ProductAffected versionsFixed in
rubygems bcrypt(RubyGems) < 3.1.22 3.1.22
rubygems bcrypt(RubyGems) = 3.1.10 No fix listed
rubygems bcrypt(RubyGems) = 3.1.11 No fix listed
rubygems bcrypt(RubyGems) = 3.1.12 No fix listed
rubygems bcrypt(RubyGems) = 3.1.12.rc1 No fix listed
rubygems bcrypt(RubyGems) = 3.1.13 No fix listed
rubygems bcrypt(RubyGems) = 3.1.14 No fix listed
rubygems bcrypt(RubyGems) = 3.1.15 No fix listed
rubygems bcrypt(RubyGems) = 3.1.16 No fix listed
rubygems bcrypt(RubyGems) = 3.1.17 No fix listed
rubygems bcrypt(RubyGems) = 3.1.18 No fix listed
rubygems bcrypt(RubyGems) = 3.1.19 No fix listed
rubygems bcrypt(RubyGems) = 3.1.20 No fix listed
rubygems bcrypt(RubyGems) = 3.1.21 No fix listed
rubygems bcrypt(RubyGems) = 3.1.3 No fix listed
rubygems bcrypt(RubyGems) = 3.1.6 No fix listed
rubygems bcrypt(RubyGems) = 3.1.7 No fix listed
rubygems bcrypt(RubyGems) = 3.1.8 No fix listed
rubygems bcrypt(RubyGems) = 3.1.9 No fix listed
bcrypt-ruby = < 3.1.22 No fix listed
rubygems bcrypt(RubyGems) <= 3.1.21 No fix listed
debian/ruby-bcrypt(Debian:12) All versions No fix listed
debian/ruby-bcrypt(Debian:12) = 3.1.18-1 No fix listed
debian/ruby-bcrypt(Debian:12) = 3.1.20-1 No fix listed
debian/ruby-bcrypt(Debian:12) = 3.1.21-1 No fix listed
Show 9 more
ProductAffected versionsFixed in
debian/ruby-bcrypt(Debian:12) = 3.1.22-1 No fix listed
debian/ruby-bcrypt(Debian:13) All versions No fix listed
debian/ruby-bcrypt(Debian:13) = 3.1.20-1 No fix listed
debian/ruby-bcrypt(Debian:13) = 3.1.21-1 No fix listed
debian/ruby-bcrypt(Debian:13) = 3.1.22-1 No fix listed
debian/ruby-bcrypt(Debian:14) < 3.1.22-1 3.1.22-1
debian/ruby-bcrypt(Debian:14) = 3.1.20-1 No fix listed
debian/ruby-bcrypt(Debian:14) = 3.1.21-1 No fix listed
bcrypt-ruby project bcrypt-ruby < 3.1.22 3.1.22

References